tweak animations + fix review comments
MODIFY
WalletWasabi.Fluent/Behaviors/NavBarSelectedIndicatorChildBehavior.cs
WalletWasabi.Fluent/Behaviors/NavBarSelectedIndicatorChildBehavior.cs
@@ -15,21 +15,26 @@ namespace WalletWasabi.Fluent.Behaviors
AvaloniaProperty.RegisterAttached<NavBarSelectedIndicatorChildBehavior, Control, Control>(
"NavBarItemParent");
- public static Control GetNavBarItemParent(Control element)
+ public static Control? GetNavBarItemParent(Control? element)
{
return element?.GetValue(NavBarItemParentProperty) ?? null;
}
- public static void SetNavBarItemParent(Control element, Control value)
+ public static void SetNavBarItemParent(Control? element, Control value)
{
element?.SetValue(NavBarItemParentProperty, value);
}
private void OnLoaded()
{
- var SharedState = NavBarSelectedIndicatorParentBehavior.GetParentState(AssociatedObject);
+ if (AssociatedObject is null)
+ {
+ return;
+ }
+
+ var sharedState = NavBarSelectedIndicatorParentBehavior.GetParentState(AssociatedObject);
- if (SharedState is null)
+ if (sharedState is null)
{
Detach();
return;
@@ -52,13 +57,13 @@ namespace WalletWasabi.Fluent.Behaviors
.DistinctUntilChanged()
.Where(x => x)
.ObserveOn(AvaloniaScheduler.Instance)
- .Subscribe(_ => { SharedState.AnimateIndicator(AssociatedObject); });
+ .Subscribe(_ => { sharedState.AnimateIndicatorAsync(AssociatedObject); });
AssociatedObject.Opacity = 0;
if (parent.Classes.Contains(":selected"))
{
- SharedState.SetActive(AssociatedObject);
+ sharedState.SetActive(AssociatedObject);
}
}

MODIFY
WalletWasabi.Fluent/Behaviors/NavBarSelectedIndicatorParentBehavior.cs
WalletWasabi.Fluent/Behaviors/NavBarSelectedIndicatorParentBehavior.cs
@@ -9,7 +9,7 @@ namespace WalletWasabi.Fluent.Behaviors
public static readonly AttachedProperty<NavBarSelectedIndicatorState> ParentStateProperty =
AvaloniaProperty.RegisterAttached<NavBarSelectedIndicatorParentBehavior, Control, NavBarSelectedIndicatorState>("ParentState", inherits: true);
- private readonly CompositeDisposable disposables = new();
+ private readonly CompositeDisposable _disposables = new();
public static NavBarSelectedIndicatorState GetParentState(Control element)
{
@@ -25,8 +25,8 @@ namespace WalletWasabi.Fluent.Behaviors
{
var sharedState = new NavBarSelectedIndicatorState();
SetParentState(AssociatedObject, sharedState);
- disposables.Add(sharedState);
- AssociatedObject.DetachedFromVisualTree += delegate { disposables.Dispose(); };
+ _disposables.Add(sharedState);
+ AssociatedObject.DetachedFromVisualTree += delegate { _disposables.Dispose(); };
}
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Behaviors/NavBarSelectedIndicatorState.cs
WalletWasabi.Fluent/Behaviors/NavBarSelectedIndicatorState.cs
@@ -15,13 +15,12 @@ namespace WalletWasabi.Fluent.Behaviors
{
private readonly Easing _bckEasing = new SplineEasing(0.2, 1, 0.1, 0.9);
private readonly Easing _fwdEasing = new SplineEasing(0.1, 0.9, 0.2);
- private readonly TimeSpan _totalDuration = TimeSpan.FromSeconds(0.6);
+ private readonly TimeSpan _totalDuration = TimeSpan.FromSeconds(0.4);
private CancellationTokenSource _currentAnimationCts = new();
private Rectangle _activeIndicator;
private bool _isDisposed;
- private bool _initialFixDone;
private bool _previousAnimationOngoing;
// This will be used in the future for horizontal selection indicators.
@@ -39,7 +38,6 @@ namespace WalletWasabi.Fluent.Behaviors
var identity = Matrix.Identity;
while (visual != ancestor)
{
- var num = 0;
var bounds = visual.Bounds;
var topLeft = bounds.TopLeft;
@@ -59,19 +57,18 @@ namespace WalletWasabi.Fluent.Behaviors
return identity;
}
- public async void AnimateIndicator(Rectangle next)
+ public async void AnimateIndicatorAsync(Rectangle next)
{
if (_isDisposed)
{
return;
}
- var haveValidAnimation = false;
var prevIndicator = _activeIndicator;
var nextIndicator = next;
// user clicked twice
- if (prevIndicator == nextIndicator)
+ if (prevIndicator.Equals(nextIndicator))
{
return;
}
@@ -132,7 +129,7 @@ namespace WalletWasabi.Fluent.Behaviors
Cue = new Cue(0.33333d),
Setters =
{
- new Setter(ScaleTransform.ScaleYProperty, maxScale)
+ new Setter(ScaleTransform.ScaleYProperty, maxScale * 0.5d)
}
},
new KeyFrame

tweak animations + fix review comments