fix closing if there are more dialogs
MODIFY
WalletWasabi.Fluent/Controls/Dialog.axaml.cs
WalletWasabi.Fluent/Controls/Dialog.axaml.cs
@@ -23,6 +23,9 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<bool> IsDialogOpenProperty =
AvaloniaProperty.Register<Dialog, bool>(nameof(IsDialogOpen));
+ public static readonly StyledProperty<bool> IsActiveProperty =
+ AvaloniaProperty.Register<Dialog, bool>(nameof(IsActive));
+
public static readonly StyledProperty<bool> IsBusyProperty =
AvaloniaProperty.Register<Dialog, bool>(nameof(IsBusy));
@@ -70,6 +73,12 @@ namespace WalletWasabi.Fluent.Controls
set => SetValue(IsDialogOpenProperty, value);
}
+ public bool IsActive
+ {
+ get => GetValue(IsActiveProperty);
+ set => SetValue(IsActiveProperty, value);
+ }
+
public bool IsBusy
{
get => GetValue(IsBusyProperty);
@@ -182,13 +191,14 @@ namespace WalletWasabi.Fluent.Controls
private void CancelPointerPressed(object? sender, PointerPressedEventArgs e)
{
- if (IsDialogOpen && EnableCancelOnPressed && !IsBusy && _dismissPanel is { } && _overlayPanel is { } && _canCancelOnPointerPressed)
+ if (IsDialogOpen && IsActive && EnableCancelOnPressed && !IsBusy && _dismissPanel is { } && _overlayPanel is { } && _canCancelOnPointerPressed)
{
var point = e.GetPosition(_dismissPanel);
var isPressedOnTitleBar = e.GetPosition(_overlayPanel).Y < 30;
if (!_dismissPanel.Bounds.Contains(point) && !isPressedOnTitleBar)
{
+ e.Handled = true;
Close();
}
}
@@ -196,8 +206,9 @@ namespace WalletWasabi.Fluent.Controls
private void CancelKeyDown(object? sender, KeyEventArgs e)
{
- if (e.Key == Key.Escape && EnableCancelOnEscape && !IsBusy)
+ if (e.Key == Key.Escape && EnableCancelOnEscape && !IsBusy && IsActive)
{
+ e.Handled = true;
Close();
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -87,6 +87,54 @@ namespace WalletWasabi.Fluent.ViewModels
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => IsMainContentEnabled = !x);
+ this.WhenAnyValue(
+ x => x.DialogScreen.CurrentPage,
+ x => x.CompactDialogScreen.CurrentPage,
+ x => x.FullScreen.CurrentPage)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(tup =>
+ {
+ var (currentDialog, currentCompactDialog, currentFullScreenDialog) = tup;
+
+ if (currentDialog is { })
+ {
+ currentDialog.IsActive = false;
+ }
+
+ if (currentDialog is { })
+ {
+ currentDialog.IsActive = false;
+ }
+
+ if (currentFullScreenDialog is { })
+ {
+ currentFullScreenDialog.IsActive = false;
+ }
+
+ if (currentCompactDialog is { })
+ {
+ currentCompactDialog.IsActive = false;
+ }
+
+ if (currentCompactDialog is { })
+ {
+ currentCompactDialog.IsActive = true;
+ return;
+ }
+
+ if (currentDialog is { })
+ {
+ currentDialog.IsActive = true;
+ return;
+ }
+
+ if (currentFullScreenDialog is { })
+ {
+ currentFullScreenDialog.IsActive = true;
+ return;
+ }
+ });
+
if (!Services.WalletManager.HasWallet())
{
_dialogScreen.To(_addWalletPage, NavigationMode.Clear);

MODIFY
WalletWasabi.Fluent/ViewModels/Navigation/RoutableViewModel.cs
WalletWasabi.Fluent/ViewModels/Navigation/RoutableViewModel.cs
@@ -16,6 +16,7 @@ namespace WalletWasabi.Fluent.ViewModels.Navigation
[AutoNotify] private bool _enableCancelOnEscape;
[AutoNotify] private bool _enableBack;
[AutoNotify] private bool _enableCancel;
+ [AutoNotify] private bool _isActive;
public abstract string Title { get; protected set; }

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
<c:Dialog x:CompileBindings="False"
DataContext="{Binding FullScreen}"
IsDialogOpen="{Binding IsDialogOpen, Mode=TwoWay}"
+ IsActive="{Binding CurrentPage.IsActive}"
IsBusy="{Binding CurrentPage.IsBusy, FallbackValue=False}"
IsBackEnabled="{Binding CurrentPage.EnableBack, FallbackValue=False}"
IsCancelEnabled="{Binding CurrentPage.EnableCancel, FallbackValue=False}"
<c:Dialog x:CompileBindings="False"
DataContext="{Binding DialogScreen}"
IsDialogOpen="{Binding IsDialogOpen, Mode=TwoWay}"
+ IsActive="{Binding CurrentPage.IsActive}"
IsBusy="{Binding CurrentPage.IsBusy, FallbackValue=False}"
IsBackEnabled="{Binding CurrentPage.EnableBack, FallbackValue=False}"
IsCancelEnabled="{Binding CurrentPage.EnableCancel, FallbackValue=False}"
<c:Dialog x:CompileBindings="False"
DataContext="{Binding CompactDialogScreen}"
IsDialogOpen="{Binding IsDialogOpen, Mode=TwoWay}"
+ IsActive="{Binding CurrentPage.IsActive}"
IsBusy="{Binding CurrentPage.IsBusy, FallbackValue=False}"
IsBackEnabled="{Binding CurrentPage.EnableBack, FallbackValue=False}"
IsCancelEnabled="{Binding CurrentPage.EnableCancel, FallbackValue=False}"

fix closing if there are more dialogs