[NUI] Modify the default action of back navigation
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Thu, 1 Dec 2022 06:04:31 +0000 (15:04 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Fri, 10 Mar 2023 07:00:48 +0000 (16:00 +0900)
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
src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs
src/Tizen.NUI.Components/Controls/Navigation/Page.cs

index de632cd..42d94c5 100755 (executable)
@@ -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.
         /// </summary>
         /// <since_tizen> 9 </since_tizen>
         public bool AutoNavigationContent
index 39a8e09..365c56d 100755 (executable)
@@ -759,7 +759,9 @@ namespace Tizen.NUI.Components
         }
 
         /// <summary>
-        /// 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.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool EnableBackNavigation
@@ -889,6 +891,8 @@ namespace Tizen.NUI.Components
 
         /// <summary>
         /// 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.
         /// </summary>
         /// <param name="eventArgs">The back navigation information.</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -901,6 +905,10 @@ namespace Tizen.NUI.Components
                     Peek().NavigateBack();
                 }
             }
+            else
+            {
+                NUIApplication.Current?.Exit();
+            }
         }
 
         /// <summary>
index f4d1bde..136e595 100755 (executable)
@@ -254,7 +254,9 @@ namespace Tizen.NUI.Components
         public event EventHandler<PageDisappearedEventArgs> Disappeared;
 
         /// <summary>
-        /// 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.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool EnableBackNavigation
@@ -376,12 +378,21 @@ namespace Tizen.NUI.Components
 
         /// <summary>
         /// 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.
         /// </summary>
         /// <param name="eventArgs">The back navigation information.</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected virtual void OnBackNavigation(PageBackNavigationEventArgs eventArgs)
         {
-            Navigator.Pop();
+            if (Navigator.PageCount > 1)
+            {
+                Navigator.Pop();
+            }
+            else
+            {
+                NUIApplication.Current?.Exit();
+            }
         }
 
         /// <summary>