LockScreen DataContext will not be cleared or changed until lockscreen animation has completed.
MODIFY
WalletWasabi.Gui/Controls/LockScreen/LockScreen.xaml
WalletWasabi.Gui/Controls/LockScreen/LockScreen.xaml
xmlns:cont="clr-namespace:WalletWasabi.Gui.Controls.LockScreen"
xmlns:shell="clr-namespace:AvalonStudio.Controls;assembly=AvalonStudio.Shell.Extensibility"
x:Class="WalletWasabi.Gui.Controls.LockScreen.LockScreen">
- <cont:SlideLock IsLocked="{Binding IsLocked, Mode=TwoWay}" CanSlide="{Binding CanSlide}">
+ <cont:SlideLock IsAnimating="{Binding IsAnimating, Mode=TwoWay}" IsLocked="{Binding IsLocked, Mode=TwoWay}" CanSlide="{Binding CanSlide}">
<shell:ViewModelViewHost />
</cont:SlideLock>
</UserControl>

MODIFY
WalletWasabi.Gui/Controls/LockScreen/LockScreenViewModelBase.cs
WalletWasabi.Gui/Controls/LockScreen/LockScreenViewModelBase.cs
@@ -8,6 +8,7 @@ namespace WalletWasabi.Gui.Controls.LockScreen
{
public abstract class LockScreenViewModelBase : ViewModelBase
{
+ private bool _isAnimating;
private bool _isLocked;
private bool _canSlide;
private volatile bool _disposedValue = false; // To detect redundant calls
@@ -17,11 +18,6 @@ namespace WalletWasabi.Gui.Controls.LockScreen
_isLocked = true;
Disposables = new CompositeDisposable();
-
- this.WhenAnyValue(x => x.IsLocked)
- .Where(x => !x)
- .Take(1)
- .Subscribe(x => Close());
}
protected CompositeDisposable Disposables { get; }
@@ -38,10 +34,10 @@ namespace WalletWasabi.Gui.Controls.LockScreen
set => this.RaiseAndSetIfChanged(ref _isLocked, value);
}
- protected void Close()
+ public bool IsAnimating
{
- IsLocked = false;
- MainWindowViewModel.Instance?.CloseLockScreen(this);
+ get { return _isAnimating; }
+ set { this.RaiseAndSetIfChanged(ref _isAnimating, value); }
}
public void Initialize()
@@ -53,6 +49,16 @@ namespace WalletWasabi.Gui.Controls.LockScreen
{
}
+ protected void Close()
+ {
+ IsLocked = false;
+
+ this.WhenAnyValue(x => x.IsAnimating)
+ .Where(x => !x)
+ .Take(1)
+ .Subscribe(x => MainWindowViewModel.Instance?.CloseLockScreen(this));
+ }
+
#region IDisposable Support
protected virtual void Dispose(bool disposing)

MODIFY
WalletWasabi.Gui/Controls/LockScreen/SlideLock.cs
WalletWasabi.Gui/Controls/LockScreen/SlideLock.cs
@@ -7,6 +7,7 @@ using Avalonia.Input;
using Avalonia.Styling;
using Avalonia.Utilities;
using System;
+using System.Threading.Tasks;
namespace WalletWasabi.Gui.Controls.LockScreen
{
@@ -15,6 +16,7 @@ namespace WalletWasabi.Gui.Controls.LockScreen
private Thumb _thumb;
private Grid _container;
private bool _isLocked;
+ private bool _isAnimating;
private Animation _closeAnimation;
private Animation _openAnimation;
private bool _canSlide;
@@ -75,7 +77,21 @@ namespace WalletWasabi.Gui.Controls.LockScreen
};
this.GetObservable(IsLockedProperty)
- .Subscribe(async isLocked => await (isLocked ? _closeAnimation.RunAsync(this) : _openAnimation.RunAsync(this)));
+ .Subscribe(async isLocked => await (isLocked ? RunCloseAnimationAsync() : RunOpenAnimationAsync()));
+ }
+
+ public async Task RunCloseAnimationAsync ()
+ {
+ IsAnimating = true;
+ await _closeAnimation.RunAsync(this);
+ IsAnimating = false;
+ }
+
+ public async Task RunOpenAnimationAsync()
+ {
+ IsAnimating = true;
+ await _openAnimation.RunAsync(this);
+ IsAnimating = false;
}
public static readonly DirectProperty<SlideLock, bool> CanSlideProperty =
@@ -105,6 +121,15 @@ namespace WalletWasabi.Gui.Controls.LockScreen
set => SetAndRaise(IsLockedProperty, ref _isLocked, value);
}
+ public static readonly DirectProperty<SlideLock, bool> IsAnimatingProperty =
+ AvaloniaProperty.RegisterDirect<SlideLock, bool>(nameof(IsAnimating), o => o.IsAnimating, (o, v) => o.IsAnimating = v);
+
+ public bool IsAnimating
+ {
+ get => _isAnimating;
+ set => SetAndRaise(IsAnimatingProperty, ref _isAnimating, value);
+ }
+
public static readonly StyledProperty<double> ValueProperty =
AvaloniaProperty.Register<SlideLock, double>(nameof(Value));
@@ -138,18 +163,18 @@ namespace WalletWasabi.Gui.Controls.LockScreen
_thumb.DragCompleted += OnThumb_DragCompleted;
}
- private void OnThumb_DragCompleted(object sender, VectorEventArgs e)
+ private async void OnThumb_DragCompleted(object sender, VectorEventArgs e)
{
if (CanSlide)
{
if (Value <= Threshold)
{
IsLocked = false;
- _openAnimation.RunAsync(this);
+ await RunOpenAnimationAsync();
}
else
{
- _closeAnimation.RunAsync(this);
+ await RunCloseAnimationAsync();
}
}
}

MODIFY
WalletWasabi.Gui/Controls/LockScreen/SlideLockScreenViewModel.cs
WalletWasabi.Gui/Controls/LockScreen/SlideLockScreenViewModel.cs
+using System;
+using ReactiveUI;
+using System.Reactive.Linq;
+
namespace WalletWasabi.Gui.Controls.LockScreen
{
public class SlideLockScreenViewModel : WasabiLockScreenViewModelBase
@@ -7,6 +11,11 @@ namespace WalletWasabi.Gui.Controls.LockScreen
public SlideLockScreenViewModel()
{
CanSlide = true;
+
+ this.WhenAnyValue(x => x.IsLocked)
+ .Where(x => !x)
+ .Take(1)
+ .Subscribe(x => Close());
}
}
}

LockScreen DataContext will not be cleared or changed until lockscreen animation has completed.