iOS: fix listItem cannot be animated

This commit is contained in:
pengfei.zhou 2021-12-03 17:33:22 +08:00 committed by osborn
parent c3093d9ff2
commit 0477e5790b
2 changed files with 38 additions and 38 deletions

View File

@ -293,26 +293,26 @@ - (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
}
- (void)blendSubNode:(NSDictionary *)subModel {
NSString *viewId = subModel[@"id"];
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
BOOL skipReload = NO;
if (viewNode) {
CGSize originSize = viewNode.view.frame.size;
[viewNode blend:subModel[@"props"]];
[viewNode.view.doricLayout apply];
[viewNode requestLayout];
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
skipReload = YES;
}
} else {
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
[self recursiveMixin:subModel to:model];
[self setSubModel:model in:viewId];
}
if (skipReload) {
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
NSString *viewId = subModel[@"id"];
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
BOOL skipReload = NO;
if (viewNode) {
CGSize originSize = viewNode.view.frame.size;
[viewNode blend:subModel[@"props"]];
[viewNode.view.doricLayout apply];
[viewNode requestLayout];
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
skipReload = YES;
}
} else {
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
[self recursiveMixin:subModel to:model];
[self setSubModel:model in:viewId];
}
if (skipReload) {
return;
}
[self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
if ([viewId isEqualToString:obj]) {
*stop = YES;

View File

@ -280,26 +280,26 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
- (void)blendSubNode:(NSDictionary *)subModel {
///Here async blend sub node because the item count need to be applied first.
NSUInteger currentCount = self.itemCount + (self.loadMore ? 1 : 0);
NSString *viewId = subModel[@"id"];
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
BOOL skipReload = NO;
if (viewNode) {
CGSize originSize = viewNode.view.frame.size;
[viewNode blend:subModel[@"props"]];
[viewNode.view.doricLayout apply:CGSizeMake(self.view.width, self.view.height)];
[viewNode requestLayout];
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
skipReload = YES;
}
} else {
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
[self recursiveMixin:subModel to:model];
[self setSubModel:model in:viewId];
}
if (skipReload) {
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
NSString *viewId = subModel[@"id"];
DoricViewNode *viewNode = [self subNodeWithViewId:viewId];
BOOL skipReload = NO;
if (viewNode) {
CGSize originSize = viewNode.view.frame.size;
[viewNode blend:subModel[@"props"]];
[viewNode.view.doricLayout apply:CGSizeMake(self.view.width, self.view.height)];
[viewNode requestLayout];
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
skipReload = YES;
}
} else {
NSMutableDictionary *model = [[self subModelOf:viewId] mutableCopy];
[self recursiveMixin:subModel to:model];
[self setSubModel:model in:viewId];
}
if (skipReload) {
return;
}
[self.itemViewIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *_Nonnull key, NSString *_Nonnull obj, BOOL *_Nonnull stop) {
if ([viewId isEqualToString:obj]) {
*stop = YES;