From 3f578741f7d93ea1a2bb7082b0c1d0f1816b8970 Mon Sep 17 00:00:00 2001 From: Tsvetan Raikov Date: Mon, 14 Nov 2016 18:34:26 +0200 Subject: [PATCH] Fixed: ActionBar w/translucent navigationBar set to false is creating whitish transition --- tns-core-modules/ui/frame/frame.ios.ts | 10 ++++++++++ tns-core-modules/ui/page/page.ios.ts | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tns-core-modules/ui/frame/frame.ios.ts b/tns-core-modules/ui/frame/frame.ios.ts index ae381b84b..b1475b6ed 100644 --- a/tns-core-modules/ui/frame/frame.ios.ts +++ b/tns-core-modules/ui/frame/frame.ios.ts @@ -195,7 +195,11 @@ export class Frame extends frameCommon.Frame { page = page || this.currentPage; let newValue = this._getNavBarVisible(page); + var disableNavBarAnimation = this._ios._disableNavBarAnimation; + this._ios._disableNavBarAnimation = true; this._ios.showNavigationBar = newValue; + this._ios._disableNavBarAnimation = disableNavBarAnimation; + if (this._ios.controller.navigationBar) { this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty(); } @@ -314,6 +318,12 @@ export class Frame extends frameCommon.Frame { // If background does not span under statusbar - reduce available height and adjust top offset. let statusBarHeight = (page && !page.backgroundSpanUnderStatusBar && !this.parent) ? uiUtils.ios.getStatusBarHeight() : 0; + // Status bar height should be ignored when UINavigationBar is visible and not translucent + if (this._ios.showNavigationBar && + !this._ios.controller.navigationBar.translucent && + page && (page)._ios && !(page)._ios.shown) { + statusBarHeight = 0; + } View.layoutChild(this, page, 0, statusBarHeight, this._right, this._bottom); } diff --git a/tns-core-modules/ui/page/page.ios.ts b/tns-core-modules/ui/page/page.ios.ts index 8d7de4bde..6e1ec72c2 100644 --- a/tns-core-modules/ui/page/page.ios.ts +++ b/tns-core-modules/ui/page/page.ios.ts @@ -57,11 +57,13 @@ class UIViewControllerImpl extends UIViewController { public isBackstackSkipped: boolean; public isBackstackCleared: boolean; + public shown: boolean; public static initWithOwner(owner: WeakRef): UIViewControllerImpl { let controller = UIViewControllerImpl.new(); controller._owner = owner; controller.automaticallyAdjustsScrollViewInsets = false; + controller.shown = false; return controller; } @@ -140,6 +142,7 @@ class UIViewControllerImpl extends UIViewController { public viewWillAppear(animated: boolean): void { super.viewWillAppear(animated); + this.shown = false; let page = this._owner.get(); if (trace.enabled) { if (trace.enabled) { @@ -191,6 +194,7 @@ class UIViewControllerImpl extends UIViewController { public viewDidAppear(animated: boolean): void { super.viewDidAppear(animated); + this.shown = true; let page = this._owner.get(); if (trace.enabled) { trace.write(page + " viewDidAppear", trace.categories.Navigation); @@ -320,7 +324,7 @@ class UIViewControllerImpl extends UIViewController { } export class Page extends pageCommon.Page { - private _ios: UIViewController = UIViewControllerImpl.initWithOwner(new WeakRef(this)); + private _ios: UIViewControllerImpl = UIViewControllerImpl.initWithOwner(new WeakRef(this)); public _enableLoadedEvents: boolean; public _modalParent: Page; public _UIModalPresentationFormSheet: boolean; @@ -499,6 +503,14 @@ export class Page extends pageCommon.Page { navigationBarHeight = this.actionBar.getMeasuredHeight(); } + // Navigation bar height should be ignored when it is visible and not translucent + if (this.frame && this.frame.ios && + this.frame.ios.controller.navigationBar && + !this.frame.ios.controller.navigationBar.translucent && + !this._ios.shown) { + navigationBarHeight = 0; + } + let statusBarHeight = this.backgroundSpanUnderStatusBar ? uiUtils.ios.getStatusBarHeight() : 0; // If this page is inside nested frame - don't substract statusBarHeight again.