Skip to content

Commit

Permalink
feat: display error messages in lock form instead of toast
Browse files Browse the repository at this point in the history
Error messages are now displayed in unlock form instead of in a toast
  • Loading branch information
Ldoppea committed Dec 7, 2021
1 parent f43afed commit 4744100
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App/Pages/Accounts/LockPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
<Label Text="{Binding PageTitle}" HorizontalTextAlignment="Center" Margin="0,0,0,0" FontSize="Title"/>
<Label Text="{Binding LoggedInAsText}" HorizontalTextAlignment="Center" Margin="0,0,0,20" FontSize="Small" Opacity="0.64"/>

<Label Text="{Binding ErrorMsg}" HorizontalTextAlignment="Center" Margin="0,0,0,20" FontSize="Medium" StyleClass="text-danger" />

<Grid StyleClass="box-row" IsVisible="{Binding PinLock}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down
39 changes: 39 additions & 0 deletions src/App/Pages/Accounts/LockPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public class LockPageViewModel : BaseViewModel
private string _avatarUrl;
//*/

// Cozy customization, display error message on form
//*
private string _errorMsg;
//*/

public LockPageViewModel()
{
_apiService = ServiceContainer.Resolve<IApiService>("apiService");
Expand Down Expand Up @@ -125,6 +130,15 @@ public string AvatarUrl
}
//*/

// Cozy customization, display error message on form
//*
public string ErrorMsg
{
get => _errorMsg;
set => SetProperty(ref _errorMsg, value);
}
//*/

public Command SubmitCommand { get; }
public Command TogglePasswordCommand { get; }
public string ShowPasswordIcon => ShowPassword ? "" : "";
Expand Down Expand Up @@ -210,18 +224,33 @@ private void ComputeAvatarUrl(string webVault)

public async Task SubmitAsync()
{
// Cozy customization, display error message on form
//*
ErrorMsg = "";
//*/

if (PinLock && string.IsNullOrWhiteSpace(Pin))
{
// Cozy customization, display error message on form
/*
await Page.DisplayAlert(AppResources.AnErrorHasOccurred,
string.Format(AppResources.ValidationFieldRequired, AppResources.PIN),
AppResources.Ok);
/*/
ErrorMsg = string.Format(AppResources.ValidationFieldRequired, AppResources.PIN);
//*/
return;
}
if (!PinLock && string.IsNullOrWhiteSpace(MasterPassword))
{
// Cozy customization, display error message on form
/*
await Page.DisplayAlert(AppResources.AnErrorHasOccurred,
string.Format(AppResources.ValidationFieldRequired, AppResources.MasterPassword),
AppResources.Ok);
/*/
ErrorMsg = string.Format(AppResources.ValidationFieldRequired, AppResources.MasterPassword);
//*/
return;
}

Expand Down Expand Up @@ -272,8 +301,13 @@ public async Task SubmitAsync()
_messagingService.Send("logout");
return;
}
// Cozy customization, display error message on form
/*
await _platformUtilsService.ShowDialogAsync(AppResources.InvalidPIN,
AppResources.AnErrorHasOccurred);
/*/
ErrorMsg = AppResources.InvalidPIN;
//*/
}
}
else
Expand Down Expand Up @@ -334,8 +368,13 @@ public async Task SubmitAsync()
_messagingService.Send("logout");
return;
}
// Cozy customization, display error message on form
/*
await _platformUtilsService.ShowDialogAsync(AppResources.InvalidMasterPassword,
AppResources.AnErrorHasOccurred);
/*/
ErrorMsg = AppResources.InvalidMasterPassword;
//*/
}
}
}
Expand Down

0 comments on commit 4744100

Please sign in to comment.