diff --git a/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml b/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml index 84e46e40..1e8cfae2 100644 --- a/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml +++ b/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml @@ -19,65 +19,218 @@ - + + + - - - - - - - - - - - + Height="140" + CornerRadius="12"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml.cs b/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml.cs index 20b367f3..bd88b239 100644 --- a/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml.cs +++ b/Wino.Mail.WinUI/Dialogs/WinoAccountLoginDialog.xaml.cs @@ -1,5 +1,7 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Input; +using Windows.System; using Wino.Core.Domain; using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Interfaces; @@ -32,6 +34,25 @@ public sealed partial class WinoAccountLoginDialog : ContentDialog var deferral = args.GetDeferral(); + try + { + await PerformLoginAsync(); + } + finally + { + deferral.Complete(); + } + } + + private async System.Threading.Tasks.Task PerformLoginAsync() + { + var validationError = ValidateInput(); + if (!string.IsNullOrWhiteSpace(validationError)) + { + ShowError(validationError); + return; + } + try { SetBusyState(true); @@ -46,13 +67,11 @@ public sealed partial class WinoAccountLoginDialog : ContentDialog } Result = result.Account; - args.Cancel = false; Hide(); } finally { SetBusyState(false); - deferral.Complete(); } } @@ -71,6 +90,24 @@ public sealed partial class WinoAccountLoginDialog : ContentDialog return string.Empty; } + private void EmailTextBox_KeyDown(object sender, KeyRoutedEventArgs e) + { + if (e.Key == VirtualKey.Enter) + { + PasswordBox.Focus(FocusState.Programmatic); + e.Handled = true; + } + } + + private async void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e) + { + if (e.Key == VirtualKey.Enter) + { + e.Handled = true; + await PerformLoginAsync(); + } + } + private void InputChanged(TextBox sender, TextBoxTextChangingEventArgs args) => HideError(); private void InputChanged(object sender, RoutedEventArgs e) => HideError(); diff --git a/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml b/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml index 5f24e133..3d0abfe5 100644 --- a/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml +++ b/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml @@ -19,31 +19,187 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CornerRadius="12"> + @@ -53,20 +209,29 @@ + CornerRadius="12"> + @@ -74,21 +239,25 @@ - + + diff --git a/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml.cs b/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml.cs index fcc01d94..cdad25b3 100644 --- a/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml.cs +++ b/Wino.Mail.WinUI/Dialogs/WinoAccountRegistrationDialog.xaml.cs @@ -1,6 +1,8 @@ using System; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Input; +using Windows.System; using Wino.Core.Domain; using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Interfaces; @@ -33,6 +35,25 @@ public sealed partial class WinoAccountRegistrationDialog : ContentDialog var deferral = args.GetDeferral(); + try + { + await PerformRegistrationAsync(); + } + finally + { + deferral.Complete(); + } + } + + private async System.Threading.Tasks.Task PerformRegistrationAsync() + { + var validationError = ValidateInput(); + if (!string.IsNullOrWhiteSpace(validationError)) + { + ShowError(validationError); + return; + } + try { SetBusyState(true); @@ -47,13 +68,11 @@ public sealed partial class WinoAccountRegistrationDialog : ContentDialog } Result = result.Account; - args.Cancel = false; Hide(); } finally { SetBusyState(false); - deferral.Complete(); } } @@ -77,6 +96,33 @@ public sealed partial class WinoAccountRegistrationDialog : ContentDialog return string.Empty; } + private void EmailTextBox_KeyDown(object sender, KeyRoutedEventArgs e) + { + if (e.Key == VirtualKey.Enter) + { + PasswordBox.Focus(FocusState.Programmatic); + e.Handled = true; + } + } + + private void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e) + { + if (e.Key == VirtualKey.Enter) + { + ConfirmPasswordBox.Focus(FocusState.Programmatic); + e.Handled = true; + } + } + + private async void ConfirmPasswordBox_KeyDown(object sender, KeyRoutedEventArgs e) + { + if (e.Key == VirtualKey.Enter) + { + e.Handled = true; + await PerformRegistrationAsync(); + } + } + private void InputChanged(TextBox sender, TextBoxTextChangingEventArgs args) => HideError(); private void InputChanged(object sender, RoutedEventArgs e) => HideError();