finish things up
MODIFY
WalletWasabi.Fluent/Controls/DialogContentHost.cs
WalletWasabi.Fluent/Controls/DialogContentHost.cs
@@ -26,7 +26,7 @@ namespace WalletWasabi.Fluent.Controls
public DialogContentHost()
{
- CloseDialogCommand = ReactiveCommand.Create(() => Content.IsDialogOpen = false);
+ CloseDialogCommand = ReactiveCommand.Create(() => Content?.CloseDialog());
}
private static void OnContentPropertyChanged(DialogContentHost arg1, AvaloniaPropertyChangedEventArgs arg2)
@@ -51,10 +51,5 @@ namespace WalletWasabi.Fluent.Controls
get => GetValue(CloseDialogCommandProperty);
set => SetValue(CloseDialogCommandProperty, value);
}
-
- public void CloseDialog()
- {
- Content.IsDialogOpen = false;
- }
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Dialog/DialogViewModelBaseOfTResult.cs
WalletWasabi.Fluent/ViewModels/Dialog/DialogViewModelBaseOfTResult.cs
@@ -9,7 +9,6 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
/// <typeparam name="TResult">The type of the value to be returned when the dialog is finished.</typeparam>
public abstract class DialogViewModelBase<TResult> : DialogViewModelBase
{
-
private TaskCompletionSource<TResult> CurrentTaskCompletionSource { get; set; }
/// <summary>
@@ -19,15 +18,10 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
/// <param name="value">The return value of the dialog</param>
public void CloseDialog(TResult value)
{
- if (IsDialogOpen is false)
- {
- throw new InvalidOperationException("Dialog was already closed.");
- }
-
CurrentTaskCompletionSource.SetResult(value);
CurrentTaskCompletionSource = null;
- IsDialogOpen = false;
+ CloseDialog();
}
/// <summary>
@@ -45,16 +39,11 @@ namespace WalletWasabi.Fluent.ViewModels.Dialog
CurrentTaskCompletionSource = new TaskCompletionSource<TResult>();
+ DialogShowing();
+
IsDialogOpen = true;
- DialogShown();
return CurrentTaskCompletionSource.Task;
}
-
- /// <summary>
- /// Method that is triggered when the dialog
- /// is to be shown.
- /// </summary>
- protected abstract void DialogShown();
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/TestDialogViewModel.cs
WalletWasabi.Fluent/ViewModels/TestDialogViewModel.cs
@@ -6,8 +6,17 @@ namespace WalletWasabi.Fluent.ViewModels
{
public class TestDialogViewModel : DialogViewModelBase<string>
{
- protected override void DialogShown()
+ protected override void DialogClosing()
{
}
+
+ protected override void DialogShowing()
+ {
+ Task.Run(async () =>
+ {
+ await Task.Delay(15000);
+ CloseDialog("Done");
+ });
+ }
}
}

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vl="clr-namespace:WalletWasabi.Fluent"
+ xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
xmlns:local="clr-namespace:WalletWasabi.Fluent.Views"
xmlns:rxui="clr-namespace:Avalonia.ReactiveUI;assembly=Avalonia.ReactiveUI"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
xmlns:behaviors="clr-namespace:WalletWasabi.Fluent.Behaviors;assembly=WalletWasabi.Fluent"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.MainView">
+ <Panel>
<SplitView IsPaneOpen="{Binding NavBar.IsOpen, Mode=TwoWay}">
<i:Interaction.Behaviors>
<behaviors:SplitViewAutoBehavior ToggleAction="{Binding NavBar.ToggleAction, Mode=OneWayToSource}"
</DockPanel>
</Panel>
</SplitView>
+ <c:DialogContentHost Content="{Binding CurrentDialog}"/>
+ </Panel>
</UserControl>

MODIFY
WalletWasabi.Fluent/Views/MainWindow.axaml
WalletWasabi.Fluent/Views/MainWindow.axaml
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WalletWasabi.Fluent.Views"
xmlns:vm="clr-namespace:WalletWasabi.Fluent.ViewModels;assembly=WalletWasabi.Fluent"
- xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
<Panel Margin="{Binding #MainWindow.OffScreenMargin}">
<local:MainView />
- <c:DialogContentHost Content="{Binding CurrentDialog}"/>
</Panel>
</Window>

MODIFY
WalletWasabi.Fluent/Views/TestDialogView.axaml
WalletWasabi.Fluent/Views/TestDialogView.axaml
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Width="450" Height="200"
x:Class="WalletWasabi.Fluent.Views.TestDialogView">
+ <Panel Margin="10">
+ <Button Classes="invisible" Command="{Binding CloseDialog}" HorizontalAlignment="Left" VerticalAlignment="Top">
+ <PathIcon Data="{StaticResource arrow_left_regular}" />
+ </Button>
<StackPanel HorizontalAlignment="Center"
VerticalAlignment="Center">
- <TextBlock Text="Hi, I'm a dialog and will close in 5 seconds!" />
+ <TextBlock Text="Hi, I'm a dialog and will close in 15 seconds!" />
</StackPanel>
+ </Panel>
</UserControl>

finish things up