Simplify tag add
MODIFY
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
WalletWasabi.Fluent/Controls/TagsBox.axaml.cs
@@ -26,9 +26,6 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<int> ItemCountLimitProperty =
AvaloniaProperty.Register<TagsBox, int>(nameof(ItemCountLimit));
- public static readonly StyledProperty<object> SelectedTagProperty =
- AvaloniaProperty.Register<TagsBox, object>(nameof(SelectedTag), defaultBindingMode: BindingMode.TwoWay);
-
public static readonly StyledProperty<char> TagSeparatorProperty =
AvaloniaProperty.Register<TagsBox, char>(nameof(TagSeparator), defaultValue: ' ');
@@ -76,12 +73,6 @@ namespace WalletWasabi.Fluent.Controls
set => SetValue(RestrictInputToSuggestionsProperty, value);
}
- public object SelectedTag
- {
- get => GetValue(SelectedTagProperty);
- set => SetValue(SelectedTagProperty, value);
- }
-
public int ItemCountLimit
{
get => GetValue(ItemCountLimitProperty);
@@ -236,7 +227,7 @@ namespace WalletWasabi.Fluent.Controls
return;
}
- SelectTag(currentText);
+ AddTag(currentText);
BackspaceLogicClear();
autoCompleteBox.ClearValue(AutoCompleteBox.SelectedItemProperty);
@@ -279,7 +270,7 @@ namespace WalletWasabi.Fluent.Controls
{
if (!RestrictInputToSuggestions)
{
- SelectTag(tag);
+ AddTag(tag);
continue;
}
@@ -289,7 +280,7 @@ namespace WalletWasabi.Fluent.Controls
if (keywordIsInSuggestions)
{
- SelectTag(tag);
+ AddTag(tag);
}
}
@@ -306,7 +297,7 @@ namespace WalletWasabi.Fluent.Controls
return;
}
- SelectTag(currentText);
+ AddTag(currentText);
BackspaceLogicClear();
@@ -333,20 +324,23 @@ namespace WalletWasabi.Fluent.Controls
RemoveTag();
break;
case Key.Enter when _isInputEnabled && !string.IsNullOrEmpty(currentText):
- if (RestrictInputToSuggestions &&
- Suggestions is { } &&
+ // Reject entry of the tag when user pressed enter and
+ // the input tag is not on the suggestions list.
+ if (RestrictInputToSuggestions && Suggestions is { } &&
!Suggestions.Cast<string>().Any(
x => x.Equals(currentText, StringComparison.InvariantCultureIgnoreCase)))
{
+
break;
}
BackspaceLogicClear();
- SelectTag(currentText);
+ AddTag(currentText);
ExecuteCompletedCommand();
Dispatcher.UIThread.Post(() => autoCompleteBox.ClearValue(AutoCompleteBox.TextProperty));
break;
+
case Key.Enter:
ExecuteCompletedCommand();
break;
@@ -394,9 +388,13 @@ namespace WalletWasabi.Fluent.Controls
CheckIsInputEnabled();
}
- private void SelectTag(string tagString)
+ private void AddTag(string tag)
+ {
+ if (Items is IList x && x.Count + 1 <= ItemCountLimit)
{
- SelectedTag = tagString;
+ x.Add(tag);
+ }
+
CheckIsInputEnabled();
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
@@ -24,7 +24,6 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
[NavigationMetaData (Title = "Enter recovery words")]
public partial class RecoverWalletViewModel : RoutableViewModel
{
- [AutoNotify] private string? _selectedTag;
[AutoNotify] private IEnumerable<string>? _suggestions;
[AutoNotify] private Mnemonic? _currentMnemonics;
@@ -40,10 +39,6 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
.Select(x => x.Count == 12 ? new Mnemonic(GetTagsAsConcatString().ToLowerInvariant()) : default)
.Subscribe(x => CurrentMnemonics = x);
- this.WhenAnyValue(x => x.SelectedTag)
- .Where(x => !string.IsNullOrEmpty(x))
- .Subscribe(AddMnemonic);
-
this.WhenAnyValue(x => x.CurrentMnemonics)
.Subscribe(_ => this.RaisePropertyChanged(nameof(Mnemonics)));
@@ -147,16 +142,6 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
}
}
- private void AddMnemonic(string? tagString)
- {
- if (!string.IsNullOrWhiteSpace(tagString) && Mnemonics.Count + 1 <= 12)
- {
- Mnemonics.Add( tagString);
- }
-
- SelectedTag = string.Empty;
- }
-
private string GetTagsAsConcatString()
{
return string.Join(' ', Mnemonics);

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

Simplify tag add