refactor: wrap layout safe area support

This commit is contained in:
Vasil Chimev
2018-07-27 04:42:12 +03:00
committed by Martin Yankov
parent 3414f3660e
commit 2a9d1acb6f

View File

@@ -130,12 +130,15 @@ export class WrapLayout extends WrapLayoutBase {
let childLeft = paddingLeft; let childLeft = paddingLeft;
let childTop = paddingTop; let childTop = paddingTop;
let childrenLength: number;
let childrenWidth: number;
let childrenHeight: number;
if (isVertical) { if (isVertical) {
childrenLength = bottom - top - paddingBottom; childrenHeight = right - left - paddingRight;
} childrenWidth = bottom - top - paddingBottom;
else { } else {
childrenLength = right - left - paddingRight; childrenHeight = bottom - top - paddingBottom;
childrenWidth = right - left - paddingRight;
} }
var rowOrColumn = 0; var rowOrColumn = 0;
@@ -150,7 +153,7 @@ export class WrapLayout extends WrapLayoutBase {
childWidth = length; childWidth = length;
childHeight = this.effectiveItemHeight > 0 ? this.effectiveItemHeight : childHeight; childHeight = this.effectiveItemHeight > 0 ? this.effectiveItemHeight : childHeight;
let isFirst = childTop === paddingTop; let isFirst = childTop === paddingTop;
if (childTop + childHeight > childrenLength) { if (childTop + childHeight > childrenWidth && childLeft + childWidth <= childrenHeight) {
// Move to top. // Move to top.
childTop = paddingTop; childTop = paddingTop;
@@ -165,12 +168,19 @@ export class WrapLayout extends WrapLayoutBase {
// Take respective column width. // Take respective column width.
childWidth = this._lengths[isFirst ? rowOrColumn - 1 : rowOrColumn]; 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; childWidth = this.effectiveItemWidth > 0 ? this.effectiveItemWidth : childWidth;
childHeight = length; childHeight = length;
let isFirst = childLeft === paddingLeft; let isFirst = childLeft === paddingLeft;
if (childLeft + childWidth > childrenLength) {
if (childLeft + childWidth > childrenWidth && childTop + childHeight <= childrenHeight) {
// Move to left. // Move to left.
childLeft = paddingLeft; childLeft = paddingLeft;
@@ -185,15 +195,11 @@ export class WrapLayout extends WrapLayoutBase {
// Take respective row height. // Take respective row height.
childHeight = this._lengths[isFirst ? rowOrColumn - 1 : rowOrColumn]; childHeight = this._lengths[isFirst ? rowOrColumn - 1 : rowOrColumn];
} }
}
if (childLeft < childrenWidth && childTop < childrenHeight) {
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childTop + childHeight); 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. // Move next child Left position to right.
childLeft += childWidth; childLeft += childWidth;
} }