diff --git a/Wino.Core.ViewModels/SettingOptionsPageViewModel.cs b/Wino.Core.ViewModels/SettingOptionsPageViewModel.cs index f73871c8..0e6e1651 100644 --- a/Wino.Core.ViewModels/SettingOptionsPageViewModel.cs +++ b/Wino.Core.ViewModels/SettingOptionsPageViewModel.cs @@ -31,7 +31,6 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel private readonly IPreferencesService _preferencesService; private readonly IProviderService _providerService; private bool _isInitializingSettings; - private bool _isAppearanceSelectionPaused; public string WebsiteUrl => AppUrls.Website; public string PrivacyPolicyUrl => AppUrls.PrivacyPolicy; @@ -126,10 +125,14 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel public void NavigateToSetting(SettingsNavigationItemInfo item) { - if (item?.PageType is WinoPage pageType) + if (item?.PageType is not WinoPage pageType) { - NavigateSubDetail(pageType); + return; } + + Messenger.Send(new BreadcrumbNavigationRequested( + SettingsNavigationInfoProvider.GetPageTitle(pageType), + pageType)); } public void NavigateToAccount(IAccountProviderDetailViewModel account) @@ -217,13 +220,27 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel { Colors.Clear(); - foreach (var color in AccentColorProvider.GetAvailableColors()) + var fixedColors = new[] + { + "#0078d7", "#00838c", "#e3008c", "#ca4f07", "#e81123", + "#00819e", "#10893e", "#881798", "#c239b3", "#767676", + "#e1b12c", "#16a085", "#0984e3", "#4a69bd", "#05c46b" + }; + + foreach (var color in fixedColors) { Colors.Add(new AppColorViewModel(color)); } - UseAccentColor = _preferencesService.IsCustomAccentColorEnabled; - SelectedAppColor = Colors.FirstOrDefault(color => color.Hex == _preferencesService.CustomAccentColorHex) ?? Colors.FirstOrDefault(); + Colors.Add(new AppColorViewModel(_newThemeService.GetSystemAccentColorHex(), true)); + + var currentAccentColor = _newThemeService.AccentColor; + var useSystemAccent = string.IsNullOrEmpty(currentAccentColor); + + UseAccentColor = useSystemAccent; + SelectedAppColor = useSystemAccent + ? Colors.LastOrDefault() + : Colors.FirstOrDefault(color => color.Hex == currentAccentColor) ?? Colors.FirstOrDefault(); } private void InitializeLanguageOptions() @@ -235,7 +252,7 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel private void InitializeAppearanceOptions() { - SelectedElementTheme = ElementThemes.FirstOrDefault(theme => theme.Theme == _preferencesService.ApplicationTheme) + SelectedElementTheme = ElementThemes.FirstOrDefault(theme => theme.NativeTheme == _newThemeService.RootTheme) ?? ElementThemes[0]; } @@ -252,20 +269,15 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel if (_isInitializingSettings || value == null) return; - _preferencesService.ApplicationTheme = value.Theme; + _newThemeService.RootTheme = value.NativeTheme; } partial void OnSelectedAppColorChanged(AppColorViewModel value) { - if (_isInitializingSettings || _isAppearanceSelectionPaused || value == null) + if (_isInitializingSettings || value == null) return; - _preferencesService.CustomAccentColorHex = value.Hex; - - if (UseAccentColor) - { - _newThemeService.ApplyCustomAccentColor(value.Color); - } + _newThemeService.AccentColor = UseAccentColor ? string.Empty : value.Hex; } partial void OnUseAccentColorChanged(bool value) @@ -273,23 +285,15 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel if (_isInitializingSettings) return; - _preferencesService.IsCustomAccentColorEnabled = value; - - _isAppearanceSelectionPaused = true; - try + if (value) { - if (value && SelectedAppColor != null) - { - _newThemeService.ApplyCustomAccentColor(SelectedAppColor.Color); - } - else - { - _newThemeService.ResetAccentColor(); - } + SelectedAppColor = Colors.LastOrDefault(); + _newThemeService.AccentColor = string.Empty; } - finally + else if (SelectedAppColor?.IsAccentColor == true) { - _isAppearanceSelectionPaused = false; + SelectedAppColor = Colors.FirstOrDefault(); + _newThemeService.AccentColor = SelectedAppColor?.Hex ?? string.Empty; } } @@ -302,8 +306,29 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel return _nativeAppService.LaunchUriAsync(new Uri(url)); } - private static List CreateAccountItems(List accounts) + private List CreateAccountItems(List accounts) { - return AccountProviderDetailViewModelFactory.CreateAccountItems(accounts); + return accounts + .GroupBy(account => account.MergedInboxId) + .SelectMany(group => + { + if (group.Key == null) + { + return group.Select(account => (IAccountProviderDetailViewModel)new AccountProviderDetailViewModel( + _providerService.GetProviderDetail(account.ProviderType), + account)); + } + + var mergedInbox = group.First().MergedInbox; + var holdingAccounts = group + .Select(account => new AccountProviderDetailViewModel(_providerService.GetProviderDetail(account.ProviderType), account)) + .ToList(); + + return + [ + (IAccountProviderDetailViewModel)new MergedAccountProviderDetailViewModel(mergedInbox, holdingAccounts) + ]; + }) + .ToList(); } } \ No newline at end of file diff --git a/Wino.Mail.WinUI/Views/SettingOptionsPage.xaml.cs b/Wino.Mail.WinUI/Views/SettingOptionsPage.xaml.cs index f58b3ae2..426324bd 100644 --- a/Wino.Mail.WinUI/Views/SettingOptionsPage.xaml.cs +++ b/Wino.Mail.WinUI/Views/SettingOptionsPage.xaml.cs @@ -26,7 +26,7 @@ public sealed partial class SettingOptionsPage : SettingOptionsPageAbstract if (page.HasValue) { - ViewModel.NavigateSubDetailCommand.Execute(page.Value); + ViewModel.NavigateToSetting(new SettingsNavigationItemInfo(page.Value, string.Empty, string.Empty)); } }