code sweep
This commit is contained in:
@@ -1,44 +1,43 @@
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Mediator;
|
||||
|
||||
namespace Toolkit.Foundation.Avalonia
|
||||
namespace Toolkit.Foundation.Avalonia;
|
||||
|
||||
public class ContentDialogNavigationHandler : IRequestHandler<ContentDialogNavigation, bool>
|
||||
{
|
||||
public class ContentDialogNavigationHandler : IRequestHandler<ContentDialogNavigation, bool>
|
||||
public async ValueTask<bool> Handle(ContentDialogNavigation request, CancellationToken cancellationToken)
|
||||
{
|
||||
public async ValueTask<bool> Handle(ContentDialogNavigation request, CancellationToken cancellationToken)
|
||||
if (request.Template is ContentDialog contentDialog)
|
||||
{
|
||||
if (request.Template is ContentDialog contentDialog)
|
||||
async void HandleButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
async void HandleButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
ContentDialogButtonClickDeferral defferal = args.GetDeferral();
|
||||
if (sender.DataContext is INavigationConfirmation confirmation)
|
||||
{
|
||||
ContentDialogButtonClickDeferral defferal = args.GetDeferral();
|
||||
if (sender.DataContext is INavigationConfirmation confirmation)
|
||||
if (!await confirmation.CanConfirm())
|
||||
{
|
||||
if (!await confirmation.CanConfirm())
|
||||
{
|
||||
args.Cancel = true;
|
||||
}
|
||||
args.Cancel = true;
|
||||
}
|
||||
|
||||
if (!args.Cancel)
|
||||
{
|
||||
contentDialog.SecondaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.CloseButtonClick -= HandleButtonClick;
|
||||
}
|
||||
|
||||
defferal.Complete();
|
||||
}
|
||||
|
||||
contentDialog.SecondaryButtonClick += HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick += HandleButtonClick;
|
||||
contentDialog.CloseButtonClick += HandleButtonClick;
|
||||
if (!args.Cancel)
|
||||
{
|
||||
contentDialog.SecondaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick -= HandleButtonClick;
|
||||
contentDialog.CloseButtonClick -= HandleButtonClick;
|
||||
}
|
||||
|
||||
contentDialog.DataContext = request.Content;
|
||||
await contentDialog.ShowAsync();
|
||||
defferal.Complete();
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
contentDialog.SecondaryButtonClick += HandleButtonClick;
|
||||
contentDialog.PrimaryButtonClick += HandleButtonClick;
|
||||
contentDialog.CloseButtonClick += HandleButtonClick;
|
||||
|
||||
contentDialog.DataContext = request.Content;
|
||||
await contentDialog.ShowAsync();
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user