iOS: fix case when parent is fit,child is most, align to android

This commit is contained in:
pengfei.zhou
2021-05-07 18:11:54 +08:00
committed by osborn
parent f43406dc4a
commit d8412f3a96
2 changed files with 54 additions and 13 deletions

View File

@@ -120,7 +120,9 @@ - (void)measureSelf:(CGSize)targetSize {
CGFloat width;
CGFloat height;
if (self.widthSpec == DoricLayoutMost) {
if (self.view.superview.doricLayout.layoutType == DoricHLayout && self.weight > 0) {
if (self.view.superview.doricLayout.widthSpec == DoricLayoutFit) {
width = targetSize.width;
} else if (self.view.superview.doricLayout.layoutType == DoricHLayout && self.weight > 0) {
width = self.measuredWidth = 0;
} else {
width = self.measuredWidth = targetSize.width;
@@ -193,11 +195,13 @@ - (void)measureContent:(CGSize)targetSize {
break;
}
}
if (self.view.superview.doricLayout.layoutType != DoricUndefined && self.view.superview.doricLayout.widthSpec == DoricLayoutFit && self.widthSpec == DoricLayoutMost) {
self.measuredWidth = targetSize.width;
if (self.view.superview.doricLayout.widthSpec == DoricLayoutFit && self.widthSpec == DoricLayoutMost) {
self.measuredWidth = self.contentWidth + self.paddingLeft + self.paddingRight;
}
if (self.view.superview.doricLayout.layoutType != DoricUndefined && self.view.superview.doricLayout.heightSpec == DoricLayoutFit && self.heightSpec == DoricLayoutMost) {
self.measuredHeight = targetSize.height;
if (self.view.superview.doricLayout.heightSpec == DoricLayoutFit && self.heightSpec == DoricLayoutMost) {
self.measuredHeight = self.contentHeight + self.paddingTop + self.paddingBottom;
}
}
@@ -494,9 +498,6 @@ - (void)layoutVLayout {
if (self.widthSpec == DoricLayoutFit && layout.widthSpec == DoricLayoutMost) {
layout.measuredWidth = self.measuredWidth - layout.marginLeft - layout.marginRight;
}
if (self.heightSpec == DoricLayoutFit && layout.heightSpec == DoricLayoutMost) {
layout.measuredHeight = self.measuredHeight - yStart - layout.marginTop - layout.marginBottom;
}
[layout layout];
DoricGravity gravity = layout.alignment | self.gravity;
if ((gravity & DoricGravityLeft) == DoricGravityLeft) {
@@ -537,10 +538,6 @@ - (void)layoutHLayout {
continue;
}
if (self.widthSpec == DoricLayoutFit && layout.widthSpec == DoricLayoutMost) {
layout.measuredWidth = self.measuredWidth - xStart - layout.marginLeft - layout.marginRight;
}
if (self.heightSpec == DoricLayoutFit && layout.heightSpec == DoricLayoutMost) {
layout.measuredHeight = self.measuredHeight - layout.marginTop - layout.marginBottom;
}