From 0d8552df2f77f637ddc71c30b27cdc207aa36460 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Mon, 28 Nov 2022 20:36:53 +0900 Subject: [PATCH] [NUI] Add OnBackNavigation to Page To enable customization of back navigation per page, OnBackNavigation is added to Page. e.g. class CustomPage : Page { protected override OnBackNavigation(PageBackNavigationEventArgs args) { // Do something when back navigation is started. ... // To pop this page, call base.OnBackNavigation(). // Otherwise, do not call base.OnBackNavigation(). base.OnBackNavigation(args); } } --- .../Controls/Navigation/Navigator.cs | 8 ++++--- .../Controls/Navigation/Page.cs | 25 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs index 289e26b..39a8e09 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs @@ -894,10 +894,12 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void OnBackNavigation(BackNavigationEventArgs eventArgs) { - if ((PageCount >= 1) && Peek().EnableBackNavigation) + if (PageCount >= 1) { - Tizen.Log.Info("NUI", $"Navigator pops the peek page.\n"); - Pop(); + if (Peek().EnableBackNavigation) + { + Peek().NavigateBack(); + } } } diff --git a/src/Tizen.NUI.Components/Controls/Navigation/Page.cs b/src/Tizen.NUI.Components/Controls/Navigation/Page.cs index 6bd365d..f4d1bde 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Page.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Page.cs @@ -374,5 +374,30 @@ namespace Tizen.NUI.Components } } + /// + /// Called when the back navigation is started. + /// + /// The back navigation information. + [EditorBrowsable(EditorBrowsableState.Never)] + protected virtual void OnBackNavigation(PageBackNavigationEventArgs eventArgs) + { + Navigator.Pop(); + } + + /// + /// Called when the back navigation is required outside Navigator. + /// + internal void NavigateBack() + { + OnBackNavigation(new PageBackNavigationEventArgs()); + } + } + + /// + /// PageBackNavigationEventArgs is a class to record back navigation event arguments which will sent to user. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PageBackNavigationEventArgs : EventArgs + { } } -- 2.7.4