feat:fix subitem mixin of listitemnode in iOS

This commit is contained in:
pengfei.zhou
2019-11-19 16:15:54 +08:00
parent d7d2af8065
commit c3b656d539
7 changed files with 67 additions and 12 deletions

View File

@@ -129,15 +129,23 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
- (void)blendSubNode:(NSDictionary *)subModel {
NSString *viewId = subModel[@"id"];
[self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
if ([viewId isEqualToString:obj]) {
*stop = YES;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[key integerValue] inSection:0];
[UIView performWithoutAnimation:^{
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}];
}
}];
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
if (viewNode) {
[viewNode blend:subModel[@"props"]];
} else {
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
[self recursiveMixin:subModel to:model];
[self setSubModel:model in:viewId];
[self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
if ([viewId isEqualToString:obj]) {
*stop = YES;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[key integerValue] inSection:0];
[UIView performWithoutAnimation:^{
[self.view reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}];
}
}];
}
}
- (void)callItem:(NSUInteger)position height:(CGFloat)height {
@@ -154,7 +162,7 @@ - (void)callItem:(NSUInteger)position height:(CGFloat)height {
- (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
__block DoricViewNode *ret = nil;
dispatch_sync(dispatch_get_main_queue(), ^{
[self.doricContext.driver ensureSyncInMainQueue:^{
for (UITableViewCell *tableViewCell in self.view.visibleCells) {
if ([tableViewCell isKindOfClass:[DoricTableViewCell class]]) {
DoricListItemNode *node = ((DoricTableViewCell *) tableViewCell).doricListItemNode;
@@ -164,7 +172,7 @@ - (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
}
}
}
});
}];
return ret;
}