Added Login validation
This commit is contained in:
@@ -23,14 +23,17 @@
|
||||
PasswordChar="●"
|
||||
Text="{Binding Password}">
|
||||
<Interaction.Behaviors>
|
||||
<KeyBindingTriggerBehaviour Gesture="Enter">
|
||||
<KeyBindingTriggerBehaviour Gesture="Enter" IsEnabled="{Binding Password, Converter={x:Static StringConverters.IsNotNullOrEmpty}}">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</KeyBindingTriggerBehaviour>
|
||||
</Interaction.Behaviors>
|
||||
</TextBox>
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Center" Text="{ReflectionBinding Validation.Errors[Password]}" />
|
||||
<ProgressRing
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
IsActive="{Binding IsActive}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -61,7 +61,7 @@ public partial class CreateWalletViewModel :
|
||||
{
|
||||
if (args.PropertyName is string name)
|
||||
{
|
||||
Validation.Validate(name);
|
||||
_ = Validation.Validate(name);
|
||||
}
|
||||
|
||||
base.OnPropertyChanged(args);
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class OpenWalletViewModel : Observable
|
||||
{
|
||||
private readonly IValidation validation;
|
||||
[ObservableProperty]
|
||||
private IValidation validation;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? name;
|
||||
|
||||
[MaybeNull]
|
||||
[ObservableProperty]
|
||||
private string? password;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? repeatedPassword;
|
||||
private string password;
|
||||
|
||||
public OpenWalletViewModel(IValidation validation,
|
||||
IServiceProvider provider,
|
||||
@@ -35,13 +35,11 @@ public partial class OpenWalletViewModel : Observable
|
||||
{
|
||||
using (await new ActivityLock(this))
|
||||
{
|
||||
if (Password is { Length: > 0 })
|
||||
{
|
||||
if (await Mediator.Handle<ActivateEventArgs<Wallet<string>>, bool>(Activate.As(new Wallet<string>(Password))))
|
||||
if (await validation.Validate(() => Password, [new ValidationRule(async () =>
|
||||
await Mediator.Handle<ActivateEventArgs<Wallet<string>>, bool>(Activate.As(new Wallet<string>(Password))), "The password is incorrect, please try again.")]))
|
||||
{
|
||||
Publisher.Publish(Opened.As<Wallet>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user