iOS: fix when reuse flexnode, its childNode cannot measure properly
This commit is contained in:
parent
59bb3a049d
commit
563f1a7fe1
@ -31,17 +31,16 @@ - (CGSize)sizeThatFits:(CGSize)size {
|
|||||||
[view.doricLayout measure:size];
|
[view.doricLayout measure:size];
|
||||||
[view configureLayoutWithBlock:^(YGLayout *layout) {
|
[view configureLayoutWithBlock:^(YGLayout *layout) {
|
||||||
layout.isEnabled = YES;
|
layout.isEnabled = YES;
|
||||||
|
if (view.doricLayout.undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (layout.width.unit == YGUnitUndefined
|
if (layout.width.unit == YGUnitUndefined
|
||||||
|| layout.width.unit == YGUnitAuto) {
|
|| layout.width.unit == YGUnitAuto) {
|
||||||
if (!view.doricLayout.undefined) {
|
layout.width = YGPointValue(view.doricLayout.measuredWidth);
|
||||||
layout.width = YGPointValue(view.doricLayout.measuredWidth);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (layout.height.unit == YGUnitUndefined
|
if (layout.height.unit == YGUnitUndefined
|
||||||
|| layout.height.unit == YGUnitAuto) {
|
|| layout.height.unit == YGUnitAuto) {
|
||||||
if (!view.doricLayout.undefined) {
|
layout.height = YGPointValue(view.doricLayout.measuredHeight);
|
||||||
layout.height = YGPointValue(view.doricLayout.measuredHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -70,11 +69,26 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)afterBlended:(NSDictionary *)props {
|
||||||
|
[super afterBlended:props];
|
||||||
|
[self.childNodes forEach:^(DoricViewNode *viewNode) {
|
||||||
|
NSString *viewId = viewNode.viewId;
|
||||||
|
NSDictionary *model = [self subModelOf:viewId];
|
||||||
|
NSDictionary *dictionary = model[@"dictionary"];
|
||||||
|
if (!dictionary[@"flexConfig"]) {
|
||||||
|
viewNode.view.yoga.width = YGValueAuto;
|
||||||
|
viewNode.view.yoga.height = YGValueAuto;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)blendSubNode:(DoricViewNode *)subNode flexConfig:(NSDictionary *)flexConfig {
|
- (void)blendSubNode:(DoricViewNode *)subNode flexConfig:(NSDictionary *)flexConfig {
|
||||||
[subNode.view configureLayoutWithBlock:^(YGLayout *_Nonnull layout) {
|
[subNode.view configureLayoutWithBlock:^(YGLayout *_Nonnull layout) {
|
||||||
layout.isEnabled = YES;
|
layout.isEnabled = YES;
|
||||||
}];
|
}];
|
||||||
subNode.view.doricLayout.disabled = YES;
|
subNode.view.doricLayout.disabled = YES;
|
||||||
|
subNode.view.yoga.width = YGValueAuto;
|
||||||
|
subNode.view.yoga.height = YGValueAuto;
|
||||||
[self blendYoga:subNode.view.yoga from:flexConfig];
|
[self blendYoga:subNode.view.yoga from:flexConfig];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user