diff --git a/Wino.Core.Domain/Models/Accounts/ProviderDetail.cs b/Wino.Core.Domain/Models/Accounts/ProviderDetail.cs index dc9a5824..4f794749 100644 --- a/Wino.Core.Domain/Models/Accounts/ProviderDetail.cs +++ b/Wino.Core.Domain/Models/Accounts/ProviderDetail.cs @@ -14,6 +14,7 @@ namespace Wino.Core.Domain.Models.Accounts public string ProviderImage => $"ms-appx:///Assets/Providers/{Type}.png"; public bool IsSupported => Type == MailProviderType.Outlook || Type == MailProviderType.Gmail || Type == MailProviderType.IMAP4; + public bool RequireSenderNameOnCreationDialog => Type != MailProviderType.IMAP4; public ProviderDetail(MailProviderType type) { diff --git a/Wino.Mail/Dialogs/NewAccountDialog.xaml.cs b/Wino.Mail/Dialogs/NewAccountDialog.xaml.cs index bb3ce1cb..2ed4a7e7 100644 --- a/Wino.Mail/Dialogs/NewAccountDialog.xaml.cs +++ b/Wino.Mail/Dialogs/NewAccountDialog.xaml.cs @@ -35,7 +35,7 @@ namespace Wino.Dialogs private static void OnSelectedProviderChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { if (obj is NewAccountDialog dialog) - dialog.ValidateCreateButton(); + dialog.Validate(); } private void CancelClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args) @@ -45,7 +45,7 @@ namespace Wino.Dialogs private void CreateClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args) { - ValidateCreateButton(); + Validate(); if (IsSecondaryButtonEnabled) { @@ -54,8 +54,14 @@ namespace Wino.Dialogs } } - private void AccountNameChanged(object sender, TextChangedEventArgs e) => ValidateCreateButton(); - private void SenderNameChanged(object sender, TextChangedEventArgs e) => ValidateCreateButton(); + private void AccountNameChanged(object sender, TextChangedEventArgs e) => Validate(); + private void SenderNameChanged(object sender, TextChangedEventArgs e) => Validate(); + + private void Validate() + { + ValidateCreateButton(); + ValidateNames(); + } // Returns whether we can create account or not. private void ValidateCreateButton() @@ -63,14 +69,17 @@ namespace Wino.Dialogs bool shouldEnable = SelectedMailProvider != null && SelectedMailProvider.IsSupported && !string.IsNullOrEmpty(AccountNameTextbox.Text) - && !string.IsNullOrWhiteSpace(SenderNameTextbox.Text); + && (SelectedMailProvider.RequireSenderNameOnCreationDialog ? !string.IsNullOrEmpty(SenderNameTextbox.Text) : true); IsPrimaryButtonEnabled = shouldEnable; } - private void DialogOpened(ContentDialog sender, ContentDialogOpenedEventArgs args) + private void ValidateNames() { - ValidateCreateButton(); + AccountNameTextbox.IsEnabled = SelectedMailProvider != null; + SenderNameTextbox.IsEnabled = SelectedMailProvider != null && SelectedMailProvider.Type != Core.Domain.Enums.MailProviderType.IMAP4; } + + private void DialogOpened(ContentDialog sender, ContentDialogOpenedEventArgs args) => Validate(); } }