From bf070f105d3922bfa2bb231845bc3cdd991dfc9b Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Tue, 28 Aug 2018 15:31:20 +0300 Subject: [PATCH] refactor: update safe area traces --- e2e/safe-area/app/app.ts | 4 ++++ tns-core-modules/ui/core/view/view.ios.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/e2e/safe-area/app/app.ts b/e2e/safe-area/app/app.ts index 0c5afc47e..2afbff2ed 100644 --- a/e2e/safe-area/app/app.ts +++ b/e2e/safe-area/app/app.ts @@ -1,3 +1,7 @@ import * as application from "tns-core-modules/application"; +import * as trace from "tns-core-modules/trace"; + +trace.setCategories(trace.categories.Layout); +trace.enable(); application.run({ moduleName: "app-root" }); diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts index be4f595b7..1d38cc728 100644 --- a/tns-core-modules/ui/core/view/view.ios.ts +++ b/tns-core-modules/ui/core/view/view.ios.ts @@ -156,7 +156,7 @@ export class View extends ViewCommon { public _setNativeViewFrame(nativeView: UIView, frame: CGRect): void { if (!CGRectEqualToRect(nativeView.frame, frame)) { if (traceEnabled()) { - traceWrite(this + ", Native setFrame: = " + NSStringFromCGRect(frame), traceCategories.Layout); + traceWrite(this + " :_setNativeViewFrame: " + JSON.stringify(ios.getPositionFromFrame(frame)), traceCategories.Layout); } this._cachedFrame = frame; if (this._hasTransfrom) { @@ -231,6 +231,11 @@ export class View extends ViewCommon { if (insets.left || insets.top) { const position = ios.getPositionFromFrame(frame); const adjustedFrame = ios.getFrameFromPosition(position, insets); + + if (traceEnabled()) { + traceWrite(this + " :applySafeAreaInsets: " + JSON.stringify(ios.getPositionFromFrame(adjustedFrame)), traceCategories.Layout); + } + return adjustedFrame; } } else if (this.nativeViewProtected && this.nativeViewProtected.window) { @@ -261,6 +266,11 @@ export class View extends ViewCommon { } const adjustedFrame = CGRectMake(layout.toDeviceIndependentPixels(adjustedPosition.left), layout.toDeviceIndependentPixels(adjustedPosition.top), layout.toDeviceIndependentPixels(adjustedPosition.right - adjustedPosition.left), layout.toDeviceIndependentPixels(adjustedPosition.bottom - adjustedPosition.top)); + + if (traceEnabled()) { + traceWrite(this + " :applySafeAreaInsets: " + JSON.stringify(ios.getPositionFromFrame(adjustedFrame)), traceCategories.Layout); + } + return adjustedFrame; }