From d8705de26ffabe9362db21b6ef96a3380c8ffab8 Mon Sep 17 00:00:00 2001 From: Aleh Khantsevich Date: Mon, 19 Aug 2024 20:41:55 +0200 Subject: [PATCH] Replaced setting with reset button --- .../MailListPaneLengthPreferences.cs | 4 -- .../Translations/en_US/resources.json | 6 +- Wino.Core.Domain/Translator.Designer.cs | 20 ++++-- Wino.Mail.ViewModels/MailListPageViewModel.cs | 6 +- .../PersonalizationPageViewModel.cs | 37 ++++------- .../Views/Settings/PersonalizationPage.xaml | 64 +++++++++---------- 6 files changed, 67 insertions(+), 70 deletions(-) delete mode 100644 Wino.Core.Domain/Models/Personalization/MailListPaneLengthPreferences.cs diff --git a/Wino.Core.Domain/Models/Personalization/MailListPaneLengthPreferences.cs b/Wino.Core.Domain/Models/Personalization/MailListPaneLengthPreferences.cs deleted file mode 100644 index 23841893..00000000 --- a/Wino.Core.Domain/Models/Personalization/MailListPaneLengthPreferences.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Wino.Core.Domain.Models.Personalization -{ - public record MailListPaneLengthPreferences(string Title, double Length); -} diff --git a/Wino.Core.Domain/Translations/en_US/resources.json b/Wino.Core.Domain/Translations/en_US/resources.json index 2f6699c7..bdb0e16f 100644 --- a/Wino.Core.Domain/Translations/en_US/resources.json +++ b/Wino.Core.Domain/Translations/en_US/resources.json @@ -42,6 +42,7 @@ "Buttons_SignIn": "Sign In", "Buttons_TryAgain": "Try Again", "Buttons_Yes": "Yes", + "Buttons_Reset": "Reset", "Center": "Center", "ComingSoon": "Coming soon...", "ComposerFrom": "From: ", @@ -253,6 +254,7 @@ "Info_UnsubscribeLinkInvalidMessage": "This unsubscribe link is invalid. Failed to unsubscribe from the list.", "Info_UnsubscribeSuccessMessage": "Successfully unsubscribed from {0}.", "Info_UnsubscribeErrorMessage": "Failed to unsubscribe", + "Info_MailListSizeResetSuccessMessage": "The Mail List size has been reset.", "ImapAdvancedSetupDialog_AuthenticationMethod": "Authentication method", "ImapAdvancedSetupDialog_ConnectionSecurity": "Connection security", "ImapAuthenticationMethod_Auto": "Auto", @@ -448,8 +450,8 @@ "SettingsNoAccountSetupMessage": "You didn't setup any accounts yet.", "SettingsNotifications_Description": "Turn on or off notifications for this account.", "SettingsNotifications_Title": "Notifications", - "SettingsPaneLength_Description": "Change the width of the mail list.", - "SettingsPaneLength_Title": "Mail List Pane Length", + "SettingsPaneLengthReset_Description": "Reset the size of the mail list to original if you have issues with it.", + "SettingsPaneLengthReset_Title": "Reset Mail List Size", "SettingsPaypal_Description": "Show much more love ❤️ All donations are appreciated.", "SettingsPaypal_Title": "Donate via PayPal", "SettingsPersonalizationMailDisplayCompactMode": "Compact Mode", diff --git a/Wino.Core.Domain/Translator.Designer.cs b/Wino.Core.Domain/Translator.Designer.cs index 6fc65a03..09ea5907 100644 --- a/Wino.Core.Domain/Translator.Designer.cs +++ b/Wino.Core.Domain/Translator.Designer.cs @@ -233,6 +233,11 @@ namespace Wino.Core.Domain /// public static string Buttons_Yes => Resources.GetTranslatedString(@"Buttons_Yes"); + /// + /// Reset + /// + public static string Buttons_Reset => Resources.GetTranslatedString(@"Buttons_Reset"); + /// /// Center /// @@ -434,7 +439,7 @@ namespace Wino.Core.Domain public static string DialogMessage_UnlinkAccountsConfirmationTitle => Resources.GetTranslatedString(@"DialogMessage_UnlinkAccountsConfirmationTitle"); /// - /// Missin Subject + /// Missing Subject /// public static string DialogMessage_EmptySubjectConfirmation => Resources.GetTranslatedString(@"DialogMessage_EmptySubjectConfirmation"); @@ -1288,6 +1293,11 @@ namespace Wino.Core.Domain /// public static string Info_UnsubscribeErrorMessage => Resources.GetTranslatedString(@"Info_UnsubscribeErrorMessage"); + /// + /// The Mail List size has been reset. + /// + public static string Info_MailListSizeResetSuccessMessage => Resources.GetTranslatedString(@"Info_MailListSizeResetSuccessMessage"); + /// /// Authentication method /// @@ -2264,14 +2274,14 @@ namespace Wino.Core.Domain public static string SettingsNotifications_Title => Resources.GetTranslatedString(@"SettingsNotifications_Title"); /// - /// Change the width of the mail list. + /// Reset the size of the mail list to original if you have issues with it. /// - public static string SettingsPaneLength_Description => Resources.GetTranslatedString(@"SettingsPaneLength_Description"); + public static string SettingsPaneLengthReset_Description => Resources.GetTranslatedString(@"SettingsPaneLengthReset_Description"); /// - /// Mail List Pane Length + /// Reset Mail List Size /// - public static string SettingsPaneLength_Title => Resources.GetTranslatedString(@"SettingsPaneLength_Title"); + public static string SettingsPaneLengthReset_Title => Resources.GetTranslatedString(@"SettingsPaneLengthReset_Title"); /// /// Show much more love ❤️ All donations are appreciated. diff --git a/Wino.Mail.ViewModels/MailListPageViewModel.cs b/Wino.Mail.ViewModels/MailListPageViewModel.cs index 8b50f100..17d2e754 100644 --- a/Wino.Mail.ViewModels/MailListPageViewModel.cs +++ b/Wino.Mail.ViewModels/MailListPageViewModel.cs @@ -68,7 +68,7 @@ namespace Wino.Mail.ViewModels private CancellationTokenSource listManipulationCancellationTokenSource = new CancellationTokenSource(); public IWinoNavigationService NavigationService { get; } - public IStatePersistanceService StatePersistanceService { get; } + public IStatePersistanceService StatePersistenceService { get; } public IPreferencesService PreferencesService { get; } private readonly IMailService _mailService; @@ -158,7 +158,7 @@ namespace Wino.Mail.ViewModels { PreferencesService = preferencesService; _winoServerConnectionManager = winoServerConnectionManager; - StatePersistanceService = statePersistenceService; + StatePersistenceService = statePersistenceService; NavigationService = navigationService; _mailService = mailService; @@ -274,7 +274,7 @@ namespace Wino.Mail.ViewModels bool isMultiSelecting = isCtrlKeyPressed || IsMultiSelectionModeEnabled; - if (isMultiSelecting && StatePersistanceService.IsReaderNarrowed) + if (isMultiSelecting && StatePersistenceService.IsReaderNarrowed) { // Don't change the active mail item if the reader is narrowed, but just update the shell. Messenger.Send(new ShellStateUpdated()); diff --git a/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs b/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs index 1e302f88..718cff85 100644 --- a/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs +++ b/Wino.Mail.ViewModels/PersonalizationPageViewModel.cs @@ -25,37 +25,24 @@ namespace Wino.Mail.ViewModels public bool IsSelectedWindowsAccentColor => SelectedAppColor == Colors.LastOrDefault(); - public ObservableCollection Colors { get; set; } = new ObservableCollection(); + public ObservableCollection Colors { get; set; } = []; - public List ElementThemes { get; set; } = new List() - { + public List ElementThemes { get; set; } = + [ new ElementThemeContainer(ApplicationElementTheme.Light, Translator.ElementTheme_Light), new ElementThemeContainer(ApplicationElementTheme.Dark, Translator.ElementTheme_Dark), new ElementThemeContainer(ApplicationElementTheme.Default, Translator.ElementTheme_Default), - }; + ]; - public List PaneLengths { get; set; } = new List() - { - new MailListPaneLengthPreferences(Translator.PaneLengthOption_Micro, 300), - new MailListPaneLengthPreferences(Translator.PaneLengthOption_Small, 350), - new MailListPaneLengthPreferences(Translator.PaneLengthOption_Default, 420), - new MailListPaneLengthPreferences(Translator.PaneLengthOption_Medium, 700), - new MailListPaneLengthPreferences(Translator.PaneLengthOption_Large, 900), - new MailListPaneLengthPreferences(Translator.PaneLengthOption_ExtraLarge, 1200), - }; - - public List InformationDisplayModes { get; set; } = new List() - { + public List InformationDisplayModes { get; set; } = + [ MailListDisplayMode.Compact, MailListDisplayMode.Medium, MailListDisplayMode.Spacious - }; + ]; public List AppThemes { get; set; } - [ObservableProperty] - private MailListPaneLengthPreferences selectedMailListPaneLength; - [ObservableProperty] private ElementThemeContainer selectedElementTheme; @@ -123,6 +110,13 @@ namespace Wino.Mail.ViewModels #endregion + [RelayCommand] + private void ResetMailListPaneLength() + { + StatePersistanceService.MailListPaneLength = 420; + DialogService.InfoBarMessage(Translator.GeneralTitle_Info, Translator.Info_MailListSizeResetSuccessMessage, InfoBarMessageType.Success); + } + public AsyncRelayCommand CreateCustomThemeCommand { get; set; } public PersonalizationPageViewModel(IDialogService dialogService, IStatePersistanceService statePersistanceService, @@ -179,7 +173,6 @@ namespace Wino.Mail.ViewModels { SelectedElementTheme = ElementThemes.Find(a => a.NativeTheme == _themeService.RootTheme); SelectedInfoDisplayMode = PreferencesService.MailItemDisplayMode; - SelectedMailListPaneLength = PaneLengths.Find(a => a.Length == StatePersistanceService.MailListPaneLength); var currentAccentColor = _themeService.AccentColor; @@ -289,8 +282,6 @@ namespace Wino.Mail.ViewModels { _themeService.CurrentApplicationThemeId = SelectedAppTheme.Id; } - else if (e.PropertyName == nameof(SelectedMailListPaneLength) && SelectedMailListPaneLength != null) - StatePersistanceService.MailListPaneLength = SelectedMailListPaneLength.Length; else { if (e.PropertyName == nameof(SelectedInfoDisplayMode)) diff --git a/Wino.Mail/Views/Settings/PersonalizationPage.xaml b/Wino.Mail/Views/Settings/PersonalizationPage.xaml index 4beab950..762e8975 100644 --- a/Wino.Mail/Views/Settings/PersonalizationPage.xaml +++ b/Wino.Mail/Views/Settings/PersonalizationPage.xaml @@ -3,17 +3,17 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:abstract="using:Wino.Views.Abstract" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" - xmlns:helpers="using:Wino.Helpers" xmlns:controls="using:CommunityToolkit.WinUI.Controls" - xmlns:selectors="using:Wino.Selectors" xmlns:controls1="using:Wino.Controls" - xmlns:viewModelData="using:Wino.Mail.ViewModels.Data" - xmlns:personalization="using:Wino.Core.UWP.Models.Personalization" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:domain="using:Wino.Core.Domain" xmlns:enums="using:Wino.Core.Domain.Enums" + xmlns:helpers="using:Wino.Helpers" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:personalization="using:Wino.Core.UWP.Models.Personalization" + xmlns:selectors="using:Wino.Selectors" + xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" + xmlns:viewModelData="using:Wino.Mail.ViewModels.Data" Title="Personalization" mc:Ignorable="d"> @@ -134,35 +134,35 @@ + SystemThemeTemplate="{StaticResource SystemAppThemeTemplate}" /> + Subject="Welcome to Wino Mail" /> + Subject="Welcome to Wino Mail" /> + Subject="Welcome to Wino Mail" /> @@ -213,15 +213,15 @@ - + @@ -229,31 +229,31 @@ + Foreground="{ThemeResource InfoBarWarningSeverityIconBackground}" + Text="{x:Bind domain:Translator.SettingsElementThemeSelectionDisabled}" /> - + - + -