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