File scoped namespaces
This commit is contained in:
@@ -20,188 +20,187 @@ using Wino.Mail.Dialogs;
|
||||
using Wino.Messaging.Server;
|
||||
using Wino.Messaging.UI;
|
||||
|
||||
namespace Wino.Services
|
||||
namespace Wino.Services;
|
||||
|
||||
public class DialogService : DialogServiceBase, IMailDialogService
|
||||
{
|
||||
public class DialogService : DialogServiceBase, IMailDialogService
|
||||
public DialogService(IThemeService themeService,
|
||||
IConfigurationService configurationService,
|
||||
IApplicationResourceManager<ResourceDictionary> applicationResourceManager) : base(themeService, configurationService, applicationResourceManager)
|
||||
{
|
||||
public DialogService(IThemeService themeService,
|
||||
IConfigurationService configurationService,
|
||||
IApplicationResourceManager<ResourceDictionary> applicationResourceManager) : base(themeService, configurationService, applicationResourceManager)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override IAccountCreationDialog GetAccountCreationDialog(AccountCreationDialogResult accountCreationDialogResult)
|
||||
public override IAccountCreationDialog GetAccountCreationDialog(AccountCreationDialogResult accountCreationDialogResult)
|
||||
{
|
||||
if (accountCreationDialogResult.SpecialImapProviderDetails == null)
|
||||
{
|
||||
if (accountCreationDialogResult.SpecialImapProviderDetails == null)
|
||||
if (accountCreationDialogResult.ProviderType == MailProviderType.IMAP4)
|
||||
{
|
||||
if (accountCreationDialogResult.ProviderType == MailProviderType.IMAP4)
|
||||
return new NewImapSetupDialog
|
||||
{
|
||||
return new NewImapSetupDialog
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.GetAccountCreationDialog(accountCreationDialogResult);
|
||||
}
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// Special IMAP provider like iCloud or Yahoo.
|
||||
|
||||
return base.GetAccountCreationDialog(accountCreationDialogResult);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MailAccount> ShowEditAccountDialogAsync(MailAccount account)
|
||||
else
|
||||
{
|
||||
var editAccountDialog = new AccountEditDialog(account)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
// Special IMAP provider like iCloud or Yahoo.
|
||||
|
||||
await HandleDialogPresentationAsync(editAccountDialog);
|
||||
|
||||
return editAccountDialog.IsSaved ? editAccountDialog.Account : null;
|
||||
}
|
||||
|
||||
public async Task<ICreateAccountAliasDialog> ShowCreateAccountAliasDialogAsync()
|
||||
{
|
||||
var createAccountAliasDialog = new CreateAccountAliasDialog()
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(createAccountAliasDialog);
|
||||
|
||||
return createAccountAliasDialog;
|
||||
}
|
||||
|
||||
public async Task HandleSystemFolderConfigurationDialogAsync(Guid accountId, IFolderService folderService)
|
||||
{
|
||||
try
|
||||
{
|
||||
var configurableFolder = await folderService.GetFoldersAsync(accountId);
|
||||
|
||||
var systemFolderConfigurationDialog = new SystemFolderConfigurationDialog(configurableFolder)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(systemFolderConfigurationDialog);
|
||||
|
||||
var configuration = systemFolderConfigurationDialog.Configuration;
|
||||
|
||||
if (configuration != null)
|
||||
{
|
||||
await folderService.UpdateSystemFolderConfigurationAsync(accountId, configuration);
|
||||
|
||||
InfoBarMessage(Translator.SystemFolderConfigSetupSuccess_Title, Translator.SystemFolderConfigSetupSuccess_Message, InfoBarMessageType.Success);
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(accountId));
|
||||
|
||||
var options = new MailSynchronizationOptions()
|
||||
{
|
||||
AccountId = accountId,
|
||||
Type = MailSynchronizationType.FullFolders,
|
||||
};
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new NewMailSynchronizationRequested(options, SynchronizationSource.Client));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
InfoBarMessage(Translator.Error_FailedToSetupSystemFolders_Title, ex.Message, InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IMailItemFolder> ShowMoveMailFolderDialogAsync(List<IMailItemFolder> availableFolders)
|
||||
{
|
||||
var moveDialog = new MoveMailDialog(availableFolders)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(moveDialog);
|
||||
|
||||
return moveDialog.SelectedFolder;
|
||||
}
|
||||
|
||||
public async Task<IMailItemFolder> PickFolderAsync(Guid accountId, PickFolderReason reason, IFolderService folderService)
|
||||
{
|
||||
var allFolders = await folderService.GetFolderStructureForAccountAsync(accountId, true);
|
||||
|
||||
return await ShowMoveMailFolderDialogAsync(allFolders.Folders);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Task<bool> ShowHardDeleteConfirmationAsync()
|
||||
=> ShowWinoCustomMessageDialogAsync(Translator.DialogMessage_HardDeleteConfirmationMessage,
|
||||
Translator.DialogMessage_HardDeleteConfirmationTitle,
|
||||
Translator.Buttons_Yes,
|
||||
WinoCustomMessageDialogIcon.Warning,
|
||||
Translator.Buttons_No);
|
||||
|
||||
public async Task<MailAccount> ShowAccountPickerDialogAsync(List<MailAccount> availableAccounts)
|
||||
{
|
||||
var accountPicker = new AccountPickerDialog(availableAccounts)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(accountPicker);
|
||||
|
||||
return accountPicker.PickedAccount;
|
||||
}
|
||||
|
||||
public async Task<AccountSignature> ShowSignatureEditorDialog(AccountSignature signatureModel = null)
|
||||
{
|
||||
SignatureEditorDialog signatureEditorDialog;
|
||||
if (signatureModel != null)
|
||||
{
|
||||
signatureEditorDialog = new SignatureEditorDialog(signatureModel)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
signatureEditorDialog = new SignatureEditorDialog()
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
}
|
||||
|
||||
var result = await HandleDialogPresentationAsync(signatureEditorDialog);
|
||||
|
||||
return result == ContentDialogResult.Primary ? signatureEditorDialog.Result : null;
|
||||
}
|
||||
|
||||
public async Task ShowMessageSourceDialogAsync(string messageSource)
|
||||
{
|
||||
var dialog = new MessageSourceDialog()
|
||||
{
|
||||
MessageSource = messageSource,
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(dialog);
|
||||
|
||||
if(dialog.Copied)
|
||||
InfoBarMessage(Translator.ClipboardTextCopied_Title, string.Format(Translator.ClipboardTextCopied_Message, Translator.MessageSourceDialog_Title), InfoBarMessageType.Information);
|
||||
}
|
||||
|
||||
public async Task ShowAccountReorderDialogAsync(ObservableCollection<IAccountProviderDetailViewModel> availableAccounts)
|
||||
{
|
||||
var accountReorderDialog = new AccountReorderDialog(availableAccounts)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(accountReorderDialog);
|
||||
return base.GetAccountCreationDialog(accountCreationDialogResult);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MailAccount> ShowEditAccountDialogAsync(MailAccount account)
|
||||
{
|
||||
var editAccountDialog = new AccountEditDialog(account)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(editAccountDialog);
|
||||
|
||||
return editAccountDialog.IsSaved ? editAccountDialog.Account : null;
|
||||
}
|
||||
|
||||
public async Task<ICreateAccountAliasDialog> ShowCreateAccountAliasDialogAsync()
|
||||
{
|
||||
var createAccountAliasDialog = new CreateAccountAliasDialog()
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(createAccountAliasDialog);
|
||||
|
||||
return createAccountAliasDialog;
|
||||
}
|
||||
|
||||
public async Task HandleSystemFolderConfigurationDialogAsync(Guid accountId, IFolderService folderService)
|
||||
{
|
||||
try
|
||||
{
|
||||
var configurableFolder = await folderService.GetFoldersAsync(accountId);
|
||||
|
||||
var systemFolderConfigurationDialog = new SystemFolderConfigurationDialog(configurableFolder)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(systemFolderConfigurationDialog);
|
||||
|
||||
var configuration = systemFolderConfigurationDialog.Configuration;
|
||||
|
||||
if (configuration != null)
|
||||
{
|
||||
await folderService.UpdateSystemFolderConfigurationAsync(accountId, configuration);
|
||||
|
||||
InfoBarMessage(Translator.SystemFolderConfigSetupSuccess_Title, Translator.SystemFolderConfigSetupSuccess_Message, InfoBarMessageType.Success);
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new AccountFolderConfigurationUpdated(accountId));
|
||||
|
||||
var options = new MailSynchronizationOptions()
|
||||
{
|
||||
AccountId = accountId,
|
||||
Type = MailSynchronizationType.FullFolders,
|
||||
};
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new NewMailSynchronizationRequested(options, SynchronizationSource.Client));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
InfoBarMessage(Translator.Error_FailedToSetupSystemFolders_Title, ex.Message, InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IMailItemFolder> ShowMoveMailFolderDialogAsync(List<IMailItemFolder> availableFolders)
|
||||
{
|
||||
var moveDialog = new MoveMailDialog(availableFolders)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(moveDialog);
|
||||
|
||||
return moveDialog.SelectedFolder;
|
||||
}
|
||||
|
||||
public async Task<IMailItemFolder> PickFolderAsync(Guid accountId, PickFolderReason reason, IFolderService folderService)
|
||||
{
|
||||
var allFolders = await folderService.GetFolderStructureForAccountAsync(accountId, true);
|
||||
|
||||
return await ShowMoveMailFolderDialogAsync(allFolders.Folders);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Task<bool> ShowHardDeleteConfirmationAsync()
|
||||
=> ShowWinoCustomMessageDialogAsync(Translator.DialogMessage_HardDeleteConfirmationMessage,
|
||||
Translator.DialogMessage_HardDeleteConfirmationTitle,
|
||||
Translator.Buttons_Yes,
|
||||
WinoCustomMessageDialogIcon.Warning,
|
||||
Translator.Buttons_No);
|
||||
|
||||
public async Task<MailAccount> ShowAccountPickerDialogAsync(List<MailAccount> availableAccounts)
|
||||
{
|
||||
var accountPicker = new AccountPickerDialog(availableAccounts)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(accountPicker);
|
||||
|
||||
return accountPicker.PickedAccount;
|
||||
}
|
||||
|
||||
public async Task<AccountSignature> ShowSignatureEditorDialog(AccountSignature signatureModel = null)
|
||||
{
|
||||
SignatureEditorDialog signatureEditorDialog;
|
||||
if (signatureModel != null)
|
||||
{
|
||||
signatureEditorDialog = new SignatureEditorDialog(signatureModel)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
signatureEditorDialog = new SignatureEditorDialog()
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
}
|
||||
|
||||
var result = await HandleDialogPresentationAsync(signatureEditorDialog);
|
||||
|
||||
return result == ContentDialogResult.Primary ? signatureEditorDialog.Result : null;
|
||||
}
|
||||
|
||||
public async Task ShowMessageSourceDialogAsync(string messageSource)
|
||||
{
|
||||
var dialog = new MessageSourceDialog()
|
||||
{
|
||||
MessageSource = messageSource,
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(dialog);
|
||||
|
||||
if(dialog.Copied)
|
||||
InfoBarMessage(Translator.ClipboardTextCopied_Title, string.Format(Translator.ClipboardTextCopied_Message, Translator.MessageSourceDialog_Title), InfoBarMessageType.Information);
|
||||
}
|
||||
|
||||
public async Task ShowAccountReorderDialogAsync(ObservableCollection<IAccountProviderDetailViewModel> availableAccounts)
|
||||
{
|
||||
var accountReorderDialog = new AccountReorderDialog(availableAccounts)
|
||||
{
|
||||
RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme()
|
||||
};
|
||||
|
||||
await HandleDialogPresentationAsync(accountReorderDialog);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Services
|
||||
namespace Wino.Services;
|
||||
|
||||
public class MailAuthenticatorConfiguration : IAuthenticatorConfig
|
||||
{
|
||||
public class MailAuthenticatorConfiguration : IAuthenticatorConfig
|
||||
public string OutlookAuthenticatorClientId => "b19c2035-d740-49ff-b297-de6ec561b208";
|
||||
|
||||
public string[] OutlookScope => new string[]
|
||||
{
|
||||
public string OutlookAuthenticatorClientId => "b19c2035-d740-49ff-b297-de6ec561b208";
|
||||
"email",
|
||||
"mail.readwrite",
|
||||
"offline_access",
|
||||
"mail.send",
|
||||
"Mail.Send.Shared",
|
||||
"Mail.ReadWrite.Shared",
|
||||
"User.Read"
|
||||
};
|
||||
|
||||
public string[] OutlookScope => new string[]
|
||||
{
|
||||
"email",
|
||||
"mail.readwrite",
|
||||
"offline_access",
|
||||
"mail.send",
|
||||
"Mail.Send.Shared",
|
||||
"Mail.ReadWrite.Shared",
|
||||
"User.Read"
|
||||
};
|
||||
public string GmailAuthenticatorClientId => "973025879644-s7b4ur9p3rlgop6a22u7iuptdc0brnrn.apps.googleusercontent.com";
|
||||
|
||||
public string GmailAuthenticatorClientId => "973025879644-s7b4ur9p3rlgop6a22u7iuptdc0brnrn.apps.googleusercontent.com";
|
||||
public string[] GmailScope => new string[]
|
||||
{
|
||||
"https://mail.google.com/",
|
||||
"https://www.googleapis.com/auth/userinfo.profile",
|
||||
"https://www.googleapis.com/auth/gmail.labels",
|
||||
"https://www.googleapis.com/auth/userinfo.email"
|
||||
};
|
||||
|
||||
public string[] GmailScope => new string[]
|
||||
{
|
||||
"https://mail.google.com/",
|
||||
"https://www.googleapis.com/auth/userinfo.profile",
|
||||
"https://www.googleapis.com/auth/gmail.labels",
|
||||
"https://www.googleapis.com/auth/userinfo.email"
|
||||
};
|
||||
|
||||
public string GmailTokenStoreIdentifier => "WinoMailGmailTokenStore";
|
||||
}
|
||||
public string GmailTokenStoreIdentifier => "WinoMailGmailTokenStore";
|
||||
}
|
||||
|
||||
@@ -15,148 +15,147 @@ using Wino.Views;
|
||||
using Wino.Views.Account;
|
||||
using Wino.Views.Settings;
|
||||
|
||||
namespace Wino.Services
|
||||
namespace Wino.Services;
|
||||
|
||||
public class NavigationService : NavigationServiceBase, INavigationService
|
||||
{
|
||||
public class NavigationService : NavigationServiceBase, INavigationService
|
||||
private readonly IStatePersistanceService _statePersistanceService;
|
||||
|
||||
private WinoPage[] _renderingPageTypes = new WinoPage[]
|
||||
{
|
||||
private readonly IStatePersistanceService _statePersistanceService;
|
||||
WinoPage.MailRenderingPage,
|
||||
WinoPage.ComposePage
|
||||
};
|
||||
|
||||
private WinoPage[] _renderingPageTypes = new WinoPage[]
|
||||
public NavigationService(IStatePersistanceService statePersistanceService)
|
||||
{
|
||||
_statePersistanceService = statePersistanceService;
|
||||
}
|
||||
|
||||
public Type GetPageType(WinoPage winoPage)
|
||||
{
|
||||
return winoPage switch
|
||||
{
|
||||
WinoPage.MailRenderingPage,
|
||||
WinoPage.ComposePage
|
||||
WinoPage.None => null,
|
||||
WinoPage.IdlePage => typeof(IdlePage),
|
||||
WinoPage.AccountDetailsPage => typeof(AccountDetailsPage),
|
||||
WinoPage.MergedAccountDetailsPage => typeof(MergedAccountDetailsPage),
|
||||
WinoPage.AccountManagementPage => typeof(AccountManagementPage),
|
||||
WinoPage.ManageAccountsPage => typeof(ManageAccountsPage),
|
||||
WinoPage.SignatureManagementPage => typeof(SignatureManagementPage),
|
||||
WinoPage.AboutPage => typeof(AboutPage),
|
||||
WinoPage.PersonalizationPage => typeof(PersonalizationPage),
|
||||
WinoPage.MessageListPage => typeof(MessageListPage),
|
||||
WinoPage.ReadComposePanePage => typeof(ReadComposePanePage),
|
||||
WinoPage.MailRenderingPage => typeof(MailRenderingPage),
|
||||
WinoPage.ComposePage => typeof(ComposePage),
|
||||
WinoPage.MailListPage => typeof(MailListPage),
|
||||
WinoPage.SettingsPage => typeof(SettingsPage),
|
||||
WinoPage.WelcomePage => typeof(WelcomePage),
|
||||
WinoPage.SettingOptionsPage => typeof(SettingOptionsPage),
|
||||
WinoPage.AppPreferencesPage => typeof(AppPreferencesPage),
|
||||
WinoPage.AliasManagementPage => typeof(AliasManagementPage),
|
||||
WinoPage.LanguageTimePage => typeof(LanguageTimePage),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public NavigationService(IStatePersistanceService statePersistanceService)
|
||||
{
|
||||
_statePersistanceService = statePersistanceService;
|
||||
}
|
||||
public Frame GetCoreFrame(NavigationReferenceFrame frameType)
|
||||
{
|
||||
if (Window.Current.Content is Frame appFrame)
|
||||
return WinoVisualTreeHelper.GetChildObject<Frame>(appFrame.Content as UIElement, frameType.ToString());
|
||||
|
||||
public Type GetPageType(WinoPage winoPage)
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Navigate(WinoPage page,
|
||||
object parameter = null,
|
||||
NavigationReferenceFrame frame = NavigationReferenceFrame.ShellFrame,
|
||||
NavigationTransitionType transition = NavigationTransitionType.None)
|
||||
{
|
||||
var pageType = GetPageType(page);
|
||||
Frame shellFrame = GetCoreFrame(NavigationReferenceFrame.ShellFrame);
|
||||
|
||||
_statePersistanceService.IsReadingMail = _renderingPageTypes.Contains(page);
|
||||
|
||||
if (shellFrame != null)
|
||||
{
|
||||
return winoPage switch
|
||||
var currentFrameType = GetCurrentFrameType(ref shellFrame);
|
||||
|
||||
bool isMailListingPageActive = currentFrameType != null && currentFrameType == typeof(MailListPage);
|
||||
|
||||
// Active page is mail list page and we are refreshing the folder.
|
||||
if (isMailListingPageActive && currentFrameType == pageType && parameter is NavigateMailFolderEventArgs folderNavigationArgs)
|
||||
{
|
||||
WinoPage.None => null,
|
||||
WinoPage.IdlePage => typeof(IdlePage),
|
||||
WinoPage.AccountDetailsPage => typeof(AccountDetailsPage),
|
||||
WinoPage.MergedAccountDetailsPage => typeof(MergedAccountDetailsPage),
|
||||
WinoPage.AccountManagementPage => typeof(AccountManagementPage),
|
||||
WinoPage.ManageAccountsPage => typeof(ManageAccountsPage),
|
||||
WinoPage.SignatureManagementPage => typeof(SignatureManagementPage),
|
||||
WinoPage.AboutPage => typeof(AboutPage),
|
||||
WinoPage.PersonalizationPage => typeof(PersonalizationPage),
|
||||
WinoPage.MessageListPage => typeof(MessageListPage),
|
||||
WinoPage.ReadComposePanePage => typeof(ReadComposePanePage),
|
||||
WinoPage.MailRenderingPage => typeof(MailRenderingPage),
|
||||
WinoPage.ComposePage => typeof(ComposePage),
|
||||
WinoPage.MailListPage => typeof(MailListPage),
|
||||
WinoPage.SettingsPage => typeof(SettingsPage),
|
||||
WinoPage.WelcomePage => typeof(WelcomePage),
|
||||
WinoPage.SettingOptionsPage => typeof(SettingOptionsPage),
|
||||
WinoPage.AppPreferencesPage => typeof(AppPreferencesPage),
|
||||
WinoPage.AliasManagementPage => typeof(AliasManagementPage),
|
||||
WinoPage.LanguageTimePage => typeof(LanguageTimePage),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
// No need for new navigation, just refresh the folder.
|
||||
WeakReferenceMessenger.Default.Send(new ActiveMailFolderChangedEvent(folderNavigationArgs.BaseFolderMenuItem, folderNavigationArgs.FolderInitLoadAwaitTask));
|
||||
WeakReferenceMessenger.Default.Send(new DisposeRenderingFrameRequested());
|
||||
|
||||
public Frame GetCoreFrame(NavigationReferenceFrame frameType)
|
||||
{
|
||||
if (Window.Current.Content is Frame appFrame)
|
||||
return WinoVisualTreeHelper.GetChildObject<Frame>(appFrame.Content as UIElement, frameType.ToString());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Navigate(WinoPage page,
|
||||
object parameter = null,
|
||||
NavigationReferenceFrame frame = NavigationReferenceFrame.ShellFrame,
|
||||
NavigationTransitionType transition = NavigationTransitionType.None)
|
||||
{
|
||||
var pageType = GetPageType(page);
|
||||
Frame shellFrame = GetCoreFrame(NavigationReferenceFrame.ShellFrame);
|
||||
|
||||
_statePersistanceService.IsReadingMail = _renderingPageTypes.Contains(page);
|
||||
|
||||
if (shellFrame != null)
|
||||
{
|
||||
var currentFrameType = GetCurrentFrameType(ref shellFrame);
|
||||
|
||||
bool isMailListingPageActive = currentFrameType != null && currentFrameType == typeof(MailListPage);
|
||||
|
||||
// Active page is mail list page and we are refreshing the folder.
|
||||
if (isMailListingPageActive && currentFrameType == pageType && parameter is NavigateMailFolderEventArgs folderNavigationArgs)
|
||||
{
|
||||
// No need for new navigation, just refresh the folder.
|
||||
WeakReferenceMessenger.Default.Send(new ActiveMailFolderChangedEvent(folderNavigationArgs.BaseFolderMenuItem, folderNavigationArgs.FolderInitLoadAwaitTask));
|
||||
WeakReferenceMessenger.Default.Send(new DisposeRenderingFrameRequested());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var transitionInfo = GetNavigationTransitionInfo(transition);
|
||||
|
||||
// This page must be opened in the Frame placed in MailListingPage.
|
||||
if (isMailListingPageActive && frame == NavigationReferenceFrame.RenderingFrame)
|
||||
{
|
||||
var listingFrame = GetCoreFrame(NavigationReferenceFrame.RenderingFrame);
|
||||
|
||||
if (listingFrame == null) return false;
|
||||
|
||||
// Active page is mail list page and we are opening a mail item.
|
||||
// No navigation needed, just refresh the rendered mail item.
|
||||
if (listingFrame.Content != null
|
||||
&& listingFrame.Content.GetType() == GetPageType(WinoPage.MailRenderingPage)
|
||||
&& parameter is MailItemViewModel mailItemViewModel
|
||||
&& page != WinoPage.ComposePage)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new NewMailItemRenderingRequestedEvent(mailItemViewModel));
|
||||
}
|
||||
else if (listingFrame.Content != null
|
||||
&& listingFrame.Content.GetType() == GetPageType(WinoPage.IdlePage)
|
||||
&& pageType == typeof(IdlePage))
|
||||
{
|
||||
// Idle -> Idle navigation. Ignore.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
listingFrame.Navigate(pageType, parameter, transitionInfo);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((currentFrameType != null && currentFrameType != pageType) || currentFrameType == null)
|
||||
{
|
||||
return shellFrame.Navigate(pageType, parameter, transitionInfo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
var transitionInfo = GetNavigationTransitionInfo(transition);
|
||||
|
||||
// This page must be opened in the Frame placed in MailListingPage.
|
||||
if (isMailListingPageActive && frame == NavigationReferenceFrame.RenderingFrame)
|
||||
{
|
||||
var listingFrame = GetCoreFrame(NavigationReferenceFrame.RenderingFrame);
|
||||
|
||||
if (listingFrame == null) return false;
|
||||
|
||||
// Active page is mail list page and we are opening a mail item.
|
||||
// No navigation needed, just refresh the rendered mail item.
|
||||
if (listingFrame.Content != null
|
||||
&& listingFrame.Content.GetType() == GetPageType(WinoPage.MailRenderingPage)
|
||||
&& parameter is MailItemViewModel mailItemViewModel
|
||||
&& page != WinoPage.ComposePage)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new NewMailItemRenderingRequestedEvent(mailItemViewModel));
|
||||
}
|
||||
else if (listingFrame.Content != null
|
||||
&& listingFrame.Content.GetType() == GetPageType(WinoPage.IdlePage)
|
||||
&& pageType == typeof(IdlePage))
|
||||
{
|
||||
// Idle -> Idle navigation. Ignore.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
listingFrame.Navigate(pageType, parameter, transitionInfo);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((currentFrameType != null && currentFrameType != pageType) || currentFrameType == null)
|
||||
{
|
||||
return shellFrame.Navigate(pageType, parameter, transitionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void GoBack() => throw new NotImplementedException("GoBack method is not implemented in Wino Mail.");
|
||||
|
||||
// Standalone EML viewer.
|
||||
//public void NavigateRendering(MimeMessageInformation mimeMessageInformation, NavigationTransitionType transition = NavigationTransitionType.None)
|
||||
//{
|
||||
// if (mimeMessageInformation == null)
|
||||
// throw new ArgumentException("MimeMessage cannot be null.");
|
||||
|
||||
// Navigate(WinoPage.MailRenderingPage, mimeMessageInformation, NavigationReferenceFrame.RenderingFrame, transition);
|
||||
//}
|
||||
|
||||
//// Mail item view model clicked handler.
|
||||
//public void NavigateRendering(IMailItem mailItem, NavigationTransitionType transition = NavigationTransitionType.None)
|
||||
//{
|
||||
// if (mailItem is MailItemViewModel mailItemViewModel)
|
||||
// Navigate(WinoPage.MailRenderingPage, mailItemViewModel, NavigationReferenceFrame.RenderingFrame, transition);
|
||||
// else
|
||||
// throw new ArgumentException("MailItem must be of type MailItemViewModel.");
|
||||
//}
|
||||
|
||||
//public void NavigateFolder(NavigateMailFolderEventArgs args)
|
||||
// => Navigate(WinoPage.MailListPage, args, NavigationReferenceFrame.ShellFrame);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void GoBack() => throw new NotImplementedException("GoBack method is not implemented in Wino Mail.");
|
||||
|
||||
// Standalone EML viewer.
|
||||
//public void NavigateRendering(MimeMessageInformation mimeMessageInformation, NavigationTransitionType transition = NavigationTransitionType.None)
|
||||
//{
|
||||
// if (mimeMessageInformation == null)
|
||||
// throw new ArgumentException("MimeMessage cannot be null.");
|
||||
|
||||
// Navigate(WinoPage.MailRenderingPage, mimeMessageInformation, NavigationReferenceFrame.RenderingFrame, transition);
|
||||
//}
|
||||
|
||||
//// Mail item view model clicked handler.
|
||||
//public void NavigateRendering(IMailItem mailItem, NavigationTransitionType transition = NavigationTransitionType.None)
|
||||
//{
|
||||
// if (mailItem is MailItemViewModel mailItemViewModel)
|
||||
// Navigate(WinoPage.MailRenderingPage, mailItemViewModel, NavigationReferenceFrame.RenderingFrame, transition);
|
||||
// else
|
||||
// throw new ArgumentException("MailItem must be of type MailItemViewModel.");
|
||||
//}
|
||||
|
||||
//public void NavigateFolder(NavigateMailFolderEventArgs args)
|
||||
// => Navigate(WinoPage.MailListPage, args, NavigationReferenceFrame.ShellFrame);
|
||||
}
|
||||
|
||||
@@ -4,32 +4,31 @@ using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Accounts;
|
||||
|
||||
namespace Wino.Mail.Services
|
||||
namespace Wino.Mail.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service that is returning available provider details.
|
||||
/// </summary>
|
||||
public class ProviderService : IProviderService
|
||||
{
|
||||
/// <summary>
|
||||
/// Service that is returning available provider details.
|
||||
/// </summary>
|
||||
public class ProviderService : IProviderService
|
||||
public IProviderDetail GetProviderDetail(MailProviderType type)
|
||||
{
|
||||
public IProviderDetail GetProviderDetail(MailProviderType type)
|
||||
var details = GetAvailableProviders();
|
||||
|
||||
return details.FirstOrDefault(a => a.Type == type);
|
||||
}
|
||||
|
||||
public List<IProviderDetail> GetAvailableProviders()
|
||||
{
|
||||
var providerList = new List<IProviderDetail>
|
||||
{
|
||||
var details = GetAvailableProviders();
|
||||
new ProviderDetail(MailProviderType.Outlook, SpecialImapProvider.None),
|
||||
new ProviderDetail(MailProviderType.Gmail, SpecialImapProvider.None),
|
||||
new ProviderDetail(MailProviderType.IMAP4, SpecialImapProvider.iCloud),
|
||||
new ProviderDetail(MailProviderType.IMAP4, SpecialImapProvider.Yahoo),
|
||||
new ProviderDetail(MailProviderType.IMAP4, SpecialImapProvider.None)
|
||||
};
|
||||
|
||||
return details.FirstOrDefault(a => a.Type == type);
|
||||
}
|
||||
|
||||
public List<IProviderDetail> GetAvailableProviders()
|
||||
{
|
||||
var providerList = new List<IProviderDetail>
|
||||
{
|
||||
new ProviderDetail(MailProviderType.Outlook, SpecialImapProvider.None),
|
||||
new ProviderDetail(MailProviderType.Gmail, SpecialImapProvider.None),
|
||||
new ProviderDetail(MailProviderType.IMAP4, SpecialImapProvider.iCloud),
|
||||
new ProviderDetail(MailProviderType.IMAP4, SpecialImapProvider.Yahoo),
|
||||
new ProviderDetail(MailProviderType.IMAP4, SpecialImapProvider.None)
|
||||
};
|
||||
|
||||
return providerList;
|
||||
}
|
||||
return providerList;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user