Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
_serviceProvider = serviceProvider;
_dialogService = dialogService;
_regionManager = regionManager;
// default view
// default views for different regions
_navigationService.RequestViewNavigation("ContentRegion", "ViewAlpha", false);
_navigationService.RequestViewNavigation("TransitioningContentRegion", "ViewAlpha", false);
Modules = new ObservableCollection<IModule>(modules);
ToViewCommand = ReactiveCommand.Create<string>(content =>
{
Expand Down Expand Up @@ -110,7 +111,7 @@
set
{
this.RaiseAndSetIfChanged(ref _selectedModule, value);
_navigationService.RequestModuleNavigate(_selectedModule!, null);

Check warning on line 114 in src/Lemon.ModuleNavigation.Sample/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

Cannot convert null literal to non-nullable reference type.

Check warning on line 114 in src/Lemon.ModuleNavigation.Sample/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

Cannot convert null literal to non-nullable reference type.

Check warning on line 114 in src/Lemon.ModuleNavigation.Sample/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

Cannot convert null literal to non-nullable reference type.

Check warning on line 114 in src/Lemon.ModuleNavigation.Sample/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

Cannot convert null literal to non-nullable reference type.

Check warning on line 114 in src/Lemon.ModuleNavigation.Sample/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (macos-13)

Cannot convert null literal to non-nullable reference type.

Check warning on line 114 in src/Lemon.ModuleNavigation.Sample/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / build (macos-13)

Cannot convert null literal to non-nullable reference type.
}
}
public IServiceProvider ServiceProvider => _serviceProvider;
Expand Down
30 changes: 22 additions & 8 deletions src/Lemon.ModuleNavigation/Core/RegionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public class RegionManager : IRegionManager
{
private readonly ConcurrentDictionary<string, IRegion> _regions = [];
private readonly IServiceProvider _serviceProvider;
private readonly ConcurrentStack<NavigationContext> _buffer = [];
private readonly ConcurrentSet<IObserver<NavigationContext>> _navigationObservers = new();
private readonly ConcurrentSet<IObserver<IRegion>> _regionsObservers = new();
private readonly ConcurrentDictionary<string, ConcurrentStack<NavigationContext>> _buffer = [];
private readonly ConcurrentSet<IObserver<NavigationContext>> _navigationObservers = [];
private readonly ConcurrentSet<IObserver<IRegion>> _regionsObservers = [];
public RegionManager(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
Expand All @@ -27,7 +27,18 @@ public void RequestNavigate(string regionName, string viewName, bool requestNew,
}
else
{
_buffer.Push(context);
_buffer.AddOrUpdate(regionName,
key =>
{
var stack = new ConcurrentStack<NavigationContext>();
stack.Push(context);
return stack;
},
(key, value) =>
{
value.Push(context);
return value;
});
}
}

Expand All @@ -36,11 +47,14 @@ public void AddRegion(string regionName, IRegion region)
if (_regions.TryAdd(regionName, region))
{
ToRegionsObservers(region);
if (_buffer.TryPop(out var context))

if (_buffer.TryGetValue(regionName, out var navigationContexts))
{
region.Activate(context);
ToNavigationObservers(context);
_buffer.Clear();
if (navigationContexts.TryPop(out var context))
{
region.Activate(context);
ToNavigationObservers(context);
}
}
}
else
Expand Down
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.8-beta</Version>
<Version>2.0.9-beta</Version>
<Authors>Easley</Authors>
<RepositoryUrl>https://github.com/NeverMorewd/Lemon.ModuleNavigation</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Loading