Legal documents shows as a lock screen when user is required to accept the terms. Also displayed as a DocumentTab when user just wants to read them.
MODIFY
WalletWasabi.Gui/Controls/LockScreen/PinLockScreenViewModel.cs
WalletWasabi.Gui/Controls/LockScreen/PinLockScreenViewModel.cs
@@ -9,7 +9,7 @@ using WalletWasabi.Logging;
namespace WalletWasabi.Gui.Controls.LockScreen
{
- public class PinLockScreenViewModel : LockScreenViewModelBase
+ public class PinLockScreenViewModel : WasabiLockScreenViewModelBase
{
private string _pinInput;

MODIFY
WalletWasabi.Gui/Controls/LockScreen/SlideLockScreenViewModel.cs
WalletWasabi.Gui/Controls/LockScreen/SlideLockScreenViewModel.cs
namespace WalletWasabi.Gui.Controls.LockScreen
{
- public class SlideLockScreenViewModel : LockScreenViewModelBase
+ public class SlideLockScreenViewModel : WasabiLockScreenViewModelBase
{
public readonly double ThresholdPercent = 1 / 6d;

ADD
WalletWasabi.Gui/Controls/LockScreen/WasabiLockScreenViewModelBase.cs
+using ReactiveUI;
+using Splat;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+
+namespace WalletWasabi.Gui.Controls.LockScreen
+{
+ public abstract class WasabiLockScreenViewModelBase : LockScreenViewModelBase
+ {
+ public WasabiLockScreenViewModelBase()
+ {
+ var global = Locator.Current.GetService<Global>();
+
+ global.UiConfig
+ .WhenAnyValue(x => x.LockScreenActive)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .BindTo(this, y => y.IsLocked)
+ .DisposeWith(Disposables);
+
+ this.WhenAnyValue(x => x.IsLocked)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .BindTo(global.UiConfig, y => y.LockScreenActive)
+ .DisposeWith(Disposables);
+
+ IsLocked = global.UiConfig.LockScreenActive;
+ }
+ }
+}

MODIFY
WalletWasabi.Gui/Tabs/LegalDocumentsView.xaml
WalletWasabi.Gui/Tabs/LegalDocumentsView.xaml
xmlns:controls="clr-namespace:WalletWasabi.Gui.Controls;assembly=WalletWasabi.Gui"
xmlns:converters="clr-namespace:WalletWasabi.Gui.Converters;assembly=WalletWasabi.Gui"
x:Class="WalletWasabi.Gui.Tabs.LegalDocumentsView">
- <DockPanel LastChildFill="True">
+ <DockPanel LastChildFill="True" Background="{DynamicResource ThemeBackgroundBrush}">
<TextBlock IsVisible="{Binding EmptyContent}" Text="Text document is missing!" />
<DockPanel LastChildFill="True" IsVisible="{Binding !EmptyContent}">

MODIFY
WalletWasabi.Gui/Tabs/LegalDocumentsViewModel.cs
WalletWasabi.Gui/Tabs/LegalDocumentsViewModel.cs
-using System;
-using System.IO;
-using System.Reactive;
-using System.Reactive.Linq;
-using System.Reactive.Threading.Tasks;
using Avalonia;
-using Avalonia.Logging;
-using Avalonia.Platform;
+using AvalonStudio.Documents;
using AvalonStudio.Extensibility;
using AvalonStudio.Shell;
using ReactiveUI;
using Splat;
-using WalletWasabi.Gui.Models;
+using System;
+using System.IO;
+using System.Reactive;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+using System.Reactive.Threading.Tasks;
+using WalletWasabi.Gui.Controls.LockScreen;
using WalletWasabi.Gui.Helpers;
-using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Legal;
-using System.Reactive.Disposables;
-using System.Threading.Tasks;
namespace WalletWasabi.Gui.Tabs
{
- public class LegalDocumentsViewModel : WasabiDocumentTabViewModel
+ public class LegalDocumentsViewModel : LockScreenViewModelBase, IDocumentTabViewModel
{
private string _text;
private bool _emptyContent;
public LegalDocumentsViewModel(string content = null, LegalDocuments legalDoc = null)
- : base("Legal Documents")
{
FilePath = legalDoc?.FilePath;
Content = content;
@@ -38,7 +34,7 @@ namespace WalletWasabi.Gui.Tabs
IsAgreed = true;
await LegalDoc.ToFileAsync(Content);
Locator.Current.GetService<Global>().LegalDocuments = LegalDoc;
- OnClose();
+ base.IsLocked = false;
});
AgreeClicked
@@ -75,10 +71,33 @@ namespace WalletWasabi.Gui.Tabs
public LegalDocuments LegalDoc { get; }
public bool IsAgreed { get; set; }
+ public bool IsDirty { get; set; }
+
+ public string Title => "Legal Documents";
+
+ public bool OnClose()
+ {
+ Disposables?.Dispose();
+ IoC.Get<IShell>().RemoveDocument(this);
+ return true;
+ }
+
+ public void OnDeselected()
+ {
+ }
- public override void OnOpen(CompositeDisposable disposables)
+ public void OnOpen()
{
- base.OnOpen(disposables);
+ OnInitialize(Disposables);
+ }
+
+ public void OnSelected()
+ {
+ }
+
+ protected override void OnInitialize(CompositeDisposable disposables)
+ {
+ base.OnInitialize(disposables);
if (!string.IsNullOrWhiteSpace(Content))
{
@@ -96,14 +115,5 @@ namespace WalletWasabi.Gui.Tabs
.DisposeWith(disposables);
}
}
-
- public override bool OnClose()
- {
- if (!IsAgreed)
- {
- return false;
- }
- return base.OnClose();
- }
}
}

MODIFY
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
@@ -91,8 +91,6 @@ namespace WalletWasabi.Gui.ViewModels
set => this.RaiseAndSetIfChanged(ref _lockScreen, value);
}
- public ReactiveCommand<Unit, Unit> LockScreenCommand { get; }
-
public IShell Shell { get; }
public static MainWindowViewModel Instance { get; internal set; }
@@ -120,7 +118,7 @@ namespace WalletWasabi.Gui.ViewModels
LockScreen?.Dispose();
LockScreen = uiConfig.LockScreenPinHash.Length == 0
- ? (LockScreenViewModelBase)new SlideLockScreenViewModel()
+ ? (WasabiLockScreenViewModelBase)new SlideLockScreenViewModel()
: new PinLockScreenViewModel();
});
}

MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -269,8 +269,8 @@ namespace WalletWasabi.Gui.ViewModels
var filePath = Path.Combine(legalFolderPath, $"{version}.txt");
var legalContent = await client.GetLegalDocumentsAsync(CancellationToken.None);
- IoC.Get<IShell>().Documents.OfType<LegalDocumentsViewModel>()?.FirstOrDefault()?.OnClose();
- IoC.Get<IShell>().AddOrSelectDocument(() => new LegalDocumentsViewModel(legalContent, new LegalDocuments(filePath)));
+ MainWindowViewModel.Instance.LockScreen = new LegalDocumentsViewModel(legalContent, new LegalDocuments(filePath));
+ MainWindowViewModel.Instance.LockScreen.IsLocked = true;
}
}
catch (Exception ex)

MODIFY
WalletWasabi.Gui/ViewModels/WasabiDocumentTabViewModel.cs
WalletWasabi.Gui/ViewModels/WasabiDocumentTabViewModel.cs
@@ -68,12 +68,9 @@ namespace WalletWasabi.Gui.ViewModels
public bool IsDirty { get; set; }
public virtual void OnSelected()
- {
- if (!LegalBarrier())
{
IsSelected = true;
}
- }
public virtual void OnDeselected()
{
@@ -140,22 +137,5 @@ namespace WalletWasabi.Gui.ViewModels
}
return DialogResult;
}
-
- /// <returns>True if barrier is active.</returns>
- private bool LegalBarrier()
- {
- // If legal docs not accepted then make sure it's selected.
- if (!(this is LegalDocumentsViewModel))
- {
- var foundLegalTab = IoC.Get<IShell>().Documents.OfType<LegalDocumentsViewModel>().FirstOrDefault();
- if (foundLegalTab is { } && !foundLegalTab.IsAgreed)
- {
- IoC.Get<IShell>().Select(foundLegalTab);
- return true;
- }
- }
-
- return false;
- }
}
}

Legal documents shows as a lock screen when user is required to accept the terms. Also displayed as a DocumentTab when user just wants to read them.