From 544e0609ff3b0d918a512bac66e298a7771b92b8 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 39a8e09..365c56d 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs @@ -759,7 +759,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 @@ -889,6 +891,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)] @@ -901,6 +905,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 f4d1bde..136e595 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Page.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Page.cs @@ -254,7 +254,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 @@ -376,12 +378,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