Add tag removal in TagsBox
MODIFY
WalletWasabi.Fluent/Controls/TagsBox.axaml
WalletWasabi.Fluent/Controls/TagsBox.axaml
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:c="using:WalletWasabi.Fluent.Controls">
+ xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls;assembly=WalletWasabi.Fluent">
<Style Selector="c|TagsBox">
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
</DataValidationErrors>
</ControlTemplate>
</Setter>
- </Style>
-
- <Style Selector="c|TagsBox">
<Setter Property="(ScrollViewer.HorizontalScrollBarVisibility)" Value="Disabled" />
<Setter Property="ItemTemplate">
<DataTemplate>
<Panel>
- <Border BorderBrush="{DynamicResource TagsBoxControlForeground}"
+ <Panel.Styles>
+ <Style Selector="Panel#PART_TagPanel Panel#PART_DeleteTagButton" >
+ <Setter Property="Opacity" Value="0" />
+ <Setter Property="RenderTransform" Value="scale(0.8)" />
+ </Style>
+ <Style Selector="Panel#PART_TagPanel:pointerover Panel#PART_DeleteTagButton" >
+ <Setter Property="Opacity" Value="1" />
+ <Setter Property="RenderTransform" Value="scale(1)" />
+ </Style>
+ </Panel.Styles>
+ <Panel Name="PART_TagPanel">
+ <Border Name="PART_TagItemBorder"
+ Background="Transparent"
+ BorderBrush="{DynamicResource TagsBoxControlForeground}"
BorderThickness="1"
CornerRadius="4"
Margin="4"
VerticalAlignment="Center"
Margin="10,8,10,0" />
</Panel>
+ <Panel
+ Name="PART_DeleteTagButton"
+ Width="13"
+ Height="13"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Right">
+ <Panel.Transitions>
+ <Transitions>
+ <DoubleTransition Property="Opacity" Duration="0:0:0.175" />
+ <TransformOperationsTransition Property="RenderTransform" Duration="0:0:.135" Easing="QuadraticEaseIn" />
+ </Transitions>
+ </Panel.Transitions>
+ <Ellipse Fill="Red"/>
+ <Button Classes="" Command="{Binding $parent[c:TagsBox].DeleteTagCommand}" CommandParameter="{Binding }">Test</Button>
+ </Panel>
+ </Panel>
</Panel>
</DataTemplate>
</Setter>

MODIFY
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
+using System.Reactive;
using System.Reactive.Disposables;
using System.Windows.Input;
using Avalonia;
@@ -12,6 +13,7 @@ using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Threading;
+using ReactiveUI;
namespace WalletWasabi.Fluent.Controls
{
@@ -42,6 +44,7 @@ namespace WalletWasabi.Fluent.Controls
private bool _isInputEnabled = true;
private IEnumerable? _suggestions;
private ICommand? _completedCommand;
+ private ReactiveCommand<object, Unit>? _deleteTagCommand;
public static readonly DirectProperty<TagsBox, ICommand?> CompletedCommandProperty =
AvaloniaProperty.RegisterDirect<TagsBox, ICommand?>(
@@ -49,6 +52,12 @@ namespace WalletWasabi.Fluent.Controls
o => o.CompletedCommand,
(o, v) => o.CompletedCommand = v);
+ public static readonly DirectProperty<TagsBox, ReactiveCommand<object, Unit>?> DeleteTagCommandProperty =
+ AvaloniaProperty.RegisterDirect<TagsBox, ReactiveCommand<object, Unit>?>(
+ nameof(DeleteTagCommand),
+ o => o.DeleteTagCommand,
+ (o, v) => o.DeleteTagCommand = v);
+
static TagsBox()
{
ItemsProperty.OverrideMetadata<TagsBox>(
@@ -85,6 +94,12 @@ namespace WalletWasabi.Fluent.Controls
set => SetAndRaise(CompletedCommandProperty, ref _completedCommand, value);
}
+ public ReactiveCommand<object, Unit>? DeleteTagCommand
+ {
+ get => _deleteTagCommand;
+ set => SetAndRaise(DeleteTagCommandProperty, ref _deleteTagCommand, value);
+ }
+
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Linq;
+using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
@@ -24,6 +26,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
[AutoNotify] private string? _selectedTag;
[AutoNotify] private IEnumerable<string>? _suggestions;
[AutoNotify] private Mnemonic? _currentMnemonics;
+ [AutoNotify] private ReactiveCommand<object, Unit>? _deleteSuggestionCommand;
public RecoverWalletViewModel(
string walletName,
@@ -75,6 +78,14 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
});
EnableAutoBusyOn(NextCommand);
+
+ DeleteSuggestionCommand = ReactiveCommand.Create<object>((del) =>
+ {
+ if (del is RecoveryWordIndexed word)
+ {
+ Mnemonics.RemoveAt(Mnemonics.IndexOf(word));
+ }
+ });
}
private async Task OnNext(
@@ -135,7 +146,8 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
private Interaction<(KeyPath, int), (KeyPath?, int?)> AdvancedOptionsInteraction { get; }
- public ObservableCollection<string> Mnemonics { get; } = new ObservableCollection<string>();
+ public ObservableCollection<RecoveryWordIndexed> Mnemonics { get; } =
+ new ObservableCollection<RecoveryWordIndexed>();
private void ValidateMnemonics(IValidationErrors errors)
{
@@ -149,7 +161,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
{
if (!string.IsNullOrWhiteSpace(tagString) && Mnemonics.Count + 1 <= 12)
{
- Mnemonics.Add(tagString);
+ Mnemonics.Add(new RecoveryWordIndexed(Mnemonics.Count + 1, tagString));
}
SelectedTag = string.Empty;

ADD
WalletWasabi.Fluent/ViewModels/AddWallet/RecoveryWordIndexed.cs
+namespace WalletWasabi.Fluent.ViewModels.AddWallet
+{
+ public readonly struct RecoveryWordIndexed
+ {
+ public RecoveryWordIndexed(int index, string word)
+ {
+ Index = index;
+ Word = word;
+ }
+
+ public int Index { get; }
+ public string Word { get; }
+
+ public override string ToString()
+ {
+ return Word;
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/AddWallet/RecoverWalletView.axaml
WalletWasabi.Fluent/Views/AddWallet/RecoverWalletView.axaml
RestrictInputToSuggestions="True"
Items="{Binding Mnemonics}"
Suggestions="{Binding Suggestions}"
+ DeleteTagCommand="{Binding DeleteSuggestionCommand}"
SelectedTag="{Binding SelectedTag}"
CompletedCommand="{Binding NextCommand}">
<i:Interaction.Behaviors>

Add tag removal in TagsBox