add selecteditem prop
MODIFY
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
@@ -25,6 +25,9 @@ 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 DirectProperty<TagsBox, IEnumerable> SuggestionsProperty =
AvaloniaProperty.RegisterDirect<TagsBox, IEnumerable>(
nameof(Suggestions),
@@ -35,12 +38,10 @@ namespace WalletWasabi.Fluent.Controls
private bool _backspaceEmptyField1;
private bool _backspaceEmptyField2;
-
-
private IDisposable? _disposable;
private bool _isInputEnabled = true;
- private IEnumerable _suggestionsEnumerable;
+ private IEnumerable _suggestions;
private bool _isFocused;
public bool RestrictInputToSuggestions
@@ -49,6 +50,12 @@ namespace WalletWasabi.Fluent.Controls
set => SetValue(RestrictInputToSuggestionsProperty, value);
}
+ public object SelectedTag
+ {
+ get => GetValue(SelectedTagProperty);
+ set => SetValue(SelectedTagProperty, value);
+ }
+
public int ItemCountLimit
{
get => GetValue(ItemCountLimitProperty);
@@ -57,8 +64,8 @@ namespace WalletWasabi.Fluent.Controls
public IEnumerable Suggestions
{
- get => _suggestionsEnumerable;
- set => SetAndRaise(SuggestionsProperty, ref _suggestionsEnumerable, value);
+ get => _suggestions;
+ set => SetAndRaise(SuggestionsProperty, ref _suggestions, value);
}
private void CheckIsInputEnabled()
@@ -295,8 +302,8 @@ namespace WalletWasabi.Fluent.Controls
private void AddTag(string strTrimmed)
{
+ SelectedTag = strTrimmed;
CheckIsInputEnabled();
- if (Items is IList x) x.Add(strTrimmed);
}
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/RecoverWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/RecoverWalletPageViewModel.cs
+using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
@@ -22,6 +23,7 @@ namespace WalletWasabi.Fluent.ViewModels
private IEnumerable _suggestions;
private int _itemCountLimit;
private bool _restrictInputToSuggestions;
+ private object _selectedTag;
public ObservableCollection<string> Mnemonics
{
@@ -47,6 +49,12 @@ namespace WalletWasabi.Fluent.ViewModels
set => this.RaiseAndSetIfChanged(ref _restrictInputToSuggestions, value);
}
+ public object? SelectedTag
+ {
+ get => _selectedTag;
+ set => this.RaiseAndSetIfChanged(ref _selectedTag, value);
+ }
+
public RecoveryPageViewModel(IScreen screen) : base(screen)
{
Global = Locator.Current.GetService<Global>();
@@ -67,12 +75,23 @@ namespace WalletWasabi.Fluent.ViewModels
.Select(x => x?.WordList?.WordCount == 12 && (x?.IsValidChecksum ?? false))
.ToProperty(this, x => x.IsMnemonicValid);
+ this.WhenAnyValue(x => x.SelectedTag)
+ .Where(x => x is string s && !string.IsNullOrEmpty(s))
+ .Select(x => x as string)
+ .Subscribe(AddTag);
+
this.ValidateProperty(x => x.Mnemonics, ValidateMnemonics);
// A hack for validations system...
Mnemonics.CollectionChanged += MnemonicsChanged;
}
+ public void AddTag(string tagString)
+ {
+ Mnemonics.Add(tagString);
+ SelectedTag = null;
+ }
+
// ugly hack
private void MnemonicsChanged(object sender, NotifyCollectionChangedEventArgs e)
{

MODIFY
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
<c:ContentArea Title="Enter recovery words" Caption="Type in your 12 recovery words and click continue"
x:DataType="vm:RecoveryPageViewModel"
Margin="44 0">
- <Grid RowDefinitions="Auto,20,Auto" VerticalAlignment="Top">
+ <StackPanel>
<Label Classes="h7 bold" Content="_Type in your recovery words here:" Target="seedTagsBox" />
<c:TagsBox x:Name="seedTagsBox"
Grid.Row="2"
ItemCountLimit="{CompiledBinding ItemCountLimit}"
RestrictInputToSuggestions="{CompiledBinding RestrictInputToSuggestions}"
Items="{CompiledBinding Mnemonics}"
- Suggestions="{CompiledBinding Suggestions}" />
- </Grid>
+ Suggestions="{CompiledBinding Suggestions}"
+ SelectedTag="{CompiledBinding SelectedTag}"/>
+ </StackPanel>
</c:ContentArea>
<Button Content="Cancel" Command="{Binding CancelCommand}" Classes="invisible" HorizontalAlignment="Left"
VerticalAlignment="Bottom" />

add selecteditem prop