iOS:Fix nested use of FlexLayout
This commit is contained in:
parent
d29ff4991d
commit
5a8a855f89
@ -28,14 +28,16 @@ @interface DoricFlexView : UIView
|
||||
@implementation DoricFlexView
|
||||
- (CGSize)sizeThatFits:(CGSize)size {
|
||||
for (UIView *view in self.subviews) {
|
||||
if (!view.doricLayout.disabled) {
|
||||
[view.doricLayout apply];
|
||||
[view.doricLayout measure:size];
|
||||
[view configureLayoutWithBlock:^(YGLayout *layout) {
|
||||
layout.isEnabled = YES;
|
||||
if (layout.width.unit == YGUnitUndefined || layout.width.unit == YGUnitAuto) {
|
||||
layout.width = YGPointValue(view.doricLayout.measuredWidth);
|
||||
layout.height = YGPointValue(view.doricLayout.measuredHeight);
|
||||
}];
|
||||
}
|
||||
if (layout.height.unit == YGUnitUndefined || layout.height.unit == YGUnitAuto) {
|
||||
layout.height = YGPointValue(view.doricLayout.measuredHeight);
|
||||
}
|
||||
}];
|
||||
}
|
||||
return [self.yoga intrinsicSize];
|
||||
}
|
||||
@ -205,8 +207,6 @@ - (YGValue)translateYGValueFromProperty:(id)prop {
|
||||
}
|
||||
|
||||
- (void)requestLayout {
|
||||
[super requestLayout];
|
||||
|
||||
if (self.view.doricLayout.widthSpec != DoricLayoutFit) {
|
||||
self.view.yoga.width = YGPointValue(self.view.width);
|
||||
}
|
||||
@ -230,5 +230,6 @@ - (void)requestLayout {
|
||||
view.doricLayout.measuredY = view.top;
|
||||
[view.doricLayout apply];
|
||||
}
|
||||
[super requestLayout];
|
||||
}
|
||||
@end
|
||||
|
@ -103,6 +103,8 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
- (void)measure:(CGSize)targetSize;
|
||||
|
||||
- (void)apply;
|
||||
|
||||
- (void)apply:(CGSize)frameSize;
|
||||
|
@ -66,7 +66,6 @@ - (instancetype)init {
|
||||
- (void)apply:(CGSize)frameSize {
|
||||
self.resolved = NO;
|
||||
[self measure:frameSize];
|
||||
[self layout];
|
||||
[self setFrame];
|
||||
self.resolved = YES;
|
||||
}
|
||||
@ -76,6 +75,11 @@ - (void)apply {
|
||||
}
|
||||
|
||||
- (void)measure:(CGSize)targetSize {
|
||||
[self measureSelf:targetSize];
|
||||
[self layout];
|
||||
}
|
||||
|
||||
- (void)measureSelf:(CGSize)targetSize {
|
||||
CGFloat width;
|
||||
CGFloat height;
|
||||
if (self.widthSpec == DoricLayoutMost) {
|
||||
|
Reference in New Issue
Block a user