rename to CreatePasswordDialog and add an EnterPasswordDialog.
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/AddWalletPageViewModel.cs
@@ -94,7 +94,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
async () =>
{
var dialogResult = await NavigateDialog(
- new EnterPasswordViewModel("Type the password of the wallet and click Continue."));
+ new CreatePasswordDialogViewModel("Type the password of the wallet and click Continue."));
if (dialogResult.Result is { } password)
{

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/RecoverWalletViewModel.cs
@@ -80,7 +80,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet
string? walletName)
{
var dialogResult = await NavigateDialog(
- new EnterPasswordViewModel(
+ new CreatePasswordDialogViewModel(
"Type the password of the wallet to be able to recover and click Continue."));
if (dialogResult.Result is { } password)

RENAME
WalletWasabi.Fluent/ViewModels/Dialogs/EnterPasswordViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/CreatePasswordDialogViewModel.cs
@@ -7,12 +7,12 @@ using WalletWasabi.Userfacing;
namespace WalletWasabi.Fluent.ViewModels.Dialogs
{
[NavigationMetaData(Title = "Enter a password")]
- public partial class EnterPasswordViewModel : DialogViewModelBase<string?>
+ public partial class CreatePasswordDialogViewModel : DialogViewModelBase<string?>
{
[AutoNotify] private string? _confirmPassword;
[AutoNotify] private string? _password;
- public EnterPasswordViewModel(string caption, bool enableEmpty = true)
+ public CreatePasswordDialogViewModel(string caption, bool enableEmpty = true)
{
Caption = caption;
@@ -36,8 +36,10 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
this.RaisePropertyChanged(nameof(ConfirmPassword));
return IsDialogOpen &&
- ((enableEmpty && string.IsNullOrEmpty(Password) && string.IsNullOrEmpty(ConfirmPassword)) ||
- (!string.IsNullOrEmpty(Password) && !string.IsNullOrEmpty(ConfirmPassword) && !Validations.Any));
+ ((enableEmpty && string.IsNullOrEmpty(Password) &&
+ string.IsNullOrEmpty(ConfirmPassword)) ||
+ (!string.IsNullOrEmpty(Password) && !string.IsNullOrEmpty(ConfirmPassword) &&
+ !Validations.Any));
})
.ObserveOn(RxApp.MainThreadScheduler);

ADD
WalletWasabi.Fluent/ViewModels/Dialogs/EnterPasswordDialogViewModel.cs
+using System.Reactive.Linq;
+using ReactiveUI;
+using WalletWasabi.Fluent.Validation;
+using WalletWasabi.Models;
+using WalletWasabi.Userfacing;
+
+namespace WalletWasabi.Fluent.ViewModels.Dialogs
+{
+ [NavigationMetaData(Title = "Enter your password")]
+ public partial class EnterPasswordDialogViewModel : DialogViewModelBase<string?>
+ {
+ [AutoNotify] private string? _password;
+
+ public EnterPasswordDialogViewModel(string caption, bool enableEmpty = true)
+ {
+ Caption = caption;
+
+ // This means pressing continue will make the password empty string.
+ // pressing cancel will return null.
+ _password = "";
+
+ this.ValidateProperty(x => x.Password, ValidatePassword);
+
+ var backCommandCanExecute = this.WhenAnyValue(x => x.IsDialogOpen).ObserveOn(RxApp.MainThreadScheduler);
+
+ var nextCommandCanExecute = this.WhenAnyValue(
+ x => x.IsDialogOpen,
+ x => x.Password,
+ delegate
+ {
+ // This will fire validations before return canExecute value.
+ this.RaisePropertyChanged(nameof(Password));
+
+ return IsDialogOpen &&
+ ((enableEmpty && string.IsNullOrEmpty(Password)) ||
+ (!string.IsNullOrEmpty(Password) && !Validations.Any));
+ })
+ .ObserveOn(RxApp.MainThreadScheduler);
+
+ var cancelCommandCanExecute = this.WhenAnyValue(x => x.IsDialogOpen).ObserveOn(RxApp.MainThreadScheduler);
+
+ BackCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Back), backCommandCanExecute);
+ NextCommand = ReactiveCommand.Create(() => Close(result: Password), nextCommandCanExecute);
+ CancelCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Cancel), cancelCommandCanExecute);
+ }
+
+ public string Caption { get; }
+
+ protected override void OnDialogClosed()
+ {
+ Password = "";
+ }
+
+ private void ValidatePassword(IValidationErrors errors)
+ {
+ if (PasswordHelper.IsTrimmable(Password, out _))
+ {
+ errors.Add(ErrorSeverity.Error, PasswordHelper.WhitespaceMessage);
+ }
+
+ if (PasswordHelper.IsTooLong(Password, out _))
+ {
+ errors.Add(ErrorSeverity.Error, PasswordHelper.PasswordTooLongMessage);
+ }
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Login/PasswordFinder/PasswordFinderIntroduceViewModel.cs
WalletWasabi.Fluent/ViewModels/Login/PasswordFinder/PasswordFinderIntroduceViewModel.cs
@@ -14,7 +14,7 @@ namespace WalletWasabi.Fluent.ViewModels.Login.PasswordFinder
NextCommand = ReactiveCommand.CreateFromTask(async () =>
{
var dialogResult =
- await NavigateDialog(new EnterPasswordViewModel("Type in your most likely password", enableEmpty: false));
+ await NavigateDialog(new CreatePasswordDialogViewModel("Type in your most likely password", enableEmpty: false));
if (dialogResult.Result is { } password)
{

ADD
WalletWasabi.Fluent/Views/Dialogs/CreatePasswordDialogView.axaml.cs
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace WalletWasabi.Fluent.Views.Dialogs
+{
+ public class CreatePasswordView : UserControl
+ {
+ public CreatePasswordView()
+ {
+ InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}
\ No newline at end of file

RENAME
WalletWasabi.Fluent/Views/Dialogs/EnterPasswordView.axaml
WalletWasabi.Fluent/Views/Dialogs/EnterPasswordDialogView.axaml
xmlns:i="using:Avalonia.Xaml.Interactivity"
xmlns:dialog="using:WalletWasabi.Fluent.ViewModels.Dialogs"
mc:Ignorable="d" d:DesignWidth="428" d:DesignHeight="371"
- x:DataType="dialog:EnterPasswordViewModel"
+ x:DataType="dialog:CreatePasswordDialogViewModel"
x:CompileBindings="True"
x:Class="WalletWasabi.Fluent.Views.Dialogs.EnterPasswordView">
<UserControl.KeyBindings>

RENAME
WalletWasabi.Fluent/Views/Dialogs/EnterPasswordView.axaml.cs
WalletWasabi.Fluent/Views/Dialogs/EnterPasswordDialogView.axaml.cs
rename to CreatePasswordDialog and add an EnterPasswordDialog.