iOS: fix when Image async load cause super node requestLayout

This commit is contained in:
pengfei.zhou 2021-11-12 16:23:01 +08:00 committed by osborn
parent af77a0e98e
commit 4c80e5aa60
6 changed files with 42 additions and 16 deletions

View File

@ -540,4 +540,9 @@ - (void)reset {
self.onScrollEndFuncId = nil;
self.loadMore = NO;
}
- (void)subNodeContentChanged:(DoricViewNode *)subNode {
[subNode.view.doricLayout apply];
[super subNodeContentChanged:subNode];
}
@end

View File

@ -252,11 +252,9 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
UIImage *image = [UIImage imageWithData:imageData scale:self.imageScale];
#endif
view.image = image;
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
if (self.needReload) {
[self.superNode subNodeContentChanged:self];
}
[node requestLayout];
if (self.loadCallbackId.length > 0) {
if (image) {
[self callJSResponse:self.loadCallbackId,
@ -326,12 +324,8 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
},
nil];
}
if (async) {
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
if (async && self.needReload) {
[self.superNode subNodeContentChanged:self];
}
}
}];
@ -368,12 +362,8 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
},
nil];
}
if (async) {
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
if (async && self.needReload) {
[self.superNode subNodeContentChanged:self];
}
}
}];
@ -644,4 +634,15 @@ - (void)reset {
self.blurEffectView = nil;
self.view.contentMode = UIViewContentModeScaleAspectFill;
}
- (BOOL)needReload {
if (self.view.doricLayout.widthSpec == DoricLayoutFit
|| self.view.doricLayout.heightSpec == DoricLayoutFit) {
CGSize size = [self.view sizeThatFits:self.view.bounds.size];
if (!CGSizeEqualToSize(size, self.view.bounds.size)) {
return YES;
}
}
return NO;
}
@end

View File

@ -488,4 +488,8 @@ - (void)reset {
self.loadMore = NO;
}
- (void)subNodeContentChanged:(DoricViewNode *)subNode {
[subNode.view.doricLayout apply];
[super subNodeContentChanged:subNode];
}
@end

View File

@ -314,4 +314,9 @@ - (void)reset {
self.propRenderPageFuncId = nil;
self.renderPageFuncId = nil;
}
- (void)subNodeContentChanged:(DoricViewNode *)subNode {
[subNode.view.doricLayout apply];
[super subNodeContentChanged:subNode];
}
@end

View File

@ -40,4 +40,6 @@
- (void)recursiveMixin:(NSDictionary *)srcModel to:(NSMutableDictionary *)targetModel;
- (NSArray *)getSubNodeViewIds;
- (void)subNodeContentChanged:(DoricViewNode *)subNode;
@end

View File

@ -152,6 +152,15 @@ - (void)reset {
for (NSString *viewId in self.subNodes.allKeys) {
[[self subNodeWithViewId:viewId] reset];
}
}
- (void)subNodeContentChanged:(DoricViewNode *)subNode {
if (self.superNode
&& (self.view.doricLayout.widthSpec == DoricLayoutFit
|| self.view.doricLayout.heightSpec == DoricLayoutFit)) {
[self.superNode subNodeContentChanged:self];
} else {
[self requestLayout];
}
}
@end