From 82f8afb5dd5379b43400e4c94f9c80d96b6c66cd Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Thu, 1 Dec 2022 15:04:31 +0900 Subject: [PATCH] [NUI] Modify the default action of back navigation Previously, back navigation only pops the peek page. However, in most cases, application wants to exit the program when back button is clicked on the first page. This forces application to customize back navigation to change the default action of back navigation. So now, the default action of back navigation has been modified. If navigator has more than one page, then the peek page is popped by back navigation. Otherwise, the current program is exited by back navigation. --- src/Tizen.NUI.Components/Controls/Navigation/AppBar.cs | 2 +- src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs | 10 +++++++++- src/Tizen.NUI.Components/Controls/Navigation/Page.cs | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/Navigation/AppBar.cs b/src/Tizen.NUI.Components/Controls/Navigation/AppBar.cs index de632cd..42d94c5 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/AppBar.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/AppBar.cs @@ -434,7 +434,7 @@ namespace Tizen.NUI.Components /// The default value is true. /// If AutoNavigationContent is set to be true and NavigationContent is not set, /// then default navigation content is automatically displayed. - /// If default navigation content is clicked, it calls navigator pop operation. + /// If default navigation content is clicked, the back navigation proceeds. /// /// 9 public bool AutoNavigationContent diff --git a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs index 0f9d047..99b225d 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs @@ -749,7 +749,9 @@ namespace Tizen.NUI.Components } /// - /// Gets or sets if Navigator pops the peek page when back button or back key is pressed and released. + /// Gets or sets if Navigator proceeds back navigation when back button or back key is pressed and released. + /// Back navigation pops the peek page if Navigator has more than one page. + /// If Navigator has only one page, then the current program is exited. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool EnableBackNavigation @@ -879,6 +881,8 @@ namespace Tizen.NUI.Components /// /// Called when the back navigation is started. + /// Back navigation pops the peek page if Navigator has more than one page. + /// If Navigator has only one page, then the current program is exited. /// /// The back navigation information. [EditorBrowsable(EditorBrowsableState.Never)] @@ -891,6 +895,10 @@ namespace Tizen.NUI.Components Peek().NavigateBack(); } } + else + { + NUIApplication.Current?.Exit(); + } } /// diff --git a/src/Tizen.NUI.Components/Controls/Navigation/Page.cs b/src/Tizen.NUI.Components/Controls/Navigation/Page.cs index 287d8d8..c0ed620 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Page.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Page.cs @@ -245,7 +245,9 @@ namespace Tizen.NUI.Components public event EventHandler Disappeared; /// - /// Gets or sets if this page is popped when back button or back key is pressed and released. + /// Gets or sets if this page proceeds back navigation when back button or back key is pressed and released. + /// Back navigation pops the peek page if Navigator has more than one page. + /// If Navigator has only one page, then the current program is exited. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool EnableBackNavigation @@ -367,12 +369,21 @@ namespace Tizen.NUI.Components /// /// Called when the back navigation is started. + /// Back navigation pops the peek page if Navigator has more than one page. + /// If Navigator has only one page, then the current program is exited. /// /// The back navigation information. [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void OnBackNavigation(PageBackNavigationEventArgs eventArgs) { - Navigator.Pop(); + if (Navigator.PageCount > 1) + { + Navigator.Pop(); + } + else + { + NUIApplication.Current?.Exit(); + } } /// -- 2.7.4