Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix NavigationParameters #33

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions src/Lemon.ModuleNavigation/Core/NavigationService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Lemon.ModuleNavigation.Abstracts;
using Lemon.ModuleNavigation.Internals;
using System.Collections.Concurrent;
using System.Reflection.Metadata;

namespace Lemon.ModuleNavigation.Core
{
Expand All @@ -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()
{
Expand Down Expand Up @@ -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<IModule>.BindingNavigationHandler(IModuleNavigationHandler<IModule> moduleHandler)
{
Expand Down Expand Up @@ -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);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Package.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.0.0-beta</Version>
<Version>2.0.1-beta</Version>
<Authors>Easley</Authors>
<RepositoryUrl>https://github.com/NeverMorewd/Lemon.ModuleNavigation</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Loading