Skip to content

Commit

Permalink
Improve QrCode
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperJMN committed May 11, 2023
1 parent ed88871 commit 867b6c3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 36 deletions.
14 changes: 1 addition & 13 deletions WalletWasabi.Fluent/Controls/QrCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,7 @@ public QrCode()
}
});

_saveCommand = ReactiveCommand.CreateFromTask<string, Unit>(async address =>
{
await SaveQrCodeAsync(address);
return Unit.Default;
});

SaveCommand.ThrownExceptions
.ObserveOn(RxApp.TaskpoolScheduler)
.Subscribe(_ =>
{
// The error is thrown also in ReceiveAddressViewModel -> SaveQrCodeCommand.ThrownExceptions.
// However we need to catch it here too but to avoid duplicate logging we don't do anything here.
});
_saveCommand = ReactiveCommand.CreateFromTask<string>(SaveQrCodeAsync);
}

private bool[,]? FinalMatrix { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
Expand All @@ -9,7 +8,6 @@
using WalletWasabi.Fluent.Models.UI;
using WalletWasabi.Fluent.Models.Wallets;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Logging;

namespace WalletWasabi.Fluent.ViewModels.Wallets.Receive;

Expand All @@ -33,13 +31,6 @@ public ReceiveAddressViewModel(UiContext uiContext, IWalletModel wallet, IAddres

ShowOnHwWalletCommand = ReactiveCommand.CreateFromTask(ShowOnHwWalletAsync);

var saveQrCodeCommand = ReactiveCommand.CreateFromTask(OnSaveQrCodeAsync);
saveQrCodeCommand.ThrownExceptions
.ObserveOn(RxApp.TaskpoolScheduler)
.Subscribe(ex => Logger.LogError(ex));

SaveQrCodeCommand = saveQrCodeCommand;

NextCommand = CancelCommand;

QrCode = UiContext.QrCodeGenerator.Generate(model.Text);
Expand All @@ -58,12 +49,8 @@ public ReceiveAddressViewModel(UiContext uiContext, IWalletModel wallet, IAddres

public bool IsAutoCopyEnabled { get; }

public ReactiveCommand<string, Unit>? QrCodeCommand { get; set; }

public ICommand CopyAddressCommand { get; }

public ICommand SaveQrCodeCommand { get; }

public ICommand ShowOnHwWalletCommand { get; }

public string Address { get; }
Expand All @@ -87,12 +74,4 @@ private async Task ShowOnHwWalletAsync()
await ShowErrorAsync(Title, ex.ToUserFriendlyString(), "Unable to send the address to the device");
}
}

private async Task OnSaveQrCodeAsync()
{
if (QrCodeCommand is { } cmd)
{
await cmd.Execute(Address);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
<c:AdorningContentControl HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="False">
<c:AdorningContentControl.Adornment>
<Panel Margin="0 0 -5 20">
<Button Command="{Binding SaveQrCodeCommand}" ToolTip.Tip="Save" Classes="plain icon"
<Button Command="{Binding #QrCode.SaveCommand}" CommandParameter="{Binding Address}" ToolTip.Tip="Save" Classes="plain icon"
HorizontalAlignment="Right" VerticalAlignment="Bottom">
<PathIcon Data="{StaticResource save_regular}" />
</Button>
</Panel>
</c:AdorningContentControl.Adornment>
<Viewbox Margin="20" MaxHeight="270" MinHeight="100">
<c:PrivacyContentControl Height="264" PrivacyReplacementMode="Icon">
<c:QrCode Matrix="{Binding QrCode^}" SaveCommand="{Binding QrCodeCommand, Mode=OneWayToSource}" />
<c:QrCode x:Name="QrCode" Matrix="{Binding QrCode^}" />
</c:PrivacyContentControl>
</Viewbox>
</c:AdorningContentControl>
Expand Down

0 comments on commit 867b6c3

Please sign in to comment.