fix dialog usage
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -16,6 +16,7 @@ using WalletWasabi.Extensions;
using WalletWasabi.Fluent.Extensions;
using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Fluent.Models;
+using WalletWasabi.Fluent.ViewModels.CoinControl;
using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Logging;
@@ -28,6 +29,7 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
{
private readonly Stack<(BuildTransactionResult, TransactionInfo)> _undoHistory;
private readonly Wallet _wallet;
+ private readonly WalletViewModel _walletViewModel;
private TransactionInfo _info;
private TransactionInfo _currentTransactionInfo;
private CancellationTokenSource? _cancellationTokenSource;
@@ -36,18 +38,20 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
[AutoNotify] private bool _adjustFeeAvailable;
[AutoNotify] private TransactionSummaryViewModel? _displayedTransactionSummary;
[AutoNotify] private bool _canUndo;
+ [AutoNotify] private bool _isCoinControlVisible;
public TransactionPreviewViewModel(Wallet wallet, WalletViewModel walletViewModel, TransactionInfo info)
{
_undoHistory = new();
_wallet = wallet;
+ _walletViewModel = walletViewModel;
_info = info;
_currentTransactionInfo = info.Clone();
_cancellationTokenSource = new CancellationTokenSource();
PrivacySuggestions = new PrivacySuggestionsFlyoutViewModel();
- CurrentTransactionSummary = new TransactionSummaryViewModel(this, walletViewModel, _wallet, _info);
- PreviewTransactionSummary = new TransactionSummaryViewModel(this, walletViewModel, _wallet, _info, true);
+ CurrentTransactionSummary = new TransactionSummaryViewModel(this, _wallet, _info);
+ PreviewTransactionSummary = new TransactionSummaryViewModel(this, _wallet, _info, true);
TransactionSummaries = new List<TransactionSummaryViewModel>
{
@@ -132,8 +136,9 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
});
ChangePocketCommand = ReactiveCommand.CreateFromTask(OnChangePocketsAsync);
+ ChangeCoinsCommand = ReactiveCommand.CreateFromTask(OnChangeCoinsAsync);
- EnableCoinControlCommand = ReactiveCommand.Create(() => CurrentTransactionSummary.IsCoinControlVisible = true);
+ EnableCoinControlCommand = ReactiveCommand.Create(() => IsCoinControlVisible = true);
}
public TransactionSummaryViewModel CurrentTransactionSummary { get; }
@@ -150,6 +155,8 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
public ICommand ChangePocketCommand { get; }
+ public ICommand ChangeCoinsCommand { get; }
+
public ICommand UndoCommand { get; }
public ICommand EnableCoinControlCommand { get; }
@@ -225,6 +232,19 @@ public partial class TransactionPreviewViewModel : RoutableViewModel
}
}
+ private async Task OnChangeCoinsAsync()
+ {
+ var selectCoinsDialog =
+ await NavigateDialogAsync(new SelectCoinsDialogViewModel(_walletViewModel));
+
+ if (selectCoinsDialog.Kind == DialogResultKind.Normal && selectCoinsDialog.Result is { })
+ {
+ _info.Coins = selectCoinsDialog.Result;
+ _info.ChangelessCoins = Enumerable.Empty<SmartCoin>(); // Clear ChangelessCoins on pocket change, so we calculate the suggestions with the new coins.
+ await BuildAndUpdateAsync(BuildTransactionReason.PocketChanged); // TODO: check if PocketChanged reason is good for this case too (maybe rename)
+ }
+ }
+
private async Task<bool> InitialiseTransactionAsync()
{
if (_info.FeeRate == FeeRate.Zero)

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionSummaryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionSummaryViewModel.cs
-using System.Collections.Generic;
using System.Linq;
-using System.Reactive;
-using System.Reactive.Linq;
using ReactiveUI;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.TransactionBuilding;
-using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Fluent.Extensions;
using WalletWasabi.Fluent.Helpers;
-using WalletWasabi.Fluent.ViewModels.CoinControl;
-using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
-using WalletWasabi.Fluent.ViewModels.Navigation;
using WalletWasabi.Wallets;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
@@ -29,9 +22,8 @@ public partial class TransactionSummaryViewModel : ViewModelBase
[AutoNotify] private bool _isOtherPocketSelectionPossible;
[AutoNotify] private SmartLabel _labels = SmartLabel.Empty;
[AutoNotify] private SmartLabel _recipient = SmartLabel.Empty;
- [AutoNotify] private bool _isCoinControlVisible;
- public TransactionSummaryViewModel(TransactionPreviewViewModel parent, WalletViewModel walletViewModel, Wallet wallet, TransactionInfo info, bool isPreview = false)
+ public TransactionSummaryViewModel(TransactionPreviewViewModel parent, Wallet wallet, TransactionInfo info, bool isPreview = false)
{
Parent = parent;
_wallet = wallet;
@@ -43,39 +35,8 @@ public partial class TransactionSummaryViewModel : ViewModelBase
AddressText = info.Destination.ToString();
PayJoinUrl = info.PayJoinClient?.PaymentUrl.AbsoluteUri;
IsPayJoin = PayJoinUrl is not null;
-
- var selectCoinsInteraction = SelectCoinsInteraction(walletViewModel);
-
- SelectCoinsCommand = ReactiveCommand.CreateFromObservable(() => selectCoinsInteraction.Handle(info));
- SelectCoinsCommand.Do(
- list =>
- {
- info.Coins = list;
-
- // UpdateTransactionSummary here, but how??
- }).Subscribe();
}
- private static Interaction<TransactionInfo, List<SmartCoin>> SelectCoinsInteraction(WalletViewModel walletViewModel)
- {
- var selectCoinsInteraction = new Interaction<TransactionInfo, List<SmartCoin>>();
- selectCoinsInteraction.RegisterHandler(
- async context =>
- {
- var navigateDialog = await MainViewModel.Instance.DialogScreen.NavigateDialogAsync(new SelectCoinsDialogViewModel(walletViewModel));
-
- if (navigateDialog.Kind == DialogResultKind.Normal)
- {
- context.SetOutput(navigateDialog.Result!.ToList());
- }
-
- context.SetOutput(new List<SmartCoin>());
- });
- return selectCoinsInteraction;
- }
-
- public ReactiveCommand<Unit, List<SmartCoin>> SelectCoinsCommand { get; }
-
public TransactionPreviewViewModel Parent { get; }
public bool IsPreview { get; }

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/TransactionPreviewView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/TransactionPreviewView.axaml
</StackPanel>
</DockPanel>
</c:ContentArea.Title>
+ <DockPanel>
+ <Button IsVisible="{Binding IsCoinControlVisible}"
+ Command="{Binding ChangeCoinsCommand}"
+ Content="Review coins"
+ Margin="10 0"
+ VerticalAlignment="Center"
+ DockPanel.Dock="Bottom" />
+
<Carousel Items="{Binding TransactionSummaries}" IsVirtualized="False"
SelectedItem="{Binding DisplayedTransactionSummary}">
<Carousel.PageTransition>
</DataTemplate>
</Carousel.ItemTemplate>
</Carousel>
+ </DockPanel>
</c:ContentArea>
</UserControl>

fix dialog usage