From 8ecf301eb81d20f59fec66980a73a8b881866397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Sat, 1 Mar 2025 01:17:04 +0100 Subject: [PATCH] Account colors + edit account details. (#592) * Remove account rename dialog. Implement edit account details page. * Remove unused folder definition. * Adressing theming issues and adding reset button. Changing the UI a bit. * Enable auto indent in initializer. Use service from the application. * Adding color picker to acc setup dialog. Changing UI of edit acc details page. --- Wino.Core.Domain/Enums/WinoPage.cs | 2 +- .../Interfaces/IDialogServiceBase.cs | 2 - Wino.Core.Domain/Interfaces/IThemeService.cs | 2 +- Wino.Core.Domain/MenuItems/AccountMenuItem.cs | 14 ++- .../Accounts/AccountCreationDialogResult.cs | 2 +- .../Translations/en_US/resources.json | 6 ++ .../Converters/HexToColorBrushConverter.cs | 80 +++++++++++++++++ Wino.Core.UWP/Dialogs/AccountEditDialog.xaml | 19 ---- .../Dialogs/AccountEditDialog.xaml.cs | 21 ----- Wino.Core.UWP/Dialogs/NewAccountDialog.xaml | 54 ++++++++---- .../Dialogs/NewAccountDialog.xaml.cs | 35 +++++++- Wino.Core.UWP/Services/DialogServiceBase.cs | 13 --- Wino.Core.UWP/Services/ThemeService.cs | 55 ++++++++++++ .../Services/UnderlyingThemeService.cs | 3 - Wino.Core.UWP/Styles/DataTemplates.xaml | 14 +++ .../Views/ManageAccountsPage.xaml.cs | 16 ++-- Wino.Core.UWP/WinoApplication.cs | 4 +- .../AccountDetailsPageViewModel.cs | 25 +++--- .../AccountManagementViewModel.cs | 3 +- .../EditAccountDetailsPageViewModel.cs | 88 +++++++++++++++++++ Wino.Mail/App.xaml.cs | 1 + Wino.Mail/AppShell.xaml | 10 ++- Wino.Mail/Controls/WebViewEditorControl.cs | 11 +-- Wino.Mail/Services/DialogService.cs | 13 +-- Wino.Mail/Services/NavigationService.cs | 1 + .../EditAccountDetailsPageAbstract.cs | 5 ++ .../Views/Account/AccountDetailsPage.xaml | 12 +-- .../Settings/EditAccountDetailsPage.xaml | 77 ++++++++++++++++ .../Settings/EditAccountDetailsPage.xaml.cs | 11 +++ 29 files changed, 464 insertions(+), 135 deletions(-) create mode 100644 Wino.Core.UWP/Converters/HexToColorBrushConverter.cs delete mode 100644 Wino.Core.UWP/Dialogs/AccountEditDialog.xaml delete mode 100644 Wino.Core.UWP/Dialogs/AccountEditDialog.xaml.cs create mode 100644 Wino.Mail.ViewModels/EditAccountDetailsPageViewModel.cs create mode 100644 Wino.Mail/Views/Abstract/EditAccountDetailsPageAbstract.cs create mode 100644 Wino.Mail/Views/Settings/EditAccountDetailsPage.xaml create mode 100644 Wino.Mail/Views/Settings/EditAccountDetailsPage.xaml.cs diff --git a/Wino.Core.Domain/Enums/WinoPage.cs b/Wino.Core.Domain/Enums/WinoPage.cs index 2ef77757..9bf5347a 100644 --- a/Wino.Core.Domain/Enums/WinoPage.cs +++ b/Wino.Core.Domain/Enums/WinoPage.cs @@ -25,7 +25,7 @@ public enum WinoPage AppPreferencesPage, SettingOptionsPage, AliasManagementPage, - + EditAccountDetailsPage, // Calendar CalendarPage, CalendarSettingsPage, diff --git a/Wino.Core.Domain/Interfaces/IDialogServiceBase.cs b/Wino.Core.Domain/Interfaces/IDialogServiceBase.cs index ba2cbf0b..8cc97e6d 100644 --- a/Wino.Core.Domain/Interfaces/IDialogServiceBase.cs +++ b/Wino.Core.Domain/Interfaces/IDialogServiceBase.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Enums; using Wino.Core.Domain.Models.Accounts; using Wino.Core.Domain.Models.Common; @@ -17,7 +16,6 @@ public interface IDialogServiceBase void InfoBarMessage(string title, string message, InfoBarMessageType messageType); void InfoBarMessage(string title, string message, InfoBarMessageType messageType, string actionButtonText, Action action); void ShowNotSupportedMessage(); - Task ShowEditAccountDialogAsync(MailAccount account); Task ShowTextInputDialogAsync(string currentInput, string dialogTitle, string dialogDescription, string primaryButtonText); Task ShowWinoCustomMessageDialogAsync(string title, string description, diff --git a/Wino.Core.Domain/Interfaces/IThemeService.cs b/Wino.Core.Domain/Interfaces/IThemeService.cs index eb504a0c..322643af 100644 --- a/Wino.Core.Domain/Interfaces/IThemeService.cs +++ b/Wino.Core.Domain/Interfaces/IThemeService.cs @@ -14,7 +14,7 @@ public interface IThemeService : IInitializeAsync Task> GetAvailableThemesAsync(); Task CreateNewCustomThemeAsync(string themeName, string accentColor, byte[] wallpaperData); Task> GetCurrentCustomThemesAsync(); - + List GetAvailableAccountColors(); Task ApplyCustomThemeAsync(bool isInitializing); // Settings diff --git a/Wino.Core.Domain/MenuItems/AccountMenuItem.cs b/Wino.Core.Domain/MenuItems/AccountMenuItem.cs index 4d5dc1b9..7b1e881e 100644 --- a/Wino.Core.Domain/MenuItems/AccountMenuItem.cs +++ b/Wino.Core.Domain/MenuItems/AccountMenuItem.cs @@ -56,6 +56,12 @@ public partial class AccountMenuItem : MenuItemBase SetProperty(Parameter.Base64ProfilePictureData, value, Parameter, (u, n) => u.Base64ProfilePictureData = n); } + public string AccountColorHex + { + get => Parameter.AccountColorHex; + set => SetProperty(Parameter.AccountColorHex, value, Parameter, (u, n) => u.AccountColorHex = n); + } + public IEnumerable HoldingAccounts => new List { Parameter }; public AccountMenuItem(MailAccount account, IMenuItem parent = null) : base(account, account.Id, parent) @@ -66,9 +72,11 @@ public partial class AccountMenuItem : MenuItemBase - - - - - diff --git a/Wino.Core.UWP/Dialogs/AccountEditDialog.xaml.cs b/Wino.Core.UWP/Dialogs/AccountEditDialog.xaml.cs deleted file mode 100644 index e6d72dd0..00000000 --- a/Wino.Core.UWP/Dialogs/AccountEditDialog.xaml.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Windows.UI.Xaml.Controls; -using Wino.Core.Domain.Entities.Shared; - -namespace Wino.Dialogs; - -public sealed partial class AccountEditDialog : ContentDialog -{ - public MailAccount Account { get; private set; } - public bool IsSaved { get; set; } - - public AccountEditDialog(MailAccount account) - { - InitializeComponent(); - Account = account; - } - - private void SaveClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args) - { - IsSaved = true; - } -} diff --git a/Wino.Core.UWP/Dialogs/NewAccountDialog.xaml b/Wino.Core.UWP/Dialogs/NewAccountDialog.xaml index b6330156..1c69c70f 100644 --- a/Wino.Core.UWP/Dialogs/NewAccountDialog.xaml +++ b/Wino.Core.UWP/Dialogs/NewAccountDialog.xaml @@ -5,6 +5,7 @@ xmlns:accounts="using:Wino.Core.Domain.Models.Accounts" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:domain="using:Wino.Core.Domain" + xmlns:helpers="using:Wino.Helpers" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" Title="{x:Bind domain:Translator.NewAccountDialog_Title}" @@ -45,30 +46,47 @@ - - - - + + + + + + + + + + + + /// Gets or sets current selected mail provider in the dialog. /// @@ -48,13 +58,19 @@ public sealed partial class NewAccountDialog : ContentDialog public List Providers { get; set; } + public List AvailableColors { get; set; } + + public AccountCreationDialogResult Result = null; public NewAccountDialog() { InitializeComponent(); - // AccountColorPicker.Color = Colors.Blue; + var themeService = WinoApplication.Current.ThemeService.GetAvailableAccountColors(); + AvailableColors = themeService.Select(a => new AppColorViewModel(a)).ToList(); + + UpdateSelectedColor(); } private static void OnSelectedProviderChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) @@ -63,6 +79,19 @@ public sealed partial class NewAccountDialog : ContentDialog dialog.Validate(); } + private static void OnSelectedColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) + { + if (obj is NewAccountDialog dialog) + dialog.UpdateSelectedColor(); + } + + private void UpdateSelectedColor() + { + PickColorTextblock.Visibility = SelectedColor == null ? Visibility.Visible : Visibility.Collapsed; + SelectedColorEllipse.Fill = SelectedColor == null ? null : XamlHelpers.GetSolidColorBrushFromHex(SelectedColor.Hex); + } + + private void CancelClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args) { Hide(); @@ -75,7 +104,7 @@ public sealed partial class NewAccountDialog : ContentDialog // Special imap detail input. var details = new SpecialImapProviderDetails(SpecialImapAddress.Text.Trim(), AppSpecificPassword.Password.Trim(), DisplayNameTextBox.Text.Trim(), SelectedMailProvider.SpecialImapProvider); - Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), details); + Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), details, SelectedColor?.Hex ?? string.Empty); Hide(); return; @@ -97,7 +126,7 @@ public sealed partial class NewAccountDialog : ContentDialog } else { - Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), null); + Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), null, SelectedColor?.Hex ?? string.Empty); Hide(); } } diff --git a/Wino.Core.UWP/Services/DialogServiceBase.cs b/Wino.Core.UWP/Services/DialogServiceBase.cs index cb569583..afb431df 100644 --- a/Wino.Core.UWP/Services/DialogServiceBase.cs +++ b/Wino.Core.UWP/Services/DialogServiceBase.cs @@ -10,7 +10,6 @@ using Windows.Storage.Pickers; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Wino.Core.Domain; -using Wino.Core.Domain.Entities.Shared; using Wino.Core.Domain.Enums; using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Accounts; @@ -38,18 +37,6 @@ public class DialogServiceBase : IDialogServiceBase ApplicationResourceManager = applicationResourceManager; } - public async Task ShowEditAccountDialogAsync(MailAccount account) - { - var editAccountDialog = new AccountEditDialog(account) - { - RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme() - }; - - await HandleDialogPresentationAsync(editAccountDialog); - - return editAccountDialog.IsSaved ? editAccountDialog.Account : null; - } - public async Task PickFilePathAsync(string saveFileName) { var picker = new FolderPicker() diff --git a/Wino.Core.UWP/Services/ThemeService.cs b/Wino.Core.UWP/Services/ThemeService.cs index 5f453c6c..522f4ffd 100644 --- a/Wino.Core.UWP/Services/ThemeService.cs +++ b/Wino.Core.UWP/Services/ThemeService.cs @@ -458,4 +458,59 @@ public class ThemeService : IThemeService public string GetSystemAccentColorHex() => uiSettings.GetColorValue(UIColorType.Accent).ToHex(); + + public List GetAvailableAccountColors() + { + return new List() + { + "#e74c3c", + "#c0392b", + "#e53935", + "#d81b60", + + // Pinks + "#e91e63", + "#ec407a", + "#ff4081", + + // Purples + "#9b59b6", + "#8e44ad", + "#673ab7", + + // Blues + "#3498db", + "#2980b9", + "#2196f3", + "#03a9f4", + "#00bcd4", + + // Teals + "#009688", + "#1abc9c", + "#16a085", + + // Greens + "#2ecc71", + "#27ae60", + "#4caf50", + "#8bc34a", + + // Yellows & Oranges + "#f1c40f", + "#f39c12", + "#ff9800", + "#ff5722", + + // Browns + "#795548", + "#a0522d", + + // Grays + "#9e9e9e", + "#607d8b", + "#34495e", + "#2c3e50", + }; + } } diff --git a/Wino.Core.UWP/Services/UnderlyingThemeService.cs b/Wino.Core.UWP/Services/UnderlyingThemeService.cs index 95b0ec5d..264f7709 100644 --- a/Wino.Core.UWP/Services/UnderlyingThemeService.cs +++ b/Wino.Core.UWP/Services/UnderlyingThemeService.cs @@ -16,9 +16,6 @@ public class UnderlyingThemeService : IUnderlyingThemeService _configurationService = configurationService; } - // This should not rely on application window to be present. - // Check theme from the settings, rely on UISettings background color if Default. - public bool IsUnderlyingThemeDark() { var currentTheme = _configurationService.Get(SelectedAppThemeKey, ApplicationElementTheme.Default); diff --git a/Wino.Core.UWP/Styles/DataTemplates.xaml b/Wino.Core.UWP/Styles/DataTemplates.xaml index 0f9044c4..2c2d8bf3 100644 --- a/Wino.Core.UWP/Styles/DataTemplates.xaml +++ b/Wino.Core.UWP/Styles/DataTemplates.xaml @@ -6,6 +6,7 @@ xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals" xmlns:coreControls="using:Wino.Core.UWP.Controls" xmlns:coreSelectors="using:Wino.Core.UWP.Selectors" + xmlns:coreViewModelData="using:Wino.Core.ViewModels.Data" xmlns:domain="using:Wino.Core.Domain" xmlns:helpers="using:Wino.Helpers" xmlns:local="using:Wino.Core.UWP.Styles" @@ -202,6 +203,19 @@ + + + + + + + , IRecipient, - IRecipient + IRecipient, + IRecipient { public ObservableCollection PageHistory { get; set; } = new ObservableCollection(); @@ -79,14 +81,16 @@ public sealed partial class ManageAccountsPage : ManageAccountsPageAbstract, GoBackFrame(); } - public void Receive(AccountUpdatedMessage message) + public async void Receive(AccountUpdatedMessage message) { - // TODO: Find better way to retrieve page history from the stack for the account. - var activePage = PageHistory.LastOrDefault(); + var activePage = PageHistory.FirstOrDefault(a => a.Request.PageType == WinoPage.AccountDetailsPage); if (activePage == null) return; - activePage.Title = message.Account.Name; + await Dispatcher.TryRunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => + { + activePage.Title = message.Account.Name; + }); } public void Receive(MergedInboxRenamed message) diff --git a/Wino.Core.UWP/WinoApplication.cs b/Wino.Core.UWP/WinoApplication.cs index 25bf20b2..4eae38cd 100644 --- a/Wino.Core.UWP/WinoApplication.cs +++ b/Wino.Core.UWP/WinoApplication.cs @@ -38,7 +38,8 @@ public abstract class WinoApplication : Application, IRecipient protected IWinoLogger LogInitializer { get; } protected IApplicationConfiguration AppConfiguration { get; } protected IWinoServerConnectionManager AppServiceConnectionManager { get; } - protected IThemeService ThemeService { get; } + public IThemeService ThemeService { get; } + public IUnderlyingThemeService UnderlyingThemeService { get; } protected IDatabaseService DatabaseService { get; } protected ITranslationService TranslationService { get; } @@ -62,6 +63,7 @@ public abstract class WinoApplication : Application, IRecipient ThemeService = Services.GetService(); DatabaseService = Services.GetService(); TranslationService = Services.GetService(); + UnderlyingThemeService = Services.GetService(); // Make sure the paths are setup on app start. AppConfiguration.ApplicationDataFolderPath = ApplicationData.Current.LocalFolder.Path; diff --git a/Wino.Mail.ViewModels/AccountDetailsPageViewModel.cs b/Wino.Mail.ViewModels/AccountDetailsPageViewModel.cs index ec077dfd..494d8813 100644 --- a/Wino.Mail.ViewModels/AccountDetailsPageViewModel.cs +++ b/Wino.Mail.ViewModels/AccountDetailsPageViewModel.cs @@ -13,7 +13,6 @@ using Wino.Core.Domain.Models.Folders; using Wino.Core.Domain.Models.Navigation; using Wino.Messaging.Client.Navigation; using Wino.Messaging.Server; -using Wino.Messaging.UI; namespace Wino.Mail.ViewModels; @@ -23,6 +22,7 @@ public partial class AccountDetailsPageViewModel : MailBaseViewModel private readonly IAccountService _accountService; private readonly IWinoServerConnectionManager _serverConnectionManager; private readonly IFolderService _folderService; + private bool isLoaded = false; public MailAccount Account { get; set; } public ObservableCollection CurrentFolders { get; set; } = []; @@ -78,20 +78,8 @@ public partial class AccountDetailsPageViewModel : MailBaseViewModel => _folderService.ChangeFolderShowUnreadCountStateAsync(folderStructure.Id, isEnabled); [RelayCommand] - private async Task RenameAccount() - { - if (Account == null) - return; - - var updatedAccount = await _dialogService.ShowEditAccountDialogAsync(Account); - - if (updatedAccount != null) - { - await _accountService.UpdateAccountAsync(updatedAccount); - - ReportUIChange(new AccountUpdatedMessage(updatedAccount)); - } - } + private void EditAccountDetails() + => Messenger.Send(new BreadcrumbNavigationRequested(Translator.SettingsEditAccountDetails_Title, WinoPage.EditAccountDetailsPage, Account)); [RelayCommand] private async Task DeleteAccount() @@ -119,6 +107,9 @@ public partial class AccountDetailsPageViewModel : MailBaseViewModel } } + + + public override async void OnNavigatedTo(NavigationMode mode, object parameters) { base.OnNavigatedTo(mode, parameters); @@ -143,6 +134,8 @@ public partial class AccountDetailsPageViewModel : MailBaseViewModel { CurrentFolders.Add(folder); } + + isLoaded = true; } } @@ -150,6 +143,8 @@ public partial class AccountDetailsPageViewModel : MailBaseViewModel { base.OnPropertyChanged(e); + if (!IsActive || !isLoaded) return; + switch (e.PropertyName) { case nameof(IsFocusedInboxEnabled) when IsFocusedInboxSupportedForAccount: diff --git a/Wino.Mail.ViewModels/AccountManagementViewModel.cs b/Wino.Mail.ViewModels/AccountManagementViewModel.cs index c3ccc7e1..a225d76d 100644 --- a/Wino.Mail.ViewModels/AccountManagementViewModel.cs +++ b/Wino.Mail.ViewModels/AccountManagementViewModel.cs @@ -111,7 +111,8 @@ public partial class AccountManagementViewModel : AccountManagementPageViewModel ProviderType = accountCreationDialogResult.ProviderType, Name = accountCreationDialogResult.AccountName, SpecialImapProvider = accountCreationDialogResult.SpecialImapProviderDetails?.SpecialImapProvider ?? SpecialImapProvider.None, - Id = Guid.NewGuid() + Id = Guid.NewGuid(), + AccountColorHex = accountCreationDialogResult.AccountColorHex }; await creationDialog.ShowDialogAsync(accountCreationCancellationTokenSource); diff --git a/Wino.Mail.ViewModels/EditAccountDetailsPageViewModel.cs b/Wino.Mail.ViewModels/EditAccountDetailsPageViewModel.cs new file mode 100644 index 00000000..fb0a5b78 --- /dev/null +++ b/Wino.Mail.ViewModels/EditAccountDetailsPageViewModel.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; +using Wino.Core.Domain.Entities.Shared; +using Wino.Core.Domain.Interfaces; +using Wino.Core.Domain.Models.Navigation; +using Wino.Core.ViewModels.Data; +using Wino.Messaging.Client.Navigation; + +namespace Wino.Mail.ViewModels; + +public partial class EditAccountDetailsPageViewModel : MailBaseViewModel +{ + private readonly IAccountService _accountService; + private readonly IThemeService _themeService; + + [ObservableProperty] + public partial MailAccount Account { get; set; } + + [ObservableProperty] + public partial string AccountName { get; set; } + + [ObservableProperty] + public partial string SenderName { get; set; } + + [ObservableProperty] + public partial AppColorViewModel SelectedColor { get; set; } + + + [ObservableProperty] + public partial List AvailableColors { get; set; } + + public EditAccountDetailsPageViewModel(IAccountService accountService, IThemeService themeService) + { + _accountService = accountService; + _themeService = themeService; + + var colorHexList = _themeService.GetAvailableAccountColors(); + + AvailableColors = colorHexList.Select(a => new AppColorViewModel(a)).ToList(); + } + + [RelayCommand] + private async Task SaveChangesAsync() + { + await UpdateAccountAsync(); + + Messenger.Send(new BackBreadcrumNavigationRequested()); + } + + private Task UpdateAccountAsync() + { + Account.Name = AccountName; + Account.SenderName = SenderName; + Account.AccountColorHex = SelectedColor == null ? string.Empty : SelectedColor.Hex; + + return _accountService.UpdateAccountAsync(Account); + } + + [RelayCommand] + private void ResetColor() + => SelectedColor = null; + + partial void OnSelectedColorChanged(AppColorViewModel oldValue, AppColorViewModel newValue) + { + _ = UpdateAccountAsync(); + } + + public override void OnNavigatedTo(NavigationMode mode, object parameters) + { + base.OnNavigatedTo(mode, parameters); + + if (parameters is MailAccount account) + { + Account = account; + AccountName = account.Name; + SenderName = account.SenderName; + + if (!string.IsNullOrEmpty(account.AccountColorHex)) + { + SelectedColor = AvailableColors.FirstOrDefault(a => a.Hex == account.AccountColorHex); + } + } + } +} diff --git a/Wino.Mail/App.xaml.cs b/Wino.Mail/App.xaml.cs index 35e78dc0..dfa86da8 100644 --- a/Wino.Mail/App.xaml.cs +++ b/Wino.Mail/App.xaml.cs @@ -112,6 +112,7 @@ public sealed partial class App : WinoApplication, services.AddTransient(typeof(ComposePageViewModel)); services.AddTransient(typeof(IdlePageViewModel)); + services.AddTransient(typeof(EditAccountDetailsPageViewModel)); services.AddTransient(typeof(AccountDetailsPageViewModel)); services.AddTransient(typeof(SignatureManagementPageViewModel)); services.AddTransient(typeof(MessageListPageViewModel)); diff --git a/Wino.Mail/AppShell.xaml b/Wino.Mail/AppShell.xaml index 76ded974..4314b9b6 100644 --- a/Wino.Mail/AppShell.xaml +++ b/Wino.Mail/AppShell.xaml @@ -9,6 +9,7 @@ xmlns:controls="using:Wino.Controls" xmlns:controls1="using:CommunityToolkit.WinUI.Controls" xmlns:coreControls="using:Wino.Core.UWP.Controls" + xmlns:coreConverters="using:Wino.Core.UWP.Converters" xmlns:coreSelectors="using:Wino.Core.UWP.Selectors" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:domain="using:Wino.Core.Domain" @@ -23,6 +24,8 @@ + + - + - + diff --git a/Wino.Mail/Controls/WebViewEditorControl.cs b/Wino.Mail/Controls/WebViewEditorControl.cs index df12414f..b7c5b75c 100644 --- a/Wino.Mail/Controls/WebViewEditorControl.cs +++ b/Wino.Mail/Controls/WebViewEditorControl.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Text.Json; using System.Threading.Tasks; using CommunityToolkit.WinUI; @@ -10,12 +9,11 @@ using Microsoft.Web.WebView2.Core; using Windows.UI.ViewManagement.Core; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Markup; -using Windows.UI.Xaml.Media; using Wino.Core.Domain; using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models; using Wino.Core.Domain.Models.Reader; +using Wino.Core.UWP; using Wino.Core.UWP.Extensions; namespace Wino.Mail.Controls; @@ -24,7 +22,6 @@ public sealed partial class WebViewEditorControl : Control, IDisposable private readonly INativeAppService _nativeAppService = App.Current.Services.GetService(); private readonly IFontService _fontService = App.Current.Services.GetService(); private readonly IPreferencesService _preferencesService = App.Current.Services.GetService(); - private readonly IUnderlyingThemeService _underlyingThemeService = App.Current.Services.GetService(); [GeneratedDependencyProperty] public partial bool IsEditorDarkMode { get; set; } @@ -99,7 +96,7 @@ public sealed partial class WebViewEditorControl : Control, IDisposable } } - [GeneratedDependencyProperty] + [GeneratedDependencyProperty(DefaultValue = true)] public partial bool IsEditorIndentEnabled { get; private set; } [GeneratedDependencyProperty] @@ -142,9 +139,7 @@ public sealed partial class WebViewEditorControl : Control, IDisposable { this.DefaultStyleKey = typeof(WebViewEditorControl); - IsEditorIndentEnabled = true; - - IsEditorDarkMode = _underlyingThemeService.IsUnderlyingThemeDark(); + IsEditorDarkMode = WinoApplication.Current.UnderlyingThemeService.IsUnderlyingThemeDark(); } protected override async void OnApplyTemplate() diff --git a/Wino.Mail/Services/DialogService.cs b/Wino.Mail/Services/DialogService.cs index 1e635771..546deaa4 100644 --- a/Wino.Mail/Services/DialogService.cs +++ b/Wino.Mail/Services/DialogService.cs @@ -55,17 +55,6 @@ public class DialogService : DialogServiceBase, IMailDialogService } } - public async Task ShowEditAccountDialogAsync(MailAccount account) - { - var editAccountDialog = new AccountEditDialog(account) - { - RequestedTheme = ThemeService.RootTheme.ToWindowsElementTheme() - }; - - await HandleDialogPresentationAsync(editAccountDialog); - - return editAccountDialog.IsSaved ? editAccountDialog.Account : null; - } public async Task ShowCreateAccountAliasDialogAsync() { @@ -190,7 +179,7 @@ public class DialogService : DialogServiceBase, IMailDialogService await HandleDialogPresentationAsync(dialog); - if(dialog.Copied) + if (dialog.Copied) InfoBarMessage(Translator.ClipboardTextCopied_Title, string.Format(Translator.ClipboardTextCopied_Message, Translator.MessageSourceDialog_Title), InfoBarMessageType.Information); } diff --git a/Wino.Mail/Services/NavigationService.cs b/Wino.Mail/Services/NavigationService.cs index ba193e72..2211331f 100644 --- a/Wino.Mail/Services/NavigationService.cs +++ b/Wino.Mail/Services/NavigationService.cs @@ -56,6 +56,7 @@ public class NavigationService : NavigationServiceBase, INavigationService WinoPage.AppPreferencesPage => typeof(AppPreferencesPage), WinoPage.AliasManagementPage => typeof(AliasManagementPage), WinoPage.LanguageTimePage => typeof(LanguageTimePage), + WinoPage.EditAccountDetailsPage => typeof(EditAccountDetailsPage), _ => null, }; } diff --git a/Wino.Mail/Views/Abstract/EditAccountDetailsPageAbstract.cs b/Wino.Mail/Views/Abstract/EditAccountDetailsPageAbstract.cs new file mode 100644 index 00000000..91cf2854 --- /dev/null +++ b/Wino.Mail/Views/Abstract/EditAccountDetailsPageAbstract.cs @@ -0,0 +1,5 @@ +using Wino.Core.UWP; +using Wino.Mail.ViewModels; + +namespace Wino.Views.Abstract; +public partial class EditAccountDetailsPageAbstract : BasePage { } diff --git a/Wino.Mail/Views/Account/AccountDetailsPage.xaml b/Wino.Mail/Views/Account/AccountDetailsPage.xaml index a0c3ecf4..3aca2a10 100644 --- a/Wino.Mail/Views/Account/AccountDetailsPage.xaml +++ b/Wino.Mail/Views/Account/AccountDetailsPage.xaml @@ -10,13 +10,11 @@ xmlns:domain="using:Wino.Core.Domain" xmlns:folders="using:Wino.Core.Domain.Models.Folders" xmlns:helpers="using:Wino.Helpers" - xmlns:interactionsCore="using:Microsoft.Xaml.Interactions.Core" xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:interfaces="using:Wino.Core.Domain.Interfaces" xmlns:local="using:Wino.Views" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" - xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" x:Name="root" mc:Ignorable="d"> @@ -72,11 +70,14 @@ - + - + -