Rework navigation so we can resolve by key now
This commit is contained in:
@@ -6,9 +6,9 @@ using Toolkit.Foundation;
|
||||
namespace Toolkit.Avalonia;
|
||||
|
||||
public class ClassicDesktopStyleApplicationHandler :
|
||||
IHandler<NavigateEventArgs<IClassicDesktopStyleApplicationLifetime>>
|
||||
IHandler<NavigateTemplateEventArgs>
|
||||
{
|
||||
public void Handle(NavigateEventArgs<IClassicDesktopStyleApplicationLifetime> args)
|
||||
public void Handle(NavigateTemplateEventArgs args)
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is
|
||||
IClassicDesktopStyleApplicationLifetime lifeTime)
|
||||
|
||||
@@ -5,9 +5,9 @@ using Toolkit.Foundation;
|
||||
namespace Toolkit.Avalonia;
|
||||
|
||||
public class ContentControlHandler :
|
||||
IHandler<NavigateEventArgs<ContentControl>>
|
||||
IHandler<NavigateTemplateEventArgs>
|
||||
{
|
||||
public void Handle(NavigateEventArgs<ContentControl> args)
|
||||
public void Handle(NavigateTemplateEventArgs args)
|
||||
{
|
||||
if (args.Region is ContentControl contentControl)
|
||||
{
|
||||
|
||||
@@ -5,9 +5,9 @@ using Toolkit.UI.Controls.Avalonia;
|
||||
namespace Toolkit.Avalonia;
|
||||
|
||||
public class ContentDialogHandler :
|
||||
IHandler<NavigateEventArgs<ContentDialog>>
|
||||
IHandler<NavigateTemplateEventArgs>
|
||||
{
|
||||
public async void Handle(NavigateEventArgs<ContentDialog> args)
|
||||
public async void Handle(NavigateTemplateEventArgs args)
|
||||
{
|
||||
if (args.Template is ContentDialog dialog)
|
||||
{
|
||||
|
||||
@@ -8,10 +8,10 @@ using Toolkit.UI.Controls.Avalonia;
|
||||
namespace Toolkit.Avalonia;
|
||||
|
||||
public class FrameHandler(ITransientNavigationStore<Frame> navigationStore) :
|
||||
IHandler<NavigateEventArgs<Frame>>,
|
||||
IHandler<NavigateTemplateEventArgs>,
|
||||
IHandler<NavigateBackEventArgs<Frame>>
|
||||
{
|
||||
public void Handle(NavigateEventArgs<Frame> args)
|
||||
public void Handle(NavigateTemplateEventArgs args)
|
||||
{
|
||||
if (args.Region is Frame frame)
|
||||
{
|
||||
|
||||
@@ -30,16 +30,16 @@ public static class IServiceCollectionExtensions
|
||||
services.AddAsyncHandler<SelectionEventArgs<FolderFilter>, IReadOnlyCollection<string>?, SelectFoldersHandler>();
|
||||
services.AddAsyncHandler<SelectionEventArgs<FileFilter>, IReadOnlyCollection<string>?, SelectFilesHandler>();
|
||||
|
||||
services.AddHandler<NavigateEventArgs<IClassicDesktopStyleApplicationLifetime>, ClassicDesktopStyleApplicationHandler>(nameof(IClassicDesktopStyleApplicationLifetime));
|
||||
services.AddHandler<NavigateEventArgs<ISingleViewApplicationLifetime>, SingleViewApplicationHandler>(nameof(ISingleViewApplicationLifetime));
|
||||
services.AddHandler<NavigateTemplateEventArgs, ClassicDesktopStyleApplicationHandler>(nameof(IClassicDesktopStyleApplicationLifetime));
|
||||
services.AddHandler<NavigateTemplateEventArgs, SingleViewApplicationHandler>(nameof(ISingleViewApplicationLifetime));
|
||||
|
||||
services.AddHandler<NavigateEventArgs<ContentControl>, ContentControlHandler>(nameof(ContentControl));
|
||||
services.AddHandler<NavigateTemplateEventArgs, ContentControlHandler>(nameof(ContentControl));
|
||||
|
||||
services.AddHandler<NavigateEventArgs<Frame>, FrameHandler>(nameof(Frame));
|
||||
services.AddHandler<NavigateTemplateEventArgs, FrameHandler>(nameof(Frame));
|
||||
services.TryAddSingleton<ITransientNavigationStore<Frame>, TransientNavigationStore<Frame>>();
|
||||
|
||||
services.AddHandler<NavigateEventArgs<ContentDialog>, ContentDialogHandler>(nameof(ContentDialog));
|
||||
services.AddHandler<NavigateEventArgs<TaskDialog>, TaskDialogHandler>(nameof(TaskDialog));
|
||||
services.AddHandler<NavigateTemplateEventArgs, ContentDialogHandler>(nameof(ContentDialog));
|
||||
services.AddHandler<NavigateTemplateEventArgs, TaskDialogHandler>(nameof(TaskDialog));
|
||||
|
||||
services.AddScoped<INavigationRegionCollection, NavigationRegionCollection>(provider => new NavigationRegionCollection
|
||||
{
|
||||
@@ -69,13 +69,13 @@ public static class IServiceCollectionExtensions
|
||||
services.AddAsyncHandler<SelectionEventArgs<FolderFilter>, IReadOnlyCollection<string>?, SelectFoldersHandler>();
|
||||
services.AddAsyncHandler<SelectionEventArgs<FileFilter>, IReadOnlyCollection<string>?, SelectFilesHandler>();
|
||||
|
||||
services.AddHandler<NavigateEventArgs<ContentControl>, ContentControlHandler>(nameof(ContentControl));
|
||||
services.AddHandler<NavigateTemplateEventArgs, ContentControlHandler>(nameof(ContentControl));
|
||||
|
||||
services.AddHandler<NavigateEventArgs<Frame>, FrameHandler>(nameof(Frame));
|
||||
services.AddHandler<NavigateTemplateEventArgs, FrameHandler>(nameof(Frame));
|
||||
services.TryAddSingleton<ITransientNavigationStore<Frame>, TransientNavigationStore<Frame>>();
|
||||
|
||||
services.AddHandler<NavigateEventArgs<ContentDialog>, ContentDialogHandler>(nameof(ContentDialog));
|
||||
services.AddHandler<NavigateEventArgs<TaskDialog>, TaskDialogHandler>(nameof(TaskDialog));
|
||||
services.AddHandler<NavigateTemplateEventArgs, ContentDialogHandler>(nameof(ContentDialog));
|
||||
services.AddHandler<NavigateTemplateEventArgs, TaskDialogHandler>(nameof(TaskDialog));
|
||||
})));
|
||||
|
||||
return services;
|
||||
|
||||
@@ -6,9 +6,9 @@ using Toolkit.Foundation;
|
||||
namespace Toolkit.Avalonia;
|
||||
|
||||
public class SingleViewApplicationHandler :
|
||||
IHandler<NavigateEventArgs<ISingleViewApplicationLifetime>>
|
||||
IHandler<NavigateTemplateEventArgs>
|
||||
{
|
||||
public void Handle(NavigateEventArgs<ISingleViewApplicationLifetime> args)
|
||||
public void Handle(NavigateTemplateEventArgs args)
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is
|
||||
ISingleViewApplicationLifetime lifeTime)
|
||||
|
||||
@@ -6,9 +6,9 @@ using Toolkit.UI.Controls.Avalonia;
|
||||
namespace Toolkit.Avalonia;
|
||||
|
||||
public class TaskDialogHandler(ITopLevelProvider topLevelProvider) :
|
||||
IHandler<NavigateEventArgs<TaskDialog>>
|
||||
IHandler<NavigateTemplateEventArgs>
|
||||
{
|
||||
public async void Handle(NavigateEventArgs<TaskDialog> args)
|
||||
public async void Handle(NavigateTemplateEventArgs args)
|
||||
{
|
||||
if (args.Template is TaskDialog dialog)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user