From 9b214a66c883a8fd6a1e0b608482cc6f04557492 Mon Sep 17 00:00:00 2001 From: Aleh Khantsevich Date: Sun, 15 Jun 2025 15:17:57 +0200 Subject: [PATCH] Added new option to hide action labels in mail rendering page (#683) * Added option to disable labels for mail actions * Updated spacings and section title styles in settings * Added translations --- .../Interfaces/IPreferencesService.cs | 5 ++ .../Translations/en_US/resources.json | 2 + Wino.Core.UWP/CoreGeneric.xaml | 13 +++++ Wino.Core.UWP/Services/PreferencesService.cs | 6 +++ .../Behaviors/BindableCommandBarBehavior.cs | 37 +++++++------ Wino.Mail/Dialogs/SignatureEditorDialog.xaml | 44 +++++++++++----- Wino.Mail/Views/ComposePage.xaml | 52 ++++++++++++++++--- Wino.Mail/Views/Settings/AboutPage.xaml | 2 +- .../Views/Settings/AppPreferencesPage.xaml | 2 +- .../Settings/EditAccountDetailsPage.xaml | 2 +- .../Views/Settings/LanguageTimePage.xaml | 2 +- Wino.Mail/Views/Settings/MessageListPage.xaml | 2 +- .../Views/Settings/PersonalizationPage.xaml | 2 +- .../Views/Settings/ReadComposePanePage.xaml | 16 +++--- .../Settings/SignatureManagementPage.xaml | 10 ++-- 15 files changed, 143 insertions(+), 54 deletions(-) diff --git a/Wino.Core.Domain/Interfaces/IPreferencesService.cs b/Wino.Core.Domain/Interfaces/IPreferencesService.cs index 14eef740..11575f8f 100644 --- a/Wino.Core.Domain/Interfaces/IPreferencesService.cs +++ b/Wino.Core.Domain/Interfaces/IPreferencesService.cs @@ -188,6 +188,11 @@ public interface IPreferencesService /// bool IsMailListActionBarEnabled { get; set; } + /// + /// Setting: Whether the mail rendering page will show the action labels + /// + bool IsShowActionLabelsEnabled { get; set; } + #endregion #region Calendar diff --git a/Wino.Core.Domain/Translations/en_US/resources.json b/Wino.Core.Domain/Translations/en_US/resources.json index 2edde941..211e8043 100644 --- a/Wino.Core.Domain/Translations/en_US/resources.json +++ b/Wino.Core.Domain/Translations/en_US/resources.json @@ -644,6 +644,8 @@ "SettingsThreads_Title": "Conversation Threading", "SettingsUnlinkAccounts_Description": "Remove the link between accounts. his will not delete your accounts.", "SettingsUnlinkAccounts_Title": "Unlink Accounts", + "SettingsMailRendering_ActionLabels_Title": "Action labels", + "SettingsMailRendering_ActionLabels_Description": "Show action labels.", "SignatureDeleteDialog_Message": "Are you sure you want to delete \"{0}\" signature?", "SignatureDeleteDialog_Title": "Delete signature", "SignatureEditorDialog_SignatureName_Placeholder": "Name your signature", diff --git a/Wino.Core.UWP/CoreGeneric.xaml b/Wino.Core.UWP/CoreGeneric.xaml index fda84506..30e4a928 100644 --- a/Wino.Core.UWP/CoreGeneric.xaml +++ b/Wino.Core.UWP/CoreGeneric.xaml @@ -97,6 +97,19 @@ + + + 4 + + + diff --git a/Wino.Core.UWP/Services/PreferencesService.cs b/Wino.Core.UWP/Services/PreferencesService.cs index c7508402..bdeffed2 100644 --- a/Wino.Core.UWP/Services/PreferencesService.cs +++ b/Wino.Core.UWP/Services/PreferencesService.cs @@ -79,6 +79,12 @@ public class PreferencesService : ObservableObject, IPreferencesService set => SetPropertyAndSave(nameof(IsMailListActionBarEnabled), value); } + public bool IsShowActionLabelsEnabled + { + get => _configurationService.Get(nameof(IsShowActionLabelsEnabled), true); + set => SetPropertyAndSave(nameof(IsShowActionLabelsEnabled), value); + } + public bool IsShowSenderPicturesEnabled { get => _configurationService.Get(nameof(IsShowSenderPicturesEnabled), true); diff --git a/Wino.Mail/Behaviors/BindableCommandBarBehavior.cs b/Wino.Mail/Behaviors/BindableCommandBarBehavior.cs index 40a5c320..d2deb5cf 100644 --- a/Wino.Mail/Behaviors/BindableCommandBarBehavior.cs +++ b/Wino.Mail/Behaviors/BindableCommandBarBehavior.cs @@ -1,30 +1,28 @@ using System.Collections; using System.Collections.Specialized; using System.Windows.Input; +using CommunityToolkit.WinUI; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Xaml.Interactivity; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; -using Wino.Controls; +using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Menus; using Wino.Core.UWP.Controls; using Wino.Helpers; namespace Wino.Behaviors; -public class BindableCommandBarBehavior : Behavior +public partial class BindableCommandBarBehavior : Behavior { + private readonly IPreferencesService _preferencesService = App.Current.Services.GetService(); public static readonly DependencyProperty PrimaryCommandsProperty = DependencyProperty.Register( "PrimaryCommands", typeof(object), typeof(BindableCommandBarBehavior), new PropertyMetadata(null, UpdateCommands)); - public ICommand ItemClickedCommand - { - get { return (ICommand)GetValue(ItemClickedCommandProperty); } - set { SetValue(ItemClickedCommandProperty, value); } - } - - public static readonly DependencyProperty ItemClickedCommandProperty = DependencyProperty.Register(nameof(ItemClickedCommand), typeof(ICommand), typeof(BindableCommandBarBehavior), new PropertyMetadata(null)); + [GeneratedDependencyProperty] + public partial ICommand ItemClickedCommand { get; set; } public object PrimaryCommands { @@ -83,7 +81,7 @@ public class BindableCommandBarBehavior : Behavior AssociatedObject.PrimaryCommands.Clear(); AssociatedObject.SecondaryCommands.Clear(); - if (!(PrimaryCommands is IEnumerable enumerable)) return; + if (PrimaryCommands is not IEnumerable enumerable) return; foreach (var command in enumerable) { @@ -98,19 +96,26 @@ public class BindableCommandBarBehavior : Behavior else { var label = XamlHelpers.GetOperationString(mailOperationMenuItem.Operation); + var labelPosition = string.IsNullOrWhiteSpace(label) || !_preferencesService.IsShowActionLabelsEnabled ? + CommandBarLabelPosition.Collapsed : CommandBarLabelPosition.Default; menuItem = new AppBarButton { + Width = double.NaN, + MinWidth = 40, Icon = new WinoFontIcon() { Glyph = ControlConstants.WinoIconFontDictionary[XamlHelpers.GetWinoIconGlyph(mailOperationMenuItem.Operation)] }, Label = label, - LabelPosition = string.IsNullOrWhiteSpace(label) ? CommandBarLabelPosition.Collapsed : CommandBarLabelPosition.Default, + LabelPosition = labelPosition, DataContext = mailOperationMenuItem, }; - ToolTip toolTip = new ToolTip + if (!string.IsNullOrWhiteSpace(label)) { - Content = label - }; - ToolTipService.SetToolTip((DependencyObject)menuItem, toolTip); + var toolTip = new ToolTip + { + Content = label + }; + ToolTipService.SetToolTip((DependencyObject)menuItem, toolTip); + } ((AppBarButton)menuItem).Click -= Button_Click; ((AppBarButton)menuItem).Click += Button_Click; @@ -164,7 +169,7 @@ public class BindableCommandBarBehavior : Behavior private static void UpdateCommands(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { - if (!(dependencyObject is BindableCommandBarBehavior behavior)) return; + if (dependencyObject is not BindableCommandBarBehavior behavior) return; if (dependencyPropertyChangedEventArgs.OldValue is INotifyCollectionChanged oldList) { diff --git a/Wino.Mail/Dialogs/SignatureEditorDialog.xaml b/Wino.Mail/Dialogs/SignatureEditorDialog.xaml index 1e0893fa..774c0e72 100644 --- a/Wino.Mail/Dialogs/SignatureEditorDialog.xaml +++ b/Wino.Mail/Dialogs/SignatureEditorDialog.xaml @@ -55,7 +55,8 @@ DefaultLabelPosition="Collapsed" IsOpen="False"> @@ -88,7 +91,8 @@ @@ -97,7 +101,8 @@ @@ -106,7 +111,8 @@ @@ -116,7 +122,8 @@ @@ -125,7 +132,8 @@ @@ -137,7 +145,8 @@ - + @@ -218,7 +232,8 @@ @@ -228,7 +243,8 @@ diff --git a/Wino.Mail/Views/ComposePage.xaml b/Wino.Mail/Views/ComposePage.xaml index 43a419e8..a0f0a02f 100644 --- a/Wino.Mail/Views/ComposePage.xaml +++ b/Wino.Mail/Views/ComposePage.xaml @@ -190,6 +190,8 @@ IsDynamicOverflowEnabled="True" OverflowButtonAlignment="Left"> - + - + - + - + @@ -246,13 +266,21 @@ - + - + @@ -261,6 +289,8 @@ @@ -272,6 +302,8 @@ @@ -282,7 +314,11 @@ - + diff --git a/Wino.Mail/Views/Settings/AboutPage.xaml b/Wino.Mail/Views/Settings/AboutPage.xaml index 09743b01..e4ceb635 100644 --- a/Wino.Mail/Views/Settings/AboutPage.xaml +++ b/Wino.Mail/Views/Settings/AboutPage.xaml @@ -10,7 +10,7 @@ mc:Ignorable="d"> - + - + - + diff --git a/Wino.Mail/Views/Settings/LanguageTimePage.xaml b/Wino.Mail/Views/Settings/LanguageTimePage.xaml index 2c243904..5a501b07 100644 --- a/Wino.Mail/Views/Settings/LanguageTimePage.xaml +++ b/Wino.Mail/Views/Settings/LanguageTimePage.xaml @@ -10,7 +10,7 @@ mc:Ignorable="d"> - + - + diff --git a/Wino.Mail/Views/Settings/PersonalizationPage.xaml b/Wino.Mail/Views/Settings/PersonalizationPage.xaml index a7a95238..1625f4a4 100644 --- a/Wino.Mail/Views/Settings/PersonalizationPage.xaml +++ b/Wino.Mail/Views/Settings/PersonalizationPage.xaml @@ -51,7 +51,7 @@ - + - - + + + + + + + + + @@ -78,10 +85,7 @@ - + - + @@ -69,8 +69,8 @@ - - + + - - + +