From 70f01123df3067dae764f56ee1489f2c23c9948c Mon Sep 17 00:00:00 2001 From: Alexander Djenkov Date: Mon, 2 Apr 2018 22:27:44 +0300 Subject: [PATCH] feat(frame): handle back navigation when common layout is used as a root element (#5608) * test(e2e): update modal navigation app Add layout as root. Add show modal layout. * chore(frame): move frame stack modifiers in a separate frame-stack module * feat(frame): handle back navigation when using common layout as root element --- e2e/modal-navigation/app/app.ts | 1 + e2e/modal-navigation/app/home/home-page.ts | 21 ++++++-- e2e/modal-navigation/app/home/home-page.xml | 5 +- e2e/modal-navigation/app/layout-root.xml | 3 ++ .../app/modal-layout/modal-layout.ts | 23 +++++++++ .../app/modal-layout/modal-layout.xml | 7 +++ e2e/modal-navigation/e2e/screen.ts | 22 ++++++-- tns-core-modules/ui/core/view/view-common.ts | 14 +++++- tns-core-modules/ui/core/view/view.android.ts | 13 +++++ tns-core-modules/ui/core/view/view.d.ts | 9 +++- tns-core-modules/ui/frame/frame-common.ts | 41 ++------------- tns-core-modules/ui/frame/frame-stack.ts | 50 +++++++++++++++++++ 12 files changed, 161 insertions(+), 48 deletions(-) create mode 100644 e2e/modal-navigation/app/layout-root.xml create mode 100644 e2e/modal-navigation/app/modal-layout/modal-layout.ts create mode 100644 e2e/modal-navigation/app/modal-layout/modal-layout.xml create mode 100644 tns-core-modules/ui/frame/frame-stack.ts diff --git a/e2e/modal-navigation/app/app.ts b/e2e/modal-navigation/app/app.ts index 88113cfe5..ae7b39686 100644 --- a/e2e/modal-navigation/app/app.ts +++ b/e2e/modal-navigation/app/app.ts @@ -3,3 +3,4 @@ import * as application from "tns-core-modules/application"; application.run({ moduleName: "app-root" }); // application.run({ moduleName: "tab-root" }); +// application.run({ moduleName: "layout-root" }); diff --git a/e2e/modal-navigation/app/home/home-page.ts b/e2e/modal-navigation/app/home/home-page.ts index 684ec48bd..3a0b9a9af 100644 --- a/e2e/modal-navigation/app/home/home-page.ts +++ b/e2e/modal-navigation/app/home/home-page.ts @@ -41,6 +41,14 @@ export function onModalPage(args: EventData) { false); } +export function onModalLayout(args: EventData) { + const view = args.object as View; + view.showModal("modal-layout/modal-layout", + "context", + () => console.log("home-page modal layout closed"), + false); +} + export function onModalTabView(args: EventData) { const fullscreen = false; const animated = false; @@ -61,7 +69,14 @@ export function onNavigate(args: EventData) { page.frame.navigate("second/second-page"); } -export function onRootViewChange() { - let rootView = application.getRootView(); - rootView instanceof Frame ? application._resetRootView({ moduleName: "tab-root" }) : application._resetRootView({ moduleName: "app-root" }); +export function onFrameRootViewReset() { + application._resetRootView({ moduleName: "app-root" }); } + +export function onTabRootViewReset() { + application._resetRootView({ moduleName: "tab-root" }); +} + +export function onLayoutRootViewReset() { + application._resetRootView({ moduleName: "layout-root" }); +} \ No newline at end of file diff --git a/e2e/modal-navigation/app/home/home-page.xml b/e2e/modal-navigation/app/home/home-page.xml index a34618a34..805df0ab5 100644 --- a/e2e/modal-navigation/app/home/home-page.xml +++ b/e2e/modal-navigation/app/home/home-page.xml @@ -12,8 +12,11 @@