Basic infra for shuttling changes from UiConfig to Screen locks is done.
MODIFY
WalletWasabi.Gui/Controls/LockScreen/LockScreen.xaml
WalletWasabi.Gui/Controls/LockScreen/LockScreen.xaml
xmlns:lockscreen="clr-namespace:WalletWasabi.Gui.Controls.LockScreen;assembly=WalletWasabi.Gui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ActiveLockScreenType="{Binding ActiveLockScreen}"
- IsLocked="{Binding IsLocked}">
+ IsLocked="{Binding IsLocked, Mode=TwoWay}">
<ContentControl x:Name="LockScreenHost"/>
</lockscreen:LockScreen>
\ No newline at end of file

MODIFY
WalletWasabi.Gui/Controls/LockScreen/LockScreenImpl.cs
WalletWasabi.Gui/Controls/LockScreen/LockScreenImpl.cs
@@ -7,16 +7,44 @@ namespace WalletWasabi.Gui.Controls.LockScreen
{
public abstract class LockScreenImpl : UserControl
{
- private bool _isLocked;
+ private bool _isLocked, _currentState;
public static readonly DirectProperty<LockScreenImpl, bool> IsLockedProperty =
AvaloniaProperty.RegisterDirect<LockScreenImpl, bool>(nameof(IsLocked),
o => o.IsLocked,
(o, v) => o.IsLocked = v);
+
+ public LockScreenImpl()
+ {
+ this.WhenAnyValue(x => x.IsLocked)
+ .Subscribe(IsLockedChanged);
+ }
+
+ private void IsLockedChanged(bool isLocked)
+ {
+ if (isLocked == _currentState) return;
+
+ _currentState = isLocked;
+
+ if (isLocked)
+ {
+ this.IsHitTestVisible = true;
+ DoLock();
+ }
+ else
+ {
+ this.IsHitTestVisible = false;
+ DoUnlock();
+ }
+ }
+
public bool IsLocked
{
get => _isLocked;
set => SetAndRaise(IsLockedProperty, ref _isLocked, value);
}
+
+ public abstract void DoLock();
+ public abstract void DoUnlock();
}
}

MODIFY
WalletWasabi.Gui/Controls/LockScreen/SimpleLock.xaml.cs
WalletWasabi.Gui/Controls/LockScreen/SimpleLock.xaml.cs
@@ -11,7 +11,7 @@ using Avalonia.Interactivity;
namespace WalletWasabi.Gui.Controls.LockScreen
{
- internal class SimpleLock : LockScreenImpl
+ public class SimpleLock : LockScreenImpl
{
public Grid Shade { get; }
@@ -24,32 +24,6 @@ namespace WalletWasabi.Gui.Controls.LockScreen
unlockButton.Click += unlockButton_Clicked;
- this.WhenAnyValue(x => x.IsLocked)
- .Subscribe(IsLockedChanged);
- }
-
- private void IsLockedChanged(bool isLocked)
- {
- if (isLocked)
- {
- if (Shade.Classes.Contains("Locked"))
- return;
-
- Shade.Classes.Add("Locked");
- Shade.Classes.Remove("Unlocked");
-
- this.IsHitTestVisible = true;
- }
- else
- {
- if (Shade.Classes.Contains("Unlocked"))
- return;
-
- Shade.Classes.Add("Unlocked");
- Shade.Classes.Remove("Locked");
-
- this.IsHitTestVisible = false;
- }
}
private void unlockButton_Clicked(object sender, RoutedEventArgs e)
@@ -62,5 +36,17 @@ namespace WalletWasabi.Gui.Controls.LockScreen
AvaloniaXamlLoader.Load(this);
}
+ public override void DoLock()
+ {
+
+ Shade.Classes.Add("Locked");
+ Shade.Classes.Remove("Unlocked");
+ }
+
+ public override void DoUnlock()
+ {
+ Shade.Classes.Add("Unlocked");
+ Shade.Classes.Remove("Locked");
+ }
}
}

MODIFY
WalletWasabi.Gui/Controls/LockScreen/SlideLock.xaml.cs
WalletWasabi.Gui/Controls/LockScreen/SlideLock.xaml.cs
@@ -107,5 +107,14 @@ namespace WalletWasabi.Gui.Controls.LockScreen
AvaloniaXamlLoader.Load(this);
}
+ public override void DoLock()
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void DoUnlock()
+ {
+ throw new NotImplementedException();
+ }
}
}

MODIFY
WalletWasabi.Gui/ViewModels/LockScreenViewModel.cs
WalletWasabi.Gui/ViewModels/LockScreenViewModel.cs
@@ -2,6 +2,8 @@ using ReactiveUI;
using System.Reactive.Disposables;
using WalletWasabi.Gui.Models;
+using System;
+
namespace WalletWasabi.Gui.ViewModels
{
public class LockScreenViewModel : ViewModelBase

Basic infra for shuttling changes from UiConfig to Screen locks is done.