From 1fec00b6f1ae0cb0f2bae63a9e771a70acb28a39 Mon Sep 17 00:00:00 2001 From: Easley Date: Wed, 13 Nov 2024 17:52:47 +0800 Subject: [PATCH] fix NavigationParameters --- .../Core/NavigationService.cs | 38 +++++++++++-------- src/Package.props | 2 +- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/Lemon.ModuleNavigation/Core/NavigationService.cs b/src/Lemon.ModuleNavigation/Core/NavigationService.cs index b346f8c..fd4e44a 100644 --- a/src/Lemon.ModuleNavigation/Core/NavigationService.cs +++ b/src/Lemon.ModuleNavigation/Core/NavigationService.cs @@ -1,6 +1,7 @@ using Lemon.ModuleNavigation.Abstracts; using Lemon.ModuleNavigation.Internals; using System.Collections.Concurrent; +using System.Reflection.Metadata; namespace Lemon.ModuleNavigation.Core { @@ -12,7 +13,7 @@ public class NavigationService : INavigationService // reserve only one for now. private readonly ConcurrentStack<(IModule module, NavigationParameters parameter)> _bufferModule = []; private readonly ConcurrentStack<(string moduleName, NavigationParameters parameter)> _bufferModuleName = []; - private readonly ConcurrentStack<(string regionName, string viewName, bool requestNew)> _bufferViewName = []; + private readonly ConcurrentStack<(string regionName, string viewName, NavigationParameters? parameter, bool requestNew)> _bufferViewName = []; public NavigationService() { @@ -46,7 +47,18 @@ public void RequestViewNavigation(string regionName, { handler.OnNavigateTo(regionName, viewKey, requestNew); } - _bufferViewName.Push((regionName, viewKey, requestNew)); + _bufferViewName.Push((regionName, viewKey, null, requestNew)); + } + public void RequestViewNavigation(string regionName, + string viewKey, + NavigationParameters parameters, + bool requestNew = false) + { + foreach (var handler in _viewHandlers) + { + handler.OnNavigateTo(regionName, viewKey, parameters, requestNew); + } + _bufferViewName.Push((regionName, viewKey, parameters, requestNew)); } IDisposable IModuleNavigationService.BindingNavigationHandler(IModuleNavigationHandler moduleHandler) { @@ -78,25 +90,21 @@ IDisposable IModuleNavigationService.BindingNavigationHandler(IModuleNavigationH IDisposable IViewNavigationService.BindingViewNavigationHandler(IViewNavigationHandler handler) { _viewHandlers.Add(handler); - foreach (var (regionName, viewName, requestNew) in _bufferViewName) + foreach (var (regionName, viewName, parameters, requestNew) in _bufferViewName) { - handler.OnNavigateTo(regionName, viewName, requestNew); + if (parameters == null) + { + handler.OnNavigateTo(regionName, viewName, requestNew); + } + else + { + handler.OnNavigateTo(regionName, viewName, parameters, requestNew); + } } return new DisposableAction(() => { _viewHandlers.Remove(handler); }); } - - public void RequestViewNavigation(string regionName, - string viewKey, - NavigationParameters parameters, - bool requestNew = false) - { - foreach (var handler in _viewHandlers) - { - handler.OnNavigateTo(regionName, viewKey, requestNew); - } - } } } diff --git a/src/Package.props b/src/Package.props index 3b6d7a6..66e4086 100644 --- a/src/Package.props +++ b/src/Package.props @@ -1,6 +1,6 @@ - 2.0.0-beta + 2.0.1-beta Easley https://github.com/NeverMorewd/Lemon.ModuleNavigation MIT