remove all the excess code for dialog over dialog.
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reactive.Linq;
-using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
using System.Windows.Input;
using DynamicData;
@@ -51,23 +50,21 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
async () => await OnNext(walletManager, network, walletName),
FinishCommandCanExecute);
- AdvancedOptionsInteraction = new Interaction<(KeyPath, int), (KeyPath?, int?)>();
- AdvancedOptionsInteraction.RegisterHandler(
- async interaction =>
- interaction.SetOutput(
- (await new AdvancedRecoveryOptionsViewModel(interaction.Input).ShowDialogAsync()).Result));
-
AdvancedRecoveryOptionsDialogCommand = ReactiveCommand.CreateFromTask(
async () =>
{
- var (accountKeyPathIn, minGapLimitIn) = await AdvancedOptionsInteraction
- .Handle((AccountKeyPath, MinGapLimit)).ToTask();
+ var result = await NavigateDialog(new AdvancedRecoveryOptionsViewModel((AccountKeyPath, MinGapLimit)));
+
+ if (result.Kind == DialogResultKind.Normal)
+ {
+ var (accountKeyPathIn, minGapLimitIn) = result.Result;
if (accountKeyPathIn is { } && minGapLimitIn is { })
{
AccountKeyPath = accountKeyPathIn;
MinGapLimit = (int)minGapLimitIn;
}
+ }
});
EnableAutoBusyOn(NextCommand);
@@ -129,8 +126,6 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
private int MinGapLimit { get; set; } = 63;
- private Interaction<(KeyPath, int), (KeyPath?, int?)> AdvancedOptionsInteraction { get; }
-
public ObservableCollection<string> Mnemonics { get; } = new();
private void ValidateMnemonics(IValidationErrors errors)

MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/Base/DialogViewModelBaseOfTResult.cs
WalletWasabi.Fluent/ViewModels/Dialogs/Base/DialogViewModelBaseOfTResult.cs
@@ -68,27 +68,6 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs.Base
OnDialogClosed();
}
- /// <summary>
- /// Shows the dialog.
- /// </summary>
- /// <returns>The value to be returned when the dialog is finished.</returns>
- public Task<DialogResult<TResult>> ShowDialogAsync(IDialogHost? host = null)
- {
- if (host is null)
- {
- host = MainViewModel.Instance;
- }
-
- if (host is { })
- {
- host.CurrentDialog = this;
- }
-
- IsDialogOpen = true;
-
- return _currentTaskCompletionSource.Task;
- }
-
/// <summary>
/// Gets the dialog result.
/// </summary>

DELETE
WalletWasabi.Fluent/ViewModels/Dialogs/Base/IDialogHost.cs
-namespace WalletWasabi.Fluent.ViewModels.Dialogs.Base
-{
- /// <summary>
- /// Interface for ViewModels that can host a modal dialog.
- /// </summary>
- public interface IDialogHost
- {
- /// <summary>
- /// The currently active dialog. The modal dialog UI should close when this is null.
- /// </summary>
- DialogViewModelBase? CurrentDialog { get; set; }
- }
-}

MODIFY
WalletWasabi.Fluent/ViewModels/HelpAndSupport/AboutViewModel.cs
WalletWasabi.Fluent/ViewModels/HelpAndSupport/AboutViewModel.cs
using System;
using System.IO;
-using System.Reactive;
-using System.Reactive.Threading.Tasks;
using System.Windows.Input;
using Avalonia;
using ReactiveUI;
@@ -30,13 +28,8 @@ namespace WalletWasabi.Fluent.ViewModels.HelpAndSupport
{
OpenBrowserCommand = ReactiveCommand.CreateFromTask<string>(IoHelpers.OpenBrowserAsync);
- var interaction = new Interaction<Unit, Unit>();
- interaction.RegisterHandler(
- async x =>
- x.SetOutput((await new AboutAdvancedInfoViewModel().ShowDialogAsync()).Result));
-
AboutAdvancedInfoDialogCommand = ReactiveCommand.CreateFromTask(
- execute: async () => await interaction.Handle(Unit.Default).ToTask());
+ execute: async () => await NavigateDialog(new AboutAdvancedInfoViewModel()));
OpenBrowserCommand = ReactiveCommand.CreateFromTask<string>(
async (link) =>

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -19,14 +19,13 @@ using WalletWasabi.Logging;
namespace WalletWasabi.Fluent.ViewModels
{
- public partial class MainViewModel : ViewModelBase, IDialogHost
+ public partial class MainViewModel : ViewModelBase
{
private readonly Global _global;
private readonly LegalChecker _legalChecker;
[AutoNotify] private bool _isMainContentEnabled;
[AutoNotify] private bool _isDialogScreenEnabled;
[AutoNotify] private bool _isFullScreenEnabled;
- [AutoNotify] private DialogViewModelBase? _currentDialog;
[AutoNotify] private DialogScreenViewModel _dialogScreen;
[AutoNotify] private DialogScreenViewModel _fullScreen;
[AutoNotify] private NavBarViewModel _navBar;
@@ -49,12 +48,10 @@ namespace WalletWasabi.Fluent.ViewModels
MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen);
- NavigationState.Register(MainScreen, DialogScreen, FullScreen, () => this);
+ NavigationState.Register(MainScreen, DialogScreen, FullScreen);
Network = global.Network;
- _currentDialog = null;
-
_isMainContentEnabled = true;
_isDialogScreenEnabled = true;
_isFullScreenEnabled = true;
@@ -96,14 +93,6 @@ namespace WalletWasabi.Fluent.ViewModels
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => IsMainContentEnabled = !x);
- this.WhenAnyValue(x => x.CurrentDialog!.IsDialogOpen)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(x =>
- {
- IsFullScreenEnabled = !x;
- IsDialogScreenEnabled = !x;
- });
-
_walletManagerViewModel.WhenAnyValue(x => x.Items.Count, x => x.Actions.Count)
.Subscribe(x => _navBar.IsHidden = x.Item1 == 0 && x.Item2 == 0);

MODIFY
WalletWasabi.Fluent/ViewModels/Navigation/NavigationState.cs
WalletWasabi.Fluent/ViewModels/Navigation/NavigationState.cs
-using System;
-using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
-
namespace WalletWasabi.Fluent.ViewModels.Navigation
{
public class NavigationState
@@ -8,19 +5,15 @@ namespace WalletWasabi.Fluent.ViewModels.Navigation
private NavigationState(
INavigationStack<RoutableViewModel> homeScreenNavigation,
INavigationStack<RoutableViewModel> dialogScreenNavigation,
- INavigationStack<RoutableViewModel> fullScreenNavigation,
- Func<IDialogHost> dialogHost)
+ INavigationStack<RoutableViewModel> fullScreenNavigation)
{
HomeScreenNavigation = homeScreenNavigation;
DialogScreenNavigation = dialogScreenNavigation;
FullScreenNavigation = fullScreenNavigation;
- DialogHost = dialogHost;
}
public static NavigationState Instance { get; private set; } = null!;
- public Func<IDialogHost> DialogHost { get; }
-
public INavigationStack<RoutableViewModel> HomeScreenNavigation { get; }
public INavigationStack<RoutableViewModel> DialogScreenNavigation { get; }
@@ -30,14 +23,12 @@ namespace WalletWasabi.Fluent.ViewModels.Navigation
public static void Register(
INavigationStack<RoutableViewModel> homeScreenNavigation,
INavigationStack<RoutableViewModel> dialogScreenNavigation,
- INavigationStack<RoutableViewModel> fullScreenNavigation,
- Func<IDialogHost> dialogHost)
+ INavigationStack<RoutableViewModel> fullScreenNavigation)
{
Instance = new NavigationState(
homeScreenNavigation,
dialogScreenNavigation,
- fullScreenNavigation,
- dialogHost);
+ fullScreenNavigation);
}
}
}

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
</c:Dialog.Styles>
<ContentControl Content="{Binding CurrentPage}" />
</c:Dialog>
- <c:Dialog DataContext="{Binding CurrentDialog}"
- IsDialogOpen="{Binding IsDialogOpen, Mode=TwoWay}"
- EnableCancelOnPressed="False"
- EnableCancelOnEscape="True"
- Content="{Binding }"
- HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
</Panel>
</UserControl>

remove all the excess code for dialog over dialog.