From f9b784931fce9649a9875d7b0ff9d11e3663e2e8 Mon Sep 17 00:00:00 2001 From: Ali Yousefi Date: Fri, 22 Dec 2023 16:13:19 +0330 Subject: [PATCH] add support for base page --- .../EasyMicroservices.UI.Cores.Mvvm/ApiBaseViewModel.cs | 6 +++--- .../EasyMicroservices.UI.Cores.Mvvm.csproj | 2 +- .../{ => Navigations}/NavigationManagerBase.cs | 2 +- .../ResponsibleBaseViewModel.cs | 1 + .../EasyMicroservices.UI.MauiComponents.csproj | 2 +- .../Navigations/DefaultNavigationManager.cs | 6 ++++-- 6 files changed, 11 insertions(+), 8 deletions(-) rename src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/{ => Navigations}/NavigationManagerBase.cs (98%) diff --git a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ApiBaseViewModel.cs b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ApiBaseViewModel.cs index 6388462..fcd872f 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ApiBaseViewModel.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ApiBaseViewModel.cs @@ -18,7 +18,7 @@ public class ApiBaseViewModel : BaseViewModel /// /// /// - public async virtual Task ExecuteApi(Func> getServerResult, Func onSuccess, Func onError = default) + public async virtual Task ExecuteApi(Func> getServerResult, Func, Task> onSuccess, Func onError = default) { try { @@ -52,7 +52,7 @@ public async virtual Task ExecuteApi(Func> getServerResult /// /// /// - public virtual async Task ExecuteApi(Func> getServerResult, Func onSuccess, Func onError = default) + public virtual async Task ExecuteApi(Func> getServerResult, Func onSuccess = default, Func onError = default) { try { @@ -62,7 +62,7 @@ public virtual async Task ExecuteApi(Func> getServerResult, FuncAnyCPU;x64;x86 EasyMicroservices true - 0.0.0.10 + 0.0.0.11 Model View View Model EasyMicroservices@gmail.com mvvm,mvpvm,modelview,modelviewviewmodel diff --git a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/NavigationManagerBase.cs b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Navigations/NavigationManagerBase.cs similarity index 98% rename from src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/NavigationManagerBase.cs rename to src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Navigations/NavigationManagerBase.cs index 1b1a670..2940e3c 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/NavigationManagerBase.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/Navigations/NavigationManagerBase.cs @@ -4,7 +4,7 @@ using System.IO; using System.Threading.Tasks; -namespace EasyMicroservices.UI.Cores; +namespace EasyMicroservices.UI.Cores.Navigations; /// /// /// diff --git a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ResponsibleBaseViewModel.cs b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ResponsibleBaseViewModel.cs index 4cfc815..853face 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ResponsibleBaseViewModel.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.Cores.Mvvm/ResponsibleBaseViewModel.cs @@ -1,4 +1,5 @@ using EasyMicroservices.UI.Cores.Interfaces; +using EasyMicroservices.UI.Cores.Navigations; using System; using System.Collections.Generic; using System.Text; 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 251a76c..2b1d459 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.1 + 0.0.0.11 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 9632840..8cfa7d0 100644 --- a/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs +++ b/src/CSharp/MauiComponents/EasyMicroservices.UI.MauiComponents/Navigations/DefaultNavigationManager.cs @@ -1,6 +1,6 @@ using EasyMicroservices.UI.Cores; using EasyMicroservices.UI.Cores.Interfaces; -using System.Collections.Concurrent; +using EasyMicroservices.UI.Cores.Navigations; namespace EasyMicroservices.UI.MauiComponents.Navigations; public class DefaultNavigationManager : NavigationManagerBase @@ -26,10 +26,12 @@ public override async Task PushDataAsync(TD if (!Pages.TryGetValue(pageName, out Type pageTpe)) throw new Exception($"Page {pageName} not found, did you register it?"); var findPage = Activator.CreateInstance(pageTpe); - Page page = findPage as Page; + ContentPage page = findPage as ContentPage; if (page == null) throw new NotImplementedException($"Page {pageName} is not inherit Page!"); var ipage = page as IPage; + if (page.BindingContext == null) + page.BindingContext = page.Content?.BindingContext; if (page.BindingContext is PageBaseViewModel pageBaseViewModel && ipage != null) pageBaseViewModel.Page = ipage; if (doClear)