From 5df6921635fc32d58eb0e003061d94cb849d90a7 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Wed, 26 Sep 2018 15:13:56 +0300 Subject: [PATCH] fix: move _getCurrentLayoutBounds from CustomLayoutView to View as extended by ListViewBase --- tests/app/ui/layouts/safe-area-tests.ts | 4 +-- tns-core-modules/ui/core/view/view-common.ts | 4 +-- tns-core-modules/ui/core/view/view.ios.ts | 36 ++++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/app/ui/layouts/safe-area-tests.ts b/tests/app/ui/layouts/safe-area-tests.ts index 499dd0da7..285f01be3 100644 --- a/tests/app/ui/layouts/safe-area-tests.ts +++ b/tests/app/ui/layouts/safe-area-tests.ts @@ -619,10 +619,10 @@ export class SafeAreaTests extends testModule.UITest { isAboveWith(cells[2][1], grid, insets.bottom); isAboveWith(cells[2][2], grid, insets.bottom); - equal(height(cells[0][1]), height(cells[1][1]), `cell height should be equal - cell01<${height(cells[0][1])}> - cell11<${height(cells[1][1])}>`); + closeEnough(height(cells[0][1]), height(cells[1][1]), `cell height should be equal - cell01<${height(cells[0][1])}> - cell11<${height(cells[1][1])}>`); equal(height(cells[1][1]), height(cells[2][1]), `cell height should be equal - cell11<${height(cells[1][1])}> - cell21<${height(cells[2][1])}>`); const sumOfLabelHeightAndInsets = insets.top + height(cells[0][1]) + height(cells[1][1]) + height(cells[2][1]) + insets.bottom; - equal(height(grid), sumOfLabelHeightAndInsets, `grid height<${height(grid)}> sum of labels height and insets<${sumOfLabelHeightAndInsets}>`); + closeEnough(height(grid), sumOfLabelHeightAndInsets, `grid height<${height(grid)}> sum of labels height and insets<${sumOfLabelHeightAndInsets}>`); equal(width(cells[1][0]), width(cells[1][1]), `cell width should be equal - cell10<${width(cells[1][0])}> - cell11<${width(cells[1][1])}>`); equal(width(cells[1][1]), width(cells[1][2]), `cell width should be equal - cell11<${width(cells[1][1])}> - cell12<${width(cells[1][2])}>`); diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts index c3a7d4b28..952944cf0 100644 --- a/tns-core-modules/ui/core/view/view-common.ts +++ b/tns-core-modules/ui/core/view/view-common.ts @@ -843,7 +843,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { } _getCurrentLayoutBounds(): { left: number; top: number; right: number; bottom: number } { - return { left: this._oldLeft, top: this._oldTop, right: this._oldRight, bottom: this._oldBottom }; + return { left: 0, top: 0, right: 0, bottom: 0 }; } /** @@ -881,7 +881,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { } public getSafeAreaInsets(): { left, top, right, bottom } { - return {left: 0, top: 0, right: 0, bottom: 0}; + return { left: 0, top: 0, right: 0, bottom: 0 }; } public getLocationInWindow(): Point { diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts index 51cb53387..fc0e6b27f 100644 --- a/tns-core-modules/ui/core/view/view.ios.ts +++ b/tns-core-modules/ui/core/view/view.ios.ts @@ -545,6 +545,23 @@ export class View extends ViewCommon { } } + _getCurrentLayoutBounds(): { left: number; top: number; right: number; bottom: number } { + const nativeView = this.nativeViewProtected; + if (nativeView && !this.isCollapsed) { + const frame = nativeView.frame; + const origin = frame.origin; + const size = frame.size; + return { + left: Math.round(layout.toDevicePixels(origin.x)), + top: Math.round(layout.toDevicePixels(origin.y)), + right: Math.round(layout.toDevicePixels(origin.x + size.width)), + bottom: Math.round(layout.toDevicePixels(origin.y + size.height)) + }; + } else { + return { left: 0, top: 0, right: 0, bottom: 0 }; + } + } + _redrawNativeBackground(value: UIColor | Background): void { let updateSuspended = this._isPresentationLayerUpdateSuspeneded(); if (!updateSuspended) { @@ -630,23 +647,6 @@ export class CustomLayoutView extends ContainerView { child.nativeViewProtected.removeFromSuperview(); } } - - _getCurrentLayoutBounds(): { left: number; top: number; right: number; bottom: number } { - const nativeView = this.nativeViewProtected; - if (nativeView && !this.isCollapsed) { - const frame = nativeView.frame; - const origin = frame.origin; - const size = frame.size; - return { - left: layout.toDevicePixels(origin.x), - top: layout.toDevicePixels(origin.y), - right: layout.toDevicePixels(origin.x + size.width), - bottom: layout.toDevicePixels(origin.y + size.height) - }; - } else { - return { left: 0, top: 0, right: 0, bottom: 0 }; - } - } } export namespace ios { @@ -845,7 +845,7 @@ export namespace ios { } } - return { safeArea: safeArea, fullscreen: fullscreen} + return { safeArea: safeArea, fullscreen: fullscreen } } export class UILayoutViewController extends UIViewController {