simplify swap and highlight logic
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
@@ -53,23 +53,13 @@ public class LabelSelectionViewModel : ViewModelBase
}
}
- public void OnPointerOver(LabelViewModel labelViewModel, bool isPointerOver)
+ public void OnPointerOver(LabelViewModel labelViewModel)
{
- if (!isPointerOver)
- {
- foreach (LabelViewModel lvm in AllLabelViewModel)
- {
- lvm.IsHighlighted = false;
- }
-
- return;
- }
-
var affectedLabelViewModels = GetAssociatedLabels(labelViewModel);
foreach (var lvm in affectedLabelViewModels)
{
- lvm.IsHighlighted = isPointerOver;
+ lvm.Highlight(labelViewModel);
}
}
@@ -79,7 +69,7 @@ public class LabelSelectionViewModel : ViewModelBase
foreach (var lvm in affectedLabelViewModels)
{
- lvm.IsBlackListed = !lvm.IsBlackListed;
+ lvm.Swap();
}
OnSelectionChanged();

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelViewModel.cs
@@ -6,9 +6,13 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
public partial class LabelViewModel : ViewModelBase
{
- [AutoNotify] private bool _isBlackListed;
+ [AutoNotify(SetterModifier = AccessModifier.Private)]
+ private bool _isBlackListed;
+
+ [AutoNotify(SetterModifier = AccessModifier.Private)]
+ private bool _isHighlighted;
+
[AutoNotify] private bool _isPointerOver;
- [AutoNotify] private bool _isHighlighted;
[AutoNotify] private bool _mustHave;
public LabelViewModel(LabelSelectionViewModel owner, string label)
@@ -17,7 +21,8 @@ public partial class LabelViewModel : ViewModelBase
this.WhenAnyValue(x => x.IsPointerOver)
.Skip(1)
- .Subscribe(isPointerOver => owner.OnPointerOver(this, isPointerOver));
+ .Where(value => value == true)
+ .Subscribe(_ => owner.OnPointerOver(this));
ClickedCommand = ReactiveCommand.Create(() => owner.SwapLabel(this),
this.WhenAnyValue(x => x.MustHave, x => x.IsBlackListed).Select(x => x.Item2 || !x.Item1 && !x.Item2));
@@ -26,4 +31,14 @@ public partial class LabelViewModel : ViewModelBase
public string Value { get; }
public ICommand ClickedCommand { get; }
+
+ public void Swap() => IsBlackListed = !IsBlackListed;
+
+ public void Highlight(LabelViewModel labelViewModel)
+ {
+ labelViewModel
+ .WhenAnyValue(x => x.IsPointerOver)
+ .TakeUntil(value => value == false)
+ .Subscribe(value => IsHighlighted = value);
+ }
}

simplify swap and highlight logic