fix:iOS DoricListNode exception and DoricGroupNode exception

This commit is contained in:
pengfei.zhou 2020-06-22 15:12:00 +08:00 committed by osborn
parent 90a3691362
commit eabb98cee9
3 changed files with 27 additions and 12 deletions

View File

@ -77,7 +77,11 @@ - (void)configChildNodes {
viewNode.viewId = viewId;
[viewNode initWithSuperNode:self];
[viewNode blend:model[@"props"]];
[childNodes insertObject:viewNode atIndex:idx];
if (idx >= childNodes.count) {
[childNodes addObject:viewNode];
} else {
[childNodes insertObject:viewNode atIndex:idx];
}
[self.view insertSubview:viewNode.view atIndex:idx];
}
} else {
@ -95,9 +99,16 @@ - (void)configChildNodes {
DoricViewNode *reused = childNodes[(NSUInteger) position];
[childNodes removeObjectAtIndex:(NSUInteger) position];
[childNodes removeObjectAtIndex:idx];
[childNodes insertObject:reused atIndex:idx];
[childNodes insertObject:oldNode atIndex:(NSUInteger) position];
if (idx >= childNodes.count) {
[childNodes addObject:reused];
} else {
[childNodes insertObject:reused atIndex:idx];
}
if (position >= childNodes.count) {
[childNodes addObject:oldNode];
} else {
[childNodes insertObject:oldNode atIndex:(NSUInteger) position];
}
///View swap index
[reused.view removeFromSuperview];
[oldNode.view removeFromSuperview];
@ -109,7 +120,11 @@ - (void)configChildNodes {
viewNode.viewId = viewId;
[viewNode initWithSuperNode:self];
[viewNode blend:model[@"props"]];
[childNodes insertObject:viewNode atIndex:idx];
if (idx >= childNodes.count) {
[childNodes addObject:viewNode];
} else {
[childNodes insertObject:viewNode atIndex:idx];
}
[self.view insertSubview:viewNode.view atIndex:idx];
}
}
@ -123,7 +138,11 @@ - (void)configChildNodes {
viewNode.viewId = viewId;
[viewNode initWithSuperNode:self];
[viewNode blend:model[@"props"]];
[childNodes insertObject:viewNode atIndex:idx];
if (idx >= childNodes.count) {
[childNodes addObject:viewNode];
} else {
[childNodes insertObject:viewNode atIndex:idx];
}
[self.view insertSubview:viewNode.view atIndex:idx];
}
}

View File

@ -34,9 +34,4 @@ - (void)initWithSuperNode:(DoricSuperNode *)superNode {
[super initWithSuperNode:superNode];
self.reusable = YES;
}
- (void)requestLayout {
[self.view.doricLayout apply];
[super requestLayout];
}
@end

View File

@ -145,6 +145,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
DoricListItemNode *node = cell.doricListItemNode;
node.viewId = model[@"id"];
[node blend:props];
[node.view.doricLayout apply:CGSizeMake(tableView.width, tableView.height)];
[node requestLayout];
[self callItem:position height:node.view.height];
return cell;
@ -220,7 +221,7 @@ - (void)blendSubNode:(NSDictionary *)subModel {
- (void)callItem:(NSUInteger)position height:(CGFloat)height {
NSNumber *old = self.itemHeights[@(position)];
if (old && old.floatValue == height) {
if (old && [old isEqualToNumber:@(height)]) {
return;
}
self.itemHeights[@(position)] = @(height);