Dialog deferrals
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using FluentAvalonia.Core;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Toolkit.Avalonia;
|
||||
@@ -20,11 +21,25 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
|
||||
{
|
||||
if (content is IPrimaryConfirmation primaryConfirmation)
|
||||
{
|
||||
List<Action> postActions = [];
|
||||
if (content is IActivityIndicator activityIndicator)
|
||||
{
|
||||
activityIndicator.Active = true;
|
||||
postActions.Add(() => activityIndicator.Active = false);
|
||||
}
|
||||
|
||||
Deferral deferral = args.GetDeferral();
|
||||
if (!await primaryConfirmation.Confirm())
|
||||
{
|
||||
args.Cancel = true;
|
||||
contentDialog.PrimaryButtonClick += HandlePrimaryButtonClick;
|
||||
}
|
||||
|
||||
deferral.Complete();
|
||||
foreach (Action action in postActions)
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,11 +52,25 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
|
||||
{
|
||||
if (content is ISecondaryConfirmation secondaryConfirmation)
|
||||
{
|
||||
List<Action> postActions = [];
|
||||
if (content is IActivityIndicator activityIndicator)
|
||||
{
|
||||
activityIndicator.Active = true;
|
||||
postActions.Add(() => activityIndicator.Active = false);
|
||||
}
|
||||
|
||||
Deferral deferral = args.GetDeferral();
|
||||
if (!await secondaryConfirmation.Confirm())
|
||||
{
|
||||
args.Cancel = true;
|
||||
contentDialog.SecondaryButtonClick += HandleSecondaryButtonClick;
|
||||
}
|
||||
|
||||
deferral.Complete();
|
||||
foreach (Action action in postActions)
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,11 +86,25 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
|
||||
{
|
||||
if (content is IConfirmation confirmation)
|
||||
{
|
||||
List<Action> postActions = [];
|
||||
if (content is IActivityIndicator activityIndicator)
|
||||
{
|
||||
activityIndicator.Active = true;
|
||||
postActions.Add(() => activityIndicator.Active = false);
|
||||
}
|
||||
|
||||
Deferral deferral = args.GetDeferral();
|
||||
if (!await confirmation.Confirm())
|
||||
{
|
||||
args.Cancel = true;
|
||||
contentDialog.Closing += HandleClosing;
|
||||
}
|
||||
|
||||
deferral.Complete();
|
||||
foreach (Action action in postActions)
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface IActivityIndicator
|
||||
{
|
||||
bool Active { get; set; }
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace Toolkit.Foundation;
|
||||
public partial class Observable :
|
||||
ObservableObject,
|
||||
IObservableViewModel,
|
||||
IActivityIndicator,
|
||||
IInitializer,
|
||||
IActivated,
|
||||
IDeactivating,
|
||||
@@ -20,9 +21,13 @@ public partial class Observable :
|
||||
private readonly Dictionary<string, object> trackedProperties = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isInitialized;
|
||||
private bool initialized;
|
||||
|
||||
public Observable(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool active;
|
||||
|
||||
public Observable(IServiceProvider
|
||||
provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -72,12 +77,12 @@ public partial class Observable :
|
||||
|
||||
public Task Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
if (Initialized)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
IsInitialized = true;
|
||||
Initialized = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user