remove base vm for dialogs
MODIFY
WalletWasabi.Fluent/ViewModels/Dialog/DialogViewModelBaseOfTResult.cs
WalletWasabi.Fluent/ViewModels/Dialog/DialogViewModelBaseOfTResult.cs
@@ -11,8 +11,9 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
/// Spawn a new instance instead after that.
/// </summary>
/// <typeparam name="TResult">The type of the value to be returned when the dialog is finished.</typeparam>
- public abstract class DialogViewModelBase<TResult> : DialogViewModelBase
+ public abstract class DialogViewModelBase<TResult> : ViewModelBase, IDialogViewModel
{
+ private bool _isDialogOpen;
private IDisposable _disposable;
protected DialogViewModelBase()
@@ -27,7 +28,7 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
// Trigger when closed abruptly (via the Overlay or the back button).
if (!obj & CurrentTaskCompletionSource is { })
{
- Close();
+ Close(default(TResult));
}
}
@@ -48,10 +49,7 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
CurrentTaskCompletionSource.SetResult(value);
CurrentTaskCompletionSource = null;
- if (!(value?.Equals(default(TResult)) ?? true))
- {
_disposable?.Dispose();
- }
IsDialogOpen = false;
@@ -76,5 +74,19 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
return CurrentTaskCompletionSource.Task;
}
+
+ /// <summary>
+ /// Gets or sets if the dialog is opened/closed.
+ /// </summary>
+ public bool IsDialogOpen
+ {
+ get => _isDialogOpen;
+ set => this.RaiseAndSetIfChanged(ref _isDialogOpen, value);
+ }
+
+ /// <summary>
+ /// Method that is triggered when the dialog is closed.
+ /// </summary>
+ protected abstract void OnDialogClosed();
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Dialog/IDialogHost.cs
WalletWasabi.Fluent/ViewModels/Dialog/IDialogHost.cs
@@ -8,6 +8,6 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
/// <summary>
/// The currently active dialog. The modal dialog UI should close when this is null.
/// </summary>
- DialogViewModelBase? CurrentDialog { get; set; }
+ IDialogViewModel CurrentDialog { get; set; }
}
}

ADD
WalletWasabi.Fluent/ViewModels/Dialog/IDialogViewModel.cs
+namespace WalletWasabi.Fluent.ViewModels.Dialog
+{
+ public interface IDialogViewModel
+ {
+ bool IsDialogOpen { get; set; }
+ }
+}

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -13,7 +13,7 @@ namespace WalletWasabi.Fluent.ViewModels
private Global _global;
private StatusBarViewModel _statusBar;
private string _title = "Wasabi Wallet";
- private DialogViewModelBase? _currentDialog;
+ private IDialogViewModel _currentDialog;
private NavBarViewModel _navBar;
public MainViewModel(Global global)
{
@@ -36,7 +36,7 @@ namespace WalletWasabi.Fluent.ViewModels
public Network Network { get; }
- public DialogViewModelBase? CurrentDialog
+ public IDialogViewModel CurrentDialog
{
get => _currentDialog;
set => this.RaiseAndSetIfChanged(ref _currentDialog, value);

remove base vm for dialogs