mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor: wrap layout safe area support
This commit is contained in:
committed by
Martin Yankov
parent
3414f3660e
commit
2a9d1acb6f
@@ -130,12 +130,15 @@ export class WrapLayout extends WrapLayoutBase {
|
||||
|
||||
let childLeft = paddingLeft;
|
||||
let childTop = paddingTop;
|
||||
let childrenLength: number;
|
||||
|
||||
let childrenWidth: number;
|
||||
let childrenHeight: number;
|
||||
if (isVertical) {
|
||||
childrenLength = bottom - top - paddingBottom;
|
||||
}
|
||||
else {
|
||||
childrenLength = right - left - paddingRight;
|
||||
childrenHeight = right - left - paddingRight;
|
||||
childrenWidth = bottom - top - paddingBottom;
|
||||
} else {
|
||||
childrenHeight = bottom - top - paddingBottom;
|
||||
childrenWidth = right - left - paddingRight;
|
||||
}
|
||||
|
||||
var rowOrColumn = 0;
|
||||
@@ -150,7 +153,7 @@ export class WrapLayout extends WrapLayoutBase {
|
||||
childWidth = length;
|
||||
childHeight = this.effectiveItemHeight > 0 ? this.effectiveItemHeight : childHeight;
|
||||
let isFirst = childTop === paddingTop;
|
||||
if (childTop + childHeight > childrenLength) {
|
||||
if (childTop + childHeight > childrenWidth && childLeft + childWidth <= childrenHeight) {
|
||||
// Move to top.
|
||||
childTop = paddingTop;
|
||||
|
||||
@@ -165,12 +168,19 @@ export class WrapLayout extends WrapLayoutBase {
|
||||
// Take respective column width.
|
||||
childWidth = this._lengths[isFirst ? rowOrColumn - 1 : rowOrColumn];
|
||||
}
|
||||
|
||||
if (childLeft < childrenHeight && childTop < childrenWidth) {
|
||||
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight);
|
||||
}
|
||||
else {
|
||||
|
||||
// Move next child Left position to right.
|
||||
childTop += childHeight;
|
||||
} else {
|
||||
childWidth = this.effectiveItemWidth > 0 ? this.effectiveItemWidth : childWidth;
|
||||
childHeight = length;
|
||||
let isFirst = childLeft === paddingLeft;
|
||||
if (childLeft + childWidth > childrenLength) {
|
||||
|
||||
if (childLeft + childWidth > childrenWidth && childTop + childHeight <= childrenHeight) {
|
||||
// Move to left.
|
||||
childLeft = paddingLeft;
|
||||
|
||||
@@ -185,15 +195,11 @@ export class WrapLayout extends WrapLayoutBase {
|
||||
// Take respective row height.
|
||||
childHeight = this._lengths[isFirst ? rowOrColumn - 1 : rowOrColumn];
|
||||
}
|
||||
}
|
||||
|
||||
if (childLeft < childrenWidth && childTop < childrenHeight) {
|
||||
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight);
|
||||
|
||||
if (isVertical) {
|
||||
// Move next child Top position to bottom.
|
||||
childTop += childHeight;
|
||||
}
|
||||
else {
|
||||
|
||||
// Move next child Left position to right.
|
||||
childLeft += childWidth;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user