Skip to content

Commit

Permalink
Merge pull request WalletWasabi#12312 from wieslawsoltes/vdg/fix-1156…
Browse files Browse the repository at this point in the history
…8-close-the-dialog-automatically

[VDG] Close the Success dialog automatically
  • Loading branch information
RolandUI authored Feb 2, 2024
2 parents a3e4c68 + 2cd14d2 commit c1d664a
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 58 deletions.
1 change: 1 addition & 0 deletions WalletWasabi.Fluent/UiConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ public static class UiConstants
{
public const char PrivacyChar = '#';
public const int PrivacyRingMaxItemCount = 100;
public const int CloseSuccessDialogMillisecondsDelay = 1000;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ private async Task OnNextAsync(WalletCreationOptions options)

await AutoLoginAsync(options);

IsBusy = false;

await Task.Delay(UiConstants.CloseSuccessDialogMillisecondsDelay);

Navigate().Clear();

UiContext.Navigate().To(_wallet);
}

Expand All @@ -51,6 +56,11 @@ protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disp
base.OnNavigatedTo(isInHistory, disposables);

_wallet = UiContext.WalletRepository.SaveWallet(_walletSettings);

if (NextCommand is not null && NextCommand.CanExecute(default))
{
NextCommand.Execute(default);
}
}

private async Task AutoLoginAsync(WalletCreationOptions? options)
Expand Down
24 changes: 20 additions & 4 deletions WalletWasabi.Fluent/ViewModels/SuccessViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Reactive.Disposables;
using System.Threading.Tasks;
using ReactiveUI;
using WalletWasabi.Fluent.ViewModels.Navigation;

Expand All @@ -6,13 +8,27 @@ namespace WalletWasabi.Fluent.ViewModels;
[NavigationMetaData(Title = "Success")]
public partial class SuccessViewModel : RoutableViewModel
{
private SuccessViewModel(string successText)
private SuccessViewModel()
{
SuccessText = successText;
NextCommand = ReactiveCommand.Create(() => Navigate().Clear());
NextCommand = ReactiveCommand.CreateFromTask(OnNextAsync);

SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: true);
}

public string SuccessText { get; }
private async Task OnNextAsync()
{
await Task.Delay(UiConstants.CloseSuccessDialogMillisecondsDelay);

Navigate().Clear();
}

protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)
{
base.OnNavigatedTo(isInHistory, disposables);

if (NextCommand is not null && NextCommand.CanExecute(default))
{
NextCommand.Execute(default);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private async Task OnNextAsync(SmartTransaction transaction)
try
{
await UiContext.TransactionBroadcaster.SendAsync(transaction);
Navigate().To().Success("The transaction has been successfully broadcasted.");
Navigate().To().Success();
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Reactive.Disposables;
using System.Threading.Tasks;
using ReactiveUI;
using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Wallets;

namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;

Expand All @@ -16,19 +17,32 @@ private SendSuccessViewModel(SmartTransaction finalTransaction, string? title =

Caption = caption ?? "Your transaction has been successfully sent.";

NextCommand = ReactiveCommand.Create(OnNext);
NextCommand = ReactiveCommand.CreateFromTask(OnNextAsync);

SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: true);
}

public override string Title { get; protected set; }

public string? Caption { get; }

private void OnNext()
private async Task OnNextAsync()
{
await Task.Delay(UiConstants.CloseSuccessDialogMillisecondsDelay);

Navigate().Clear();

// TODO: Remove this
MainViewModel.Instance.NavBar.SelectedWallet?.WalletViewModel?.SelectTransaction(_finalTransaction.GetHash());
}

protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)
{
base.OnNavigatedTo(isInHistory, disposables);

if (NextCommand is not null && NextCommand.CanExecute(default))
{
NextCommand.Execute(default);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private async Task OnExportPsbtAsync()

if (saved)
{
Navigate().To().Success("The PSBT has been successfully created.");
Navigate().To().Success();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private async Task OnNextAsync(IWalletModel wallet)
var verificationResult = wallet.Auth.VerifyRecoveryWords(currentMnemonics);
if (verificationResult)
{
Navigate().To().Success("Your Recovery Words have been verified and are correct.", navigationMode: NavigationMode.Clear);
Navigate().To().Success(navigationMode: NavigationMode.Clear);
}
else
{
Expand Down
19 changes: 3 additions & 16 deletions WalletWasabi.Fluent/Views/AddWallet/AddedWalletPageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:WalletWasabi.Fluent.ViewModels.AddWallet"
xmlns:c="using:WalletWasabi.Fluent.Controls"
xmlns:conv="using:WalletWasabi.Fluent.Converters"
xmlns:views="clr-namespace:WalletWasabi.Fluent.Views"
mc:Ignorable="d" d:DesignWidth="428" d:DesignHeight="371"
x:DataType="vm:AddedWalletPageViewModel"
x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.AddWallet.AddedWalletPageView">
<c:ContentArea Title="{Binding Title}"
EnableCancel="{Binding EnableCancel}"
EnableBack="{Binding EnableBack}"
IsBusy="{Binding IsBusy}"
NextContent="Done" EnableNext="True"
<c:ContentArea EnableNext="False"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<DockPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="0 40 0 0">
<TextBlock Text="Your wallet " />
<TextBlock Text="{Binding WalletName}" FontWeight="Bold" />
<TextBlock Text=" was added to Wasabi." />
</StackPanel>
<Viewbox MaxHeight="200">
<Image Source="{Binding WalletType, Converter={x:Static conv:WalletIconConverter.WalletTypeToImage}}" />
</Viewbox>
</DockPanel>
<views:SuccessAnimationView VerticalAlignment="Center" />
</c:ContentArea>
</UserControl>
25 changes: 25 additions & 0 deletions WalletWasabi.Fluent/Views/SuccessAnimationView.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<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" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.SuccessAnimationView">
<Viewbox MaxHeight="150" Margin="40">
<Viewbox.Styles>
<Style Selector=":is(PathIcon).fadeIn">
<Style.Animations>
<Animation Duration="0:0:1" Easing="{StaticResource FluentEasing}">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0.0" />
</KeyFrame>
<KeyFrame Cue="75%">
<Setter Property="Opacity" Value="0.6" />
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</Viewbox.Styles>
<PathIcon Data="{StaticResource copy_confirmed}" Opacity="0.6" Foreground="{DynamicResource SystemAccentColor}" Classes="fadeIn" />
</Viewbox>
</UserControl>

17 changes: 17 additions & 0 deletions WalletWasabi.Fluent/Views/SuccessAnimationView.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace WalletWasabi.Fluent.Views;

public class SuccessAnimationView : UserControl
{
public SuccessAnimationView()
{
InitializeComponent();
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
26 changes: 3 additions & 23 deletions WalletWasabi.Fluent/Views/SuccessView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:c="using:WalletWasabi.Fluent.Controls"
xmlns:viewModels="clr-namespace:WalletWasabi.Fluent.ViewModels"
xmlns:views="clr-namespace:WalletWasabi.Fluent.Views"
mc:Ignorable="d" d:DesignWidth="428" d:DesignHeight="371"
x:DataType="viewModels:SuccessViewModel"
x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.SuccessView">
<c:ContentArea Title="{Binding Title}"
EnableNext="True" NextContent="Done"
<c:ContentArea EnableNext="False"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<DockPanel VerticalAlignment="Center">
<TextBlock Text="{Binding SuccessText}" DockPanel.Dock="Bottom" TextAlignment="Center" TextWrapping="Wrap" />

<Viewbox MaxHeight="150" Margin="40">
<Viewbox.Styles>
<Style Selector=":is(PathIcon).fadeIn">
<Style.Animations>
<Animation Duration="0:0:1">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0.0" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Opacity" Value="0.6" />
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</Viewbox.Styles>
<PathIcon Data="{StaticResource copy_confirmed}" Opacity="0.6" Foreground="{DynamicResource SystemAccentColor}" Classes="fadeIn" />
</Viewbox>
</DockPanel>
<views:SuccessAnimationView VerticalAlignment="Center" />
</c:ContentArea>
</UserControl>
12 changes: 3 additions & 9 deletions WalletWasabi.Fluent/Views/Wallets/Send/SendSuccessView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:c="using:WalletWasabi.Fluent.Controls"
xmlns:vm="using:WalletWasabi.Fluent.ViewModels.Wallets.Send"
xmlns:views="clr-namespace:WalletWasabi.Fluent.Views"
mc:Ignorable="d"
x:DataType="vm:SendSuccessViewModel"
x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.Wallets.Send.SendSuccessView">
<c:ContentArea Title="{Binding Title}"
EnableNext="True" NextContent="Done"
<c:ContentArea EnableNext="False"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
MinWidth="500">
<DockPanel VerticalAlignment="Center">
<TextBlock Text="{Binding Caption}" DockPanel.Dock="Bottom" TextAlignment="Center" TextWrapping="Wrap" />

<Viewbox MaxHeight="150" Margin="40">
<PathIcon Data="{StaticResource copy_confirmed}" Opacity="0.6" Foreground="{DynamicResource SystemAccentColor}" />
</Viewbox>
</DockPanel>
<views:SuccessAnimationView VerticalAlignment="Center" />
</c:ContentArea>
</UserControl>

0 comments on commit c1d664a

Please sign in to comment.