implement dialogs as an actual dialog...
MODIFY
WalletWasabi.Fluent/Controls/DialogContentHost.cs
WalletWasabi.Fluent/Controls/DialogContentHost.cs
+using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Mixins;
@@ -17,9 +18,14 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<bool> IsDialogOpenProperty =
AvaloniaProperty.Register<DialogContentHost, bool>(nameof(IsDialogOpen));
- public DialogContentHost()
+ static DialogContentHost()
{
- PseudoClasses.Set(":open", IsDialogOpen);
+ IsDialogOpenProperty.Changed.AddClassHandler<DialogContentHost>(UpdatePseudoClasses);
+ }
+
+ private static void UpdatePseudoClasses(DialogContentHost arg1, AvaloniaPropertyChangedEventArgs arg2)
+ {
+ arg1.PseudoClasses.Set(":open", (bool)arg2.NewValue);
}
/// <summary>

MODIFY
WalletWasabi.Fluent/Controls/DialogContentHost.xaml
WalletWasabi.Fluent/Controls/DialogContentHost.xaml
<Styles.Resources>
</Styles.Resources>
<Style Selector="c|DialogContentHost">
- <Style.Animations>
- <Animation Duration="2" Delay="2">
- <KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0" />
- </KeyFrame>
- <KeyFrame Cue="100%">
- <Setter Property="Opacity" Value="100"/>
- </KeyFrame>
- </Animation>
- </Style.Animations>
+ <Setter Property="Transitions">
+ <Transitions>
+ <TransformOperationsTransition Property="RenderTransform" Duration="0:0:1" Easing="0.1,0.9,0.2,1.0" />
+ <DoubleTransition Property="Opacity" Duration="0:0:1" Easing="0.1,0.9,0.2,1.0" />
+ </Transitions>
+ </Setter>
<Setter Property="Template">
<ControlTemplate>
<Panel>
- <Panel Background="#3A3A3A" Opacity="0.8" />
- <Border MaxWidth="300" MaxHeight="200" CornerRadius="5" BoxShadow="4 11 30 1 #90000000" Background="#212121" >
- <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" FontSize="25">Hello World!</TextBlock>
+ <Panel Background="#3A3A3A" Name="Overlay" IsHitTestVisible="False" />
+ <Border VerticalAlignment="Center" HorizontalAlignment="Center" CornerRadius="5" BoxShadow="4 11 30 1 #90000000" Background="#212121" >
+ <ContentPresenter Content="{TemplateBinding Content}"/>
</Border>
</Panel>
</ControlTemplate>
</Setter>
</Style>
+ <Style Selector="c|DialogContentHost:open">
+ <Setter Property="Opacity" Value="0.8"/>
+ </Style>
+ <Style Selector="c|DialogContentHost:not(:open)">
+ <Setter Property="Opacity" Value="0"/>
+ </Style>
</Styles>
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Dialog/DialogViewModelBaseOfTResult.cs
WalletWasabi.Fluent/ViewModels/Dialog/DialogViewModelBaseOfTResult.cs
@@ -27,6 +27,7 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
{
CurrentTaskCompletionSource.SetResult(value);
CurrentTaskCompletionSource = null;
+ DialogHost.CloseDialog();
}
/// <summary>

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -42,7 +42,7 @@ namespace WalletWasabi.Fluent.ViewModels
public Network Network { get; }
- DialogViewModelBase? IDialogHost.CurrentDialog
+ public DialogViewModelBase? CurrentDialog
{
get => _currentDialog;
set => this.RaiseAndSetIfChanged(ref _currentDialog, value);
@@ -66,7 +66,7 @@ namespace WalletWasabi.Fluent.ViewModels
internal set => this.RaiseAndSetIfChanged(ref _title, value);
}
- bool IDialogHost.IsDialogOpen
+ public bool IsDialogOpen
{
get => _isDialogOpen;
set => this.RaiseAndSetIfChanged(ref _isDialogOpen, value);

MODIFY
WalletWasabi.Fluent/ViewModels/SettingsPageViewModel.cs
WalletWasabi.Fluent/ViewModels/SettingsPageViewModel.cs
using ReactiveUI;
using System.Windows.Input;
+using WalletWasabi.Fluent.ViewModels.Dialog;
namespace WalletWasabi.Fluent.ViewModels
{
@@ -13,9 +14,16 @@ namespace WalletWasabi.Fluent.ViewModels
{
screen.Router.Navigate.Execute(new HomePageViewModel(screen));
});
+
+ OpenDialogCommand = ReactiveCommand.Create(async () =>
+ {
+ var x = new TestDialogViewModel(MainViewModel.Instance);
+ var result = await x.ShowDialogAsync();
+ });
}
public ICommand NextCommand { get; }
+ public ICommand OpenDialogCommand { get; }
public override string IconName => "settings_regular";
}

ADD
WalletWasabi.Fluent/ViewModels/TestDialogViewModel.cs
+using System.Threading.Tasks;
+using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels.Dialog;
+
+namespace WalletWasabi.Fluent.ViewModels
+{
+ public class TestDialogViewModel : DialogViewModelBase<string>
+ {
+ public TestDialogViewModel(MainViewModel mainViewModel) : base(mainViewModel)
+ {
+ }
+
+ protected override void DialogShown()
+ {
+ Task.Run(async () =>
+ {
+ await Task.Delay(5000);
+ CloseDialog("Done");
+ });
+ }
+ }
+}

MODIFY
WalletWasabi.Fluent/Views/SettingsPageView.axaml
WalletWasabi.Fluent/Views/SettingsPageView.axaml
x:Class="WalletWasabi.Fluent.Views.SettingsPageView">
<Panel>
<TextBlock Text="Settings" FontSize="22" VerticalAlignment="Center" HorizontalAlignment="Center" />
+ <StackPanel>
<Button Command="{Binding NextCommand}" Content="Next" />
+ <Button Command="{Binding OpenDialogCommand}" Content="Open Dialog" />
+ </StackPanel>
</Panel>
</UserControl>

ADD
WalletWasabi.Fluent/Views/TestDialogView.axaml
+<UserControl xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d" Width="450" Height="200"
+ x:Class="WalletWasabi.Fluent.Views.TestDialogView">
+ <StackPanel HorizontalAlignment="Center"
+ VerticalAlignment="Center">
+ <TextBlock Text="Hi, I'm a dialog and will close in 5 seconds!" />
+ </StackPanel>
+</UserControl>

ADD
WalletWasabi.Fluent/Views/TestDialogView.axaml.cs
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+using Avalonia.ReactiveUI;
+using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels;
+
+namespace WalletWasabi.Fluent.Views
+{
+ public class TestDialogView : UserControl
+ {
+ public TestDialogView()
+ {
+ InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}

implement dialogs as an actual dialog...