diff --git a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/EasyMicroservices.UI.Cores.Mvvm.csproj b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/EasyMicroservices.UI.Cores.Mvvm.csproj index b1accd6..3427225 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/EasyMicroservices.UI.Cores.Mvvm.csproj +++ b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/EasyMicroservices.UI.Cores.Mvvm.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.23 + 0.0.0.24 Model View View Model EasyMicroservices@gmail.com mvvm,mvpvm,modelview,modelviewviewmodel diff --git a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Interfaces/IPage.cs b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Interfaces/IPage.cs index 22c9516..6a200db 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Interfaces/IPage.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Interfaces/IPage.cs @@ -16,7 +16,7 @@ public interface IPage /// /// /// - Action OnBackButtonPressedAction { get; set; } + Func OnBackButtonPressedAction { get; set; } /// /// /// diff --git a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Design/Pages/EasyContentPage.cs b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Design/Pages/EasyContentPage.cs index 1ae5acd..e6a9b04 100644 --- a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Design/Pages/EasyContentPage.cs +++ b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Design/Pages/EasyContentPage.cs @@ -14,13 +14,14 @@ private void CustomContentPage_Loaded(object sender, EventArgs e) OnLoadComplete?.Invoke(); } - public Action OnBackButtonPressedAction { get; set; } + public Func OnBackButtonPressedAction { get; set; } public Action OnLoadComplete { get; set; } protected override bool OnBackButtonPressed() { - OnBackButtonPressedAction?.Invoke(); + if (OnBackButtonPressedAction is not null) + return OnBackButtonPressedAction(); return base.OnBackButtonPressed(); } diff --git a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/EasyMicroservices.UI.MauiComponents.csproj b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/EasyMicroservices.UI.MauiComponents.csproj index 7eb78a9..d4a2d12 100644 --- a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/EasyMicroservices.UI.MauiComponents.csproj +++ b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/EasyMicroservices.UI.MauiComponents.csproj @@ -18,7 +18,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.19 + 0.0.0.20 Maui easy and light components EasyMicroservices@gmail.com maui,ui,component,components diff --git a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs index 4bcda6f..3ef1187 100644 --- a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs +++ b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs @@ -43,7 +43,26 @@ public override async Task PushDataAsync(TD if (page.BindingContext is IResponsibleViewModel responsibleViewModel) { if (ipage != null) - ipage.OnBackButtonPressedAction = responsibleViewModel.Close; + { + if (ipage.OnBackButtonPressedAction is null) + { + ipage.OnBackButtonPressedAction = () => + { + responsibleViewModel.Close(); + return true; + }; + } + else + { + var func = ipage.OnBackButtonPressedAction; + ipage.OnBackButtonPressedAction = () => + { + responsibleViewModel.Close(); + return func(); + }; + } + } + var result = await responsibleViewModel.GetResult(); if (result != null && result is TResponseData responseData) return responseData; @@ -92,7 +111,7 @@ public override Task OpenBrowser(string url) /// /// /// - public void RegisterContentPage(string pageName) + public virtual void RegisterContentPage(string pageName) where TView : ContentView, new() { Pages.TryAdd(pageName, () => @@ -103,4 +122,17 @@ public void RegisterContentPage(string pageName) }; }); } + + public virtual void RegisterContentPage(string pageName) + where TView : ContentView, new() + where TEasyContentPage : EasyContentPage, new() + { + Pages.TryAdd(pageName, () => + { + return new TEasyContentPage() + { + Content = new TView() + }; + }); + } } \ No newline at end of file