This commit is contained in:
TheXamlGuy
2024-04-26 23:05:36 +01:00
parent 9f90ef693d
commit bc55c4649b
206 changed files with 3106 additions and 3204 deletions
@@ -11,7 +11,7 @@ public class ClassicDesktopStyleApplicationHandler(INavigationContext navigation
public Task Handle(Navigate<IClassicDesktopStyleApplicationLifetime> args,
CancellationToken cancellationToken = default)
{
if (Application.Current?.ApplicationLifetime is
if (Application.Current?.ApplicationLifetime is
IClassicDesktopStyleApplicationLifetime lifeTime)
{
if (args.Template is Window window)
+2 -2
View File
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
namespace Toolkit.Avalonia;
public class ContentControlHandler(INavigationContext navigationContext) :
public class ContentControlHandler(INavigationContext navigationContext) :
INavigateHandler<ContentControl>
{
public async Task Handle(Navigate<ContentControl> args,
@@ -57,4 +57,4 @@ public class ContentControlHandler(INavigationContext navigationContext) :
}
}
}
}
}
+4 -4
View File
@@ -3,7 +3,7 @@ using Toolkit.UI.Controls.Avalonia;
namespace Toolkit.Avalonia;
public class ContentDialogHandler(IDispatcher dispatcher) :
public class ContentDialogHandler(IDispatcher dispatcher) :
INavigateHandler<ContentDialog>
{
public async Task Handle(Navigate<ContentDialog> args,
@@ -50,7 +50,7 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
async void HandleClosing(FluentAvalonia.UI.Controls.ContentDialog sender,
FluentAvalonia.UI.Controls.ContentDialogClosingEventArgs args)
{
if (args.Result == FluentAvalonia.UI.Controls.ContentDialogResult.Primary ||
if (args.Result == FluentAvalonia.UI.Controls.ContentDialogResult.Primary ||
args.Result == FluentAvalonia.UI.Controls.ContentDialogResult.Secondary)
{
contentDialog.Closing -= HandleClosing;
@@ -93,12 +93,12 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
}
if (content is IActivated activated)
{
{
await activated.Activated();
}
}
}
contentDialog.Opened += HandleOpened;
contentDialog.Closing += HandleClosing;
contentDialog.PrimaryButtonClick += HandlePrimaryButtonClick;
+2 -2
View File
@@ -54,7 +54,7 @@ public class ContentTemplate :
control.Loaded += HandleLoaded;
control.Unloaded += HandleUnloaded;
viewModelContentBinder?.Set(control);
return control;
@@ -67,4 +67,4 @@ public class ContentTemplate :
}
public bool Match(object? data) => true;
}
}
+11 -11
View File
@@ -7,7 +7,7 @@ using Toolkit.UI.Controls.Avalonia;
namespace Toolkit.Avalonia;
public class FrameHandler(INavigationContext navigationContext) :
public class FrameHandler(INavigationContext navigationContext) :
INavigateHandler<Frame>,
INavigateBackHandler<Frame>
{
@@ -19,13 +19,13 @@ public class FrameHandler(INavigationContext navigationContext) :
frame.NavigationPageFactory ??= new NavigationPageFactory();
if (args.Template is Control control)
{
void NavigatingFrom(object? sender,
void NavigatingFrom(object? sender,
Control control)
{
async void HandleNavigatingFrom(object? _,
async void HandleNavigatingFrom(object? _,
NavigatingCancelEventArgs args)
{
Dictionary<string,object> results = [];
Dictionary<string, object> results = [];
control.RemoveHandler(Frame.NavigatingFromEvent, HandleNavigatingFrom);
NavigatedFrom(sender, control, () => results);
@@ -71,13 +71,13 @@ public class FrameHandler(INavigationContext navigationContext) :
}
}
}
}
}
}
control.AddHandler(Frame.NavigatingFromEvent, HandleNavigatingFrom);
}
void NavigatedFrom(object? sender,
void NavigatedFrom(object? sender,
Control control,
Func<Dictionary<string, object>> resultCallBack)
{
@@ -109,9 +109,9 @@ public class FrameHandler(INavigationContext navigationContext) :
contract.GetGenericArguments() is { Length: 1 } arguments)
{
if (contentType.GetMethods().FirstOrDefault(x =>
x.Name == "NavigatedToAsync" &&
x.Name == "NavigatedToAsync" &&
x.GetCustomAttribute<NavigationContextAttribute>()
is NavigationContextAttribute attribute && results.ContainsKey(attribute.Name))
is NavigationContextAttribute attribute && results.ContainsKey(attribute.Name))
is MethodInfo methodInfo)
{
if (methodInfo.GetCustomAttribute<NavigationContextAttribute>()
@@ -153,10 +153,10 @@ public class FrameHandler(INavigationContext navigationContext) :
control.AddHandler(Frame.NavigatedFromEvent, HandleNavigatedFrom);
}
void NavigatedTo(object? sender,
void NavigatedTo(object? sender,
Control control)
{
async void HandleNavigatedTo(object? _,
async void HandleNavigatedTo(object? _,
NavigationEventArgs __)
{
control.RemoveHandler(Frame.NavigatedToEvent, HandleNavigatedTo);
@@ -200,4 +200,4 @@ public class FrameHandler(INavigationContext navigationContext) :
return Task.CompletedTask;
}
}
}
+1 -2
View File
@@ -33,5 +33,4 @@ public class NavigationContext(INavigationContextCollection contexts) :
}
}
}
}
}
+2 -2
View File
@@ -3,10 +3,10 @@ using FluentAvalonia.UI.Controls;
namespace Toolkit.Avalonia;
public class NavigationPageFactory :
public class NavigationPageFactory :
INavigationPageFactory
{
public Control? GetPage(Type srcType) => default;
public Control GetPageFromObject(object target) => (Control)target;
}
}
@@ -25,4 +25,4 @@ public class SingleViewApplicationHandler(INavigationContext navigationContext)
return Task.CompletedTask;
}
}
}