From 93ecb7b3156c4e097e9032c97f18c53f88123723 Mon Sep 17 00:00:00 2001 From: vakrilov Date: Wed, 15 Jan 2020 16:06:55 +0200 Subject: [PATCH 1/3] fix(ios): ActionBar style wrong after cancelled swipe back navigation --- nativescript-core/ui/page/page.ios.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nativescript-core/ui/page/page.ios.ts b/nativescript-core/ui/page/page.ios.ts index 38c8224706..bfb1559d11 100644 --- a/nativescript-core/ui/page/page.ios.ts +++ b/nativescript-core/ui/page/page.ios.ts @@ -93,6 +93,7 @@ class UIViewControllerImpl extends UIViewController { return; } + // console.log("---> viewWillAppear", owner); const frame = this.navigationController ? (this.navigationController).owner : null; const newEntry = this[ENTRY]; @@ -124,6 +125,9 @@ class UIViewControllerImpl extends UIViewController { // Pages in backstack are unloaded so raise loaded here. if (!owner.isLoaded) { owner.callLoaded(); + } else { + // console.log(" ------> MANUAL UPDATE!") + owner.actionBar.update(); } } @@ -136,6 +140,7 @@ class UIViewControllerImpl extends UIViewController { return; } + // console.log("---> viewDidAppear", owner); const navigationController = this.navigationController; const frame: Frame = navigationController ? (navigationController).owner : null; // Skip navigation events if modal page is shown. @@ -192,7 +197,8 @@ class UIViewControllerImpl extends UIViewController { if (!owner) { return; } - + + console.log("---> viewWillDisappear", owner); // Cache presentedViewController if any. We don't want to raise // navigation events in case of presenting view controller. if (!owner._presentedViewController) { @@ -223,7 +229,8 @@ class UIViewControllerImpl extends UIViewController { if (!page || page.modal || page._presentedViewController) { return; } - + + console.log("---> viewDidDisappear", page); // Forward navigation does not remove page from frame so we raise unloaded manually. if (page.isLoaded) { page.callUnloaded(); @@ -343,6 +350,7 @@ export class Page extends PageBase { } public onLoaded(): void { + // console.log(this, " onLoaded"); super.onLoaded(); if (this.hasActionBar) { this.actionBar.update(); From ae5c179135c2e089abeda35fcfab36e05c2946f4 Mon Sep 17 00:00:00 2001 From: vakrilov Date: Wed, 15 Jan 2020 22:41:06 +0200 Subject: [PATCH 2/3] chore: cleanup --- nativescript-core/ui/page/page.ios.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nativescript-core/ui/page/page.ios.ts b/nativescript-core/ui/page/page.ios.ts index bfb1559d11..d4924b10ea 100644 --- a/nativescript-core/ui/page/page.ios.ts +++ b/nativescript-core/ui/page/page.ios.ts @@ -93,7 +93,6 @@ class UIViewControllerImpl extends UIViewController { return; } - // console.log("---> viewWillAppear", owner); const frame = this.navigationController ? (this.navigationController).owner : null; const newEntry = this[ENTRY]; @@ -126,7 +125,11 @@ class UIViewControllerImpl extends UIViewController { if (!owner.isLoaded) { owner.callLoaded(); } else { - // console.log(" ------> MANUAL UPDATE!") + // Note: Handle the case of canceled backstack navigation. (https://github.com/NativeScript/NativeScript/issues/7430) + // In this case viewWillAppear will be executed for the previous page and it will change the ActionBar + // because changes happen in an interactive transition - IOS will animate between the the states. + // If canceled - viewWillAppear will be called for the current page(which is already loaded) and we need to + // update the action bar explicitly, so that it is not left styles as the previous page. owner.actionBar.update(); } } @@ -140,7 +143,6 @@ class UIViewControllerImpl extends UIViewController { return; } - // console.log("---> viewDidAppear", owner); const navigationController = this.navigationController; const frame: Frame = navigationController ? (navigationController).owner : null; // Skip navigation events if modal page is shown. @@ -198,7 +200,6 @@ class UIViewControllerImpl extends UIViewController { return; } - console.log("---> viewWillDisappear", owner); // Cache presentedViewController if any. We don't want to raise // navigation events in case of presenting view controller. if (!owner._presentedViewController) { @@ -230,7 +231,6 @@ class UIViewControllerImpl extends UIViewController { return; } - console.log("---> viewDidDisappear", page); // Forward navigation does not remove page from frame so we raise unloaded manually. if (page.isLoaded) { page.callUnloaded(); From fff3f9c4e3d15a910781399c3e81b08d22caace4 Mon Sep 17 00:00:00 2001 From: Vasil Trifonov Date: Thu, 16 Jan 2020 09:50:32 +0200 Subject: [PATCH 3/3] remove unneeded console.log --- nativescript-core/ui/page/page.ios.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/nativescript-core/ui/page/page.ios.ts b/nativescript-core/ui/page/page.ios.ts index d4924b10ea..f921b8967a 100644 --- a/nativescript-core/ui/page/page.ios.ts +++ b/nativescript-core/ui/page/page.ios.ts @@ -350,7 +350,6 @@ export class Page extends PageBase { } public onLoaded(): void { - // console.log(this, " onLoaded"); super.onLoaded(); if (this.hasActionBar) { this.actionBar.update();