use the label entry dialog
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
using System;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
@@ -9,8 +6,6 @@ using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia;
using Avalonia.Threading;
-using DynamicData;
-using DynamicData.Binding;
using NBitcoin;
using NBitcoin.Payment;
using ReactiveUI;
@@ -18,7 +13,6 @@ using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Fluent.Models;
using WalletWasabi.Fluent.Validation;
using WalletWasabi.Fluent.ViewModels.Navigation;
-using WalletWasabi.Fluent.ViewModels.Wallets.Labels;
using WalletWasabi.Logging;
using WalletWasabi.Models;
using WalletWasabi.Tor.Http;
@@ -27,7 +21,6 @@ using WalletWasabi.Userfacing;
using WalletWasabi.Wallets;
using WalletWasabi.WebClients.PayJoin;
using Constants = WalletWasabi.Helpers.Constants;
-using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Fluent.ViewModels.Dialogs;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
@@ -57,8 +50,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
_wallet = wallet;
_transactionInfo = new TransactionInfo();
- SuggestionLabels = new SuggestionLabelsViewModel(3);
-
IsQrButtonVisible = WebcamQrReader.IsOsPlatformSupported;
ExchangeRate = _wallet.Synchronizer.UsdExchangeRate;
@@ -88,8 +79,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
});
- SuggestionLabels.Labels.ToObservableChangeSet().Subscribe(x => _transactionInfo.UserLabels = new SmartLabel(SuggestionLabels.Labels.ToArray()));
-
PasteCommand = ReactiveCommand.CreateFromTask(async () => await OnPasteAsync());
AutoPasteCommand = ReactiveCommand.CreateFromTask(async () => await OnAutoPasteAsync());
QRCommand = ReactiveCommand.Create(async () =>
@@ -103,29 +92,34 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
});
var nextCommandCanExecute =
- this.WhenAnyValue(x => x.AmountBtc, x => x.To).Select(_ => Unit.Default)
- .Merge(SuggestionLabels.WhenAnyValue(x => x.Labels.Count).Select(_ => Unit.Default))
- .Merge(SuggestionLabels.WhenAnyValue(x => x.IsCurrentTextValid).Select(_ => Unit.Default))
- .Select(_ =>
+ this.WhenAnyValue(x => x.AmountBtc, x => x.To)
+ .Select(tup =>
{
- var allFilled = !string.IsNullOrEmpty(To) && AmountBtc > 0 && (SuggestionLabels.Labels.Any() || SuggestionLabels.IsCurrentTextValid);
+ var (amountBtc, to) = tup;
+ var allFilled = !string.IsNullOrEmpty(to) && amountBtc > 0;
var hasError = Validations.Any;
return allFilled && !hasError;
});
- NextCommand = ReactiveCommand.Create(() =>
+ NextCommand = ReactiveCommand.CreateFromTask(async () =>
+ {
+ var labelDialog = new LabelEntryDialogViewModel(_wallet, _transactionInfo);
+
+ var result = await NavigateDialogAsync(labelDialog, NavigationTarget.CompactDialogScreen);
+
+ if (result.Result is null)
{
+ return;
+ }
+
+ _transactionInfo.UserLabels = result.Result;
_transactionInfo.Amount = new Money(AmountBtc, MoneyUnit.BTC);
Navigate().To(new TransactionPreviewViewModel(wallet, _transactionInfo));
}, nextCommandCanExecute);
-
- EnableAutoBusyOn(NextCommand);
}
- public SuggestionLabelsViewModel SuggestionLabels { get; }
-
public bool IsQrButtonVisible { get; }
public ICommand PasteCommand { get; }
@@ -244,12 +238,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
if (!label.IsEmpty)
{
- SuggestionLabels.Labels.Clear();
-
- foreach (var labelString in label.Labels)
- {
- SuggestionLabels.Labels.Add(labelString);
- }
+ _transactionInfo.UserLabels = new SmartLabel(label.Labels);
}
if (url.UnknowParameters.TryGetValue("pj", out var endPoint))
@@ -292,7 +281,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
To = "";
AmountBtc = 0;
- SuggestionLabels.Labels.Clear();
ClearValidations();
}
@@ -301,12 +289,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
.Subscribe(x => ExchangeRate = x)
.DisposeWith(disposables);
- _wallet.TransactionProcessor.WhenAnyValue(x => x.Coins)
- .Select(_ => Unit.Default)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(_ => SuggestionLabels.UpdateLabels())
- .DisposeWith(disposables);
-
RxApp.MainThreadScheduler.Schedule(async () => await OnAutoPasteAsync());
base.OnNavigatedTo(inHistory, disposables);

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
EnableCancel="{Binding EnableCancel}"
IsBusy="{Binding IsBusy}"
ScrollViewer.VerticalScrollBarVisibility="Auto">
- <DockPanel>
+ <DockPanel LastChildFill="False">
<DockPanel.Styles>
<Style Selector="DockPanel > Label">
<Setter Property="MinWidth" Value="80" />
ConversionRate="{Binding ExchangeRate}" ConversionCurrencyCode="USD" />
</DockPanel>
</DockPanel>
- <!-- Labels -->
- <DockPanel DockPanel.Dock="Top"
- VerticalAlignment="Top"
- Margin="0,0,0,10">
- <Label DockPanel.Dock="Left" Content="_Labels:" Target="LabelTagBox" />
- <c:TagsBox x:Name="LabelTagBox"
- DataContext="{Binding SuggestionLabels}"
- VerticalAlignment="Top"
- Watermark="{StaticResource LabelsWatermarkText}"
- TagSeparator=","
- SuggestionsAreCaseSensitive="True"
- RestrictInputToSuggestions="False"
- Items="{Binding Labels}"
- TopItems="{Binding TopSuggestions}"
- Suggestions="{Binding Suggestions}"
- MaxTextLength="{StaticResource MaxLabelLength}"
- IsCurrentTextValid="{Binding IsCurrentTextValid, Mode=OneWayToSource}" />
- </DockPanel>
+
</DockPanel>
</c:ContentArea>
</UserControl>

use the label entry dialog