rename stuff appropriately and add optoin to e/d input restriction
MODIFY
WalletWasabi.Fluent/App.xaml
WalletWasabi.Fluent/App.xaml
<StyleInclude Source="avares://WalletWasabi.Fluent/Styles/Styles.xaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/ContentArea.axaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/Dialog.xaml" />
- <StyleInclude Source="avares://WalletWasabi.Fluent/Controls/TagBox.xaml" />
+ <StyleInclude Source="avares://WalletWasabi.Fluent/Controls/TagsBox.xaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/NavBarItem.xaml" />
<StyleInclude Source="avares://WalletWasabi.Fluent/Controls/NavBarTreeItem.xaml" />
</Application.Styles>

MODIFY
WalletWasabi.Fluent/Behaviors/SplitViewAutoBehavior.cs
WalletWasabi.Fluent/Behaviors/SplitViewAutoBehavior.cs
@@ -12,7 +12,7 @@ namespace WalletWasabi.Fluent.Behaviors
{
private bool _sidebarWasForceClosed;
- private CompositeDisposable Disposables { get; set; }
+ private CompositeDisposable? Disposables { get; set; }
public static readonly StyledProperty<double> CollapseThresholdProperty =
AvaloniaProperty.Register<SplitViewAutoBehavior, double>(nameof(CollapseThreshold));

RENAME
WalletWasabi.Fluent/Behaviors/TagBoxAutoCompleteBoxBehavior.cs
WalletWasabi.Fluent/Behaviors/TagsBoxAutoCompleteBoxBehavior.cs
@@ -11,22 +11,31 @@ using Avalonia.Xaml.Interactivity;
namespace WalletWasabi.Fluent.Behaviors
{
- public class TagBoxAutoCompleteBoxBehavior : Behavior<AutoCompleteBox>
+ public class TagsBoxAutoCompleteBoxBehavior : Behavior<AutoCompleteBox>
{
+ public static readonly StyledProperty<bool> RestrictInputToSuggestionsProperty =
+ AvaloniaProperty.Register<TagsBoxAutoCompleteBoxBehavior, bool>(nameof(RestrictInputToSuggestions));
+
public static readonly StyledProperty<IEnumerable<string>> SuggestionsProperty =
- AvaloniaProperty.Register<SplitViewAutoBehavior, IEnumerable<string>>(nameof(Suggestions));
+ AvaloniaProperty.Register<TagsBoxAutoCompleteBoxBehavior, IEnumerable<string>>(nameof(Suggestions));
public static readonly StyledProperty<Action<string>> CommitTextActionProperty =
- AvaloniaProperty.Register<SplitViewAutoBehavior, Action<string>>(nameof(CommitTextAction));
+ AvaloniaProperty.Register<TagsBoxAutoCompleteBoxBehavior, Action<string>>(nameof(CommitTextAction));
public static readonly StyledProperty<Action> BackspaceAndEmptyTextActionProperty =
- AvaloniaProperty.Register<SplitViewAutoBehavior, Action>(nameof(BackspaceAndEmptyTextAction));
+ AvaloniaProperty.Register<TagsBoxAutoCompleteBoxBehavior, Action>(nameof(BackspaceAndEmptyTextAction));
private IDisposable? _disposable;
private bool _bs1;
private bool _bs2;
+ public bool RestrictInputToSuggestions
+ {
+ get => GetValue(RestrictInputToSuggestionsProperty);
+ set => SetValue(RestrictInputToSuggestionsProperty, value);
+ }
+
public IEnumerable<string> Suggestions
{
get => GetValue(SuggestionsProperty);
@@ -56,7 +65,6 @@ namespace WalletWasabi.Fluent.Behaviors
AssociatedObject.AddDisposableHandler(InputElement.TextInputEvent, OnTextInput,
RoutingStrategies.Tunnel);
-
Dispatcher.UIThread.InvokeAsync(() =>
{
// Refocus because the old control is destroyed
@@ -71,7 +79,7 @@ namespace WalletWasabi.Fluent.Behaviors
{
if (AssociatedObject is null) return;
- if (!Suggestions.Any(x =>
+ if (RestrictInputToSuggestions && !Suggestions.Any(x =>
x.StartsWith(AssociatedObject.SearchText ?? "", true, CultureInfo.CurrentCulture)))
e.Handled = true;
}
@@ -81,13 +89,14 @@ namespace WalletWasabi.Fluent.Behaviors
if (AssociatedObject is null) return;
var currentText = AssociatedObject.Text ?? "";
- var selItem = AssociatedObject.SelectedItem as string;
- if (currentText.Length == 0) return;
-
- if (selItem is null || selItem.Length == 0 || currentText != selItem) return;
+ if (currentText.Length == 0 || !(AssociatedObject.SelectedItem is string selItem) || selItem.Length == 0 ||
+ currentText != selItem)
+ {
+ return;
+ }
- CommitTextAction?.Invoke(currentText.Trim());
+ CommitTextAction.Invoke(currentText.Trim());
AssociatedObject.ClearValue(AutoCompleteBox.SelectedItemProperty);
BackspaceLogicClear();
@@ -109,8 +118,8 @@ namespace WalletWasabi.Fluent.Behaviors
var currentTextTrimmed = currentText.Trim();
if (currentText.Length < 1 || string.IsNullOrEmpty(currentTextTrimmed) || !currentText.EndsWith(' ') ||
- !Suggestions.Any(x => x.Equals(currentTextTrimmed,
- StringComparison.InvariantCultureIgnoreCase)))
+ (RestrictInputToSuggestions && !Suggestions.Any(x => x.Equals(currentTextTrimmed,
+ StringComparison.InvariantCultureIgnoreCase))))
return;
CommitTextAction?.Invoke(currentTextTrimmed);
@@ -138,7 +147,9 @@ namespace WalletWasabi.Fluent.Behaviors
BackspaceAndEmptyTextAction?.Invoke();
break;
case Key.Enter when !string.IsNullOrEmpty(strTrimmed):
- if (!Suggestions.Any(x => x.Equals(strTrimmed, StringComparison.InvariantCultureIgnoreCase))) break;
+ if (RestrictInputToSuggestions && !Suggestions.Any(x =>
+ x.Equals(strTrimmed, StringComparison.InvariantCultureIgnoreCase)))
+ break;
BackspaceLogicClear();

RENAME
WalletWasabi.Fluent/Controls/TagBox.xaml
WalletWasabi.Fluent/Controls/TagsBox.xaml
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
xmlns:vmt="clr-namespace:WalletWasabi.Fluent.ViewModels.TagsBox">
- <Style Selector="c|TagBox">
+ <Style Selector="c|TagsBox">
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
<Panel>
- <ItemsControl x:DataType="vmt:TagBoxViewModel"
+ <ItemsControl x:DataType="vmt:TagsBoxViewModel"
Items="{CompiledBinding CombinedContent}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
</Setter>
</Style>
- <Style Selector="c|TagBox:pointerover /template/ Border#PART_BorderElement">
+ <Style Selector="c|TagsBox:pointerover /template/ Border#PART_BorderElement">
<Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushPointerOver}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
</Style>
- <Style Selector="c|TagBox AutoCompleteBox">
+ <Style Selector="c|TagsBox AutoCompleteBox">
<Setter Property="Padding" Value="3,10,0, 10" />
<Setter Property="Margin" Value="0" />
</Style>
- <Style Selector="c|TagBox AutoCompleteBox /template/ TextBox /template/ Border#PART_BorderElement">
+ <Style Selector="c|TagsBox AutoCompleteBox /template/ TextBox /template/ Border#PART_BorderElement">
<Setter Property="IsVisible" Value="False" />
</Style>

RENAME
WalletWasabi.Fluent/Controls/TagBox.xaml.cs
WalletWasabi.Fluent/Controls/TagsBox.xaml.cs
@@ -4,7 +4,7 @@ namespace WalletWasabi.Fluent.Controls
{
/// <summary>
/// </summary>
- public class TagBox : ContentControl
+ public class TagsBox : ContentControl
{
}

MODIFY
WalletWasabi.Fluent/Styles/Themes/BaseDark.xaml
WalletWasabi.Fluent/Styles/Themes/BaseDark.xaml
<SolidColorBrush x:Key="DialogBackground">#323232</SolidColorBrush>
<BoxShadows x:Key="DialogBoxShadow">4 11 30 1 #3F000000</BoxShadows>
- <SolidColorBrush x:Key="TagBoxControlForeground">#2FFFFFFF</SolidColorBrush>
+ <SolidColorBrush x:Key="TagsBoxControlForeground">#2FFFFFFF</SolidColorBrush>
<Color x:Key="RegionColor">#FF212121</Color>
<BoxShadows x:Key="BoxShadow">0 1 4 #121212</BoxShadows>

MODIFY
WalletWasabi.Fluent/Styles/Themes/BaseLight.xaml
WalletWasabi.Fluent/Styles/Themes/BaseLight.xaml
<SolidColorBrush x:Key="DialogBackground">#FFFFFF</SolidColorBrush>
<BoxShadows x:Key="DialogBoxShadow">4 11 30 1 #3F000000</BoxShadows>
- <SolidColorBrush x:Key="TagBoxControlForeground">#2F000000</SolidColorBrush>
+ <SolidColorBrush x:Key="TagsBoxControlForeground">#2F000000</SolidColorBrush>
<Color x:Key="RegionColor">#FFFAFAFA</Color>
<BoxShadows x:Key="BoxShadow">0 1 4 #D1D1D1</BoxShadows>

MODIFY
WalletWasabi.Fluent/ViewModels/RecoverWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/RecoverWalletPageViewModel.cs
@@ -11,11 +11,12 @@ namespace WalletWasabi.Fluent.ViewModels
public RecoveryPageViewModel(IScreen screen) : base(screen)
{
Title = "Recovery";
- RecoveryWordsTagBox.Suggestions = new Mnemonic(Wordlist.English, WordCount.Twelve).WordList.GetWords();
+ RecoveryWordsTagsBox.Suggestions = new Mnemonic(Wordlist.English, WordCount.Twelve).WordList.GetWords();
+ RecoveryWordsTagsBox.RestrictInputToSuggestions = true;
}
public override string IconName => "home_regular";
- public TagBoxViewModel RecoveryWordsTagBox { get; } = new TagBoxViewModel();
+ public TagsBoxViewModel RecoveryWordsTagsBox { get; } = new TagsBoxViewModel();
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/TagsBox/TagInputViewModel.cs
WalletWasabi.Fluent/ViewModels/TagsBox/TagInputViewModel.cs
@@ -7,22 +7,30 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
{
public class TagInputViewModel : ViewModelBase
{
- private readonly TagBoxViewModel _parent;
+ private readonly TagsBoxViewModel _parent;
private readonly ObservableAsPropertyHelper<IEnumerable> _suggestions;
+ private readonly ObservableAsPropertyHelper<bool> _restrictInputToSuggestions;
+
private Action _backspaceAndEmptyTextAction;
private Action<string> _commitTextAction;
- public TagInputViewModel(TagBoxViewModel parent)
+ public TagInputViewModel(TagsBoxViewModel parent)
{
_parent = parent;
_suggestions = _parent.WhenAnyValue(x => x.Suggestions)
.ToProperty(this, x => x.Suggestions);
+ _restrictInputToSuggestions = _parent.WhenAnyValue(x => x.RestrictInputToSuggestions)
+ .ToProperty(this, x => x.RestrictInputToSuggestions);
+
CommitTextAction += OnCommitTextAction;
BackspaceAndEmptyTextAction += OnBackspaceAndEmptyTextAction;
}
public IEnumerable Suggestions => _suggestions.Value;
+ public bool RestrictInputToSuggestions => _restrictInputToSuggestions.Value;
+
+
public Action<string> CommitTextAction
{

MODIFY
WalletWasabi.Fluent/ViewModels/TagsBox/TagViewModel.cs
WalletWasabi.Fluent/ViewModels/TagsBox/TagViewModel.cs
@@ -5,11 +5,11 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
{
public class TagViewModel : ViewModelBase
{
- private readonly TagBoxViewModel _parent;
+ private readonly TagsBoxViewModel _parent;
private string _tag;
- public TagViewModel(TagBoxViewModel parent, string tag)
+ public TagViewModel(TagsBoxViewModel parent, string tag)
{
_parent = parent;
_tag = tag;

RENAME
WalletWasabi.Fluent/ViewModels/TagsBox/TagBoxViewModel.cs
WalletWasabi.Fluent/ViewModels/TagsBox/TagsBoxViewModel.cs
@@ -15,7 +15,7 @@ using DynamicData.Binding;
namespace WalletWasabi.Fluent.ViewModels.TagsBox
{
- public class TagBoxViewModel : ViewModelBase
+ public class TagsBoxViewModel : ViewModelBase
{
private readonly ReadOnlyObservableCollection<object> _combinedContent;
@@ -23,7 +23,9 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
private IEnumerable _suggestions;
private ObservableCollection<TagViewModel> _tags;
- public TagBoxViewModel()
+ private bool _restrictInputToSuggestions;
+
+ public TagsBoxViewModel()
{
_tags = new ObservableCollection<TagViewModel>();
@@ -46,6 +48,12 @@ namespace WalletWasabi.Fluent.ViewModels.TagsBox
public TagInputViewModel TagInput { get; }
+ public bool RestrictInputToSuggestions
+ {
+ get => _restrictInputToSuggestions;
+ set => this.RaiseAndSetIfChanged(ref _restrictInputToSuggestions, value);
+ }
+
public IEnumerable Suggestions
{
get => _suggestions;

MODIFY
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
</Button>
<c:ContentArea Title="Enter recovery words" Caption="Type in your 12 recovery words and click continue"
Margin="44 0">
- <Grid RowDefinitions="Auto,30,Auto" VerticalAlignment="Top" >
+ <Grid RowDefinitions="Auto,20,Auto" VerticalAlignment="Top" >
<TextBlock Classes="h7 bold" Text="Type in your recovery words here:"/>
- <c:TagBox Grid.Row="2"
- DataContext="{Binding RecoveryWordsTagBox}"
+ <c:TagsBox Grid.Row="2"
+ DataContext="{Binding RecoveryWordsTagsBox}"
MinHeight="60"
MaxHeight="120"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" />

MODIFY
WalletWasabi.Fluent/Views/TagsBox/TagInputView.xaml
WalletWasabi.Fluent/Views/TagsBox/TagInputView.xaml
x:Class="WalletWasabi.Fluent.Views.TagsBox.TagInputView">
<AutoCompleteBox x:DataType="vm:TagInputViewModel" IsTextCompletionEnabled="True" Items="{CompiledBinding Suggestions}">
<i:Interaction.Behaviors>
- <behaviors:TagBoxAutoCompleteBoxBehavior
+ <behaviors:TagsBoxAutoCompleteBoxBehavior
+ RestrictInputToSuggestions="{CompiledBinding RestrictInputToSuggestions}"
Suggestions="{CompiledBinding Suggestions}"
CommitTextAction="{CompiledBinding CommitTextAction}"
BackspaceAndEmptyTextAction="{CompiledBinding BackspaceAndEmptyTextAction}" />

MODIFY
WalletWasabi.Fluent/Views/TagsBox/TagView.xaml
WalletWasabi.Fluent/Views/TagsBox/TagView.xaml
mc:Ignorable="d"
x:Class="WalletWasabi.Fluent.Views.TagsBox.TagView">
<Panel>
- <Border BorderBrush="{DynamicResource TagBoxControlForeground}"
+ <Border BorderBrush="{DynamicResource TagsBoxControlForeground}"
BorderThickness="1"
CornerRadius="4"
Margin="4"

rename stuff appropriately and add optoin to e/d input restriction