diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts index 993bbf33a..571c7632e 100644 --- a/tns-core-modules/ui/core/view/view-common.ts +++ b/tns-core-modules/ui/core/view/view-common.ts @@ -641,7 +641,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { } public abstract onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void; - public abstract onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void; + public abstract onLayout(left: number, top: number, right: number, bottom: number, insets?: {left, top, right, bottom}): void; public abstract layoutNativeView(left: number, top: number, right: number, bottom: number): void; public static resolveSizeAndState(size: number, specSize: number, specMode: number, childMeasuredState: number): number { diff --git a/tns-core-modules/ui/core/view/view.d.ts b/tns-core-modules/ui/core/view/view.d.ts index 4af2b049b..bbc004b47 100644 --- a/tns-core-modules/ui/core/view/view.d.ts +++ b/tns-core-modules/ui/core/view/view.d.ts @@ -404,7 +404,7 @@ export abstract class View extends ViewBase { * @param right Right position, relative to parent * @param bottom Bottom position, relative to parent */ - public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void; + public onLayout(left: number, top: number, right: number, bottom: number, insets?: {left, top, right, bottom}): void; /** * This method must be called by onMeasure(int, int) to store the measured width and measured height. Failing to do so will trigger an exception at measurement time. diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts index a6be82332..0c0c6cae8 100644 --- a/tns-core-modules/ui/core/view/view.ios.ts +++ b/tns-core-modules/ui/core/view/view.ios.ts @@ -92,16 +92,16 @@ export class View extends ViewCommon { } if (boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED) { - let insetLeft = 0; - let insetTop = 0; + let insets = { left: 0, top: 0, right: 0, bottom: 0}; if (this.nativeViewProtected.safeAreaInsets) { - insetLeft = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.left); - insetTop = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.top); + insets.left = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.left); + insets.top = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.top); + insets.right = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.right); + insets.bottom = layout.toDevicePixels(this.nativeViewProtected.safeAreaInsets.bottom); } - // this.onLayout(actualPosition.left, actualPosition.top, actualPosition.right, actualPosition.bottom, insetLeft, insetTop, insetRight, insetBottom); - this.onLayout(actualPosition.left, actualPosition.top, actualPosition.right, actualPosition.bottom, insetLeft, insetTop); + this.onLayout(actualPosition.left, actualPosition.top, actualPosition.right, actualPosition.bottom, insets); this._privateFlags &= ~PFLAG_LAYOUT_REQUIRED; } @@ -149,7 +149,7 @@ export class View extends ViewCommon { this.setMeasuredDimension(widthAndState, heightAndState); } - public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number, insetRight?: number, insetBottom?: number): void { + public onLayout(left: number, top: number, right: number, bottom: number, insets?: {left, top, right, bottom}): void { // } diff --git a/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts b/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts index 10ea92980..cbf91902c 100644 --- a/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts +++ b/tns-core-modules/ui/layouts/grid-layout/grid-layout.ios.ts @@ -156,11 +156,11 @@ export class GridLayout extends GridLayoutBase { this.setMeasuredDimension(widthSizeAndState, heightSizeAndState); } - public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void { + public onLayout(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void { super.onLayout(left, top, right, bottom); - let paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insetLeft; - let paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insetTop; + let paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insets.left; + let paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insets.top; this.columnOffsets.length = 0; this.rowOffsets.length = 0; diff --git a/tns-core-modules/ui/layouts/layout-base.ios.ts b/tns-core-modules/ui/layouts/layout-base.ios.ts index 9511c94cd..6dde49389 100644 --- a/tns-core-modules/ui/layouts/layout-base.ios.ts +++ b/tns-core-modules/ui/layouts/layout-base.ios.ts @@ -75,11 +75,12 @@ export class LayoutBase extends LayoutBaseCommon { newHeight = height + onScreenTop; } - if (onScreenLeft + width >= layout.toDevicePixels(safeArea.origin.x) + layout.toDevicePixels(safeArea.size.width)) { + if (width && onScreenLeft + width >= layout.toDevicePixels(safeArea.origin.x) + layout.toDevicePixels(safeArea.size.width)) { newWidth = newWidth + (layout.toDevicePixels(fullscreen.size.width) - (onScreenLeft + width)); } - if (onScreenTop + height >= layout.toDevicePixels(safeArea.origin.y) + layout.toDevicePixels(safeArea.size.height)) { + if (height && onScreenTop + height >= layout.toDevicePixels(safeArea.origin.y) + layout.toDevicePixels(safeArea.size.height)) { + // console.log(">>>>>>>> Bottom Layout: onScreenTop - " + onScreenTop + " height - " + height + " safeAreaOriginY - " + layout.toDevicePixels(safeArea.origin.y) + " safeAreaHeight - " + layout.toDevicePixels(safeArea.size.height)); newHeight = newHeight + (layout.toDevicePixels(fullscreen.size.height) - (onScreenTop + height)); } diff --git a/tns-core-modules/ui/layouts/stack-layout/stack-layout.ios.ts b/tns-core-modules/ui/layouts/stack-layout/stack-layout.ios.ts index 712ad25c0..b8c672f52 100644 --- a/tns-core-modules/ui/layouts/stack-layout/stack-layout.ios.ts +++ b/tns-core-modules/ui/layouts/stack-layout/stack-layout.ios.ts @@ -81,21 +81,21 @@ export class StackLayout extends StackLayoutBase { this.setMeasuredDimension(widthAndState, heightAndState); } - public onLayout(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void { + public onLayout(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void { super.onLayout(left, top, right, bottom); if (this.orientation === "vertical") { - this.layoutVertical(left, top, right, bottom, insetLeft, insetTop); + this.layoutVertical(left, top, right, bottom, insets); } else { - this.layoutHorizontal(left, top, right, bottom); + this.layoutHorizontal(left, top, right, bottom, insets); } } - private layoutVertical(left: number, top: number, right: number, bottom: number, insetLeft?: number, insetTop?: number): void { - const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insetLeft; - const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insetTop; - const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight; - const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom; + private layoutVertical(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void { + const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insets.left; + const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insets.top; + const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight + insets.right; + const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom + insets.bottom; let childTop: number; let childLeft: number = paddingLeft; @@ -126,11 +126,11 @@ export class StackLayout extends StackLayoutBase { }) } - private layoutHorizontal(left: number, top: number, right: number, bottom: number): void { - const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft; - const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop; - const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight; - const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom; + private layoutHorizontal(left: number, top: number, right: number, bottom: number, insets: {left, top, right, bottom}): void { + const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + insets.left; + const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + insets.top; + const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight + insets.right; + const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom + insets.bottom; let childTop: number = paddingTop; let childLeft: number;