Skip to content

Commit

Permalink
Merge pull request #325 from bkaankose/features/mail-list-splitter
Browse files Browse the repository at this point in the history
Mail List splitter
  • Loading branch information
bkaankose authored Aug 19, 2024
2 parents 3365c09 + 9cc4c33 commit d623129
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 231 deletions.

This file was deleted.

6 changes: 4 additions & 2 deletions Wino.Core.Domain/Translations/en_US/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"Buttons_SignIn": "Sign In",
"Buttons_TryAgain": "Try Again",
"Buttons_Yes": "Yes",
"Buttons_Reset": "Reset",
"Center": "Center",
"ComingSoon": "Coming soon...",
"ComposerFrom": "From: ",
Expand Down Expand Up @@ -278,6 +279,7 @@
"Info_UnsubscribeSuccessMessage": "Successfully unsubscribed from {0}.",
"Info_UnsubscribeErrorMessage": "Failed to unsubscribe",
"Info_CantDeletePrimaryAliasMessage": "Primary alias can't be deleted. Please change your alias before deleting this one",
"Info_MailListSizeResetSuccessMessage": "The Mail List size has been reset.",
"ImapAdvancedSetupDialog_AuthenticationMethod": "Authentication method",
"ImapAdvancedSetupDialog_ConnectionSecurity": "Connection security",
"ImapAuthenticationMethod_Auto": "Auto",
Expand Down Expand Up @@ -480,8 +482,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",
Expand Down
18 changes: 14 additions & 4 deletions Wino.Core.Domain/Translator.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions Wino.Mail.ViewModels/MailListPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public partial class MailListPageViewModel : BaseViewModel,
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;
Expand Down Expand Up @@ -120,6 +120,12 @@ public partial class MailListPageViewModel : BaseViewModel,
[ObservableProperty]
private string barMessage;

[ObservableProperty]
private double mailListLength = 420;

[ObservableProperty]
private double maxMailListLength = 1200;

[ObservableProperty]
private string barTitle;

Expand All @@ -141,7 +147,7 @@ public partial class MailListPageViewModel : BaseViewModel,
public MailListPageViewModel(IDialogService dialogService,
IWinoNavigationService navigationService,
IMailService mailService,
IStatePersistanceService statePersistanceService,
IStatePersistanceService statePersistenceService,
IFolderService folderService,
IThreadingStrategyProvider threadingStrategyProvider,
IContextMenuItemService contextMenuItemService,
Expand All @@ -152,7 +158,7 @@ public MailListPageViewModel(IDialogService dialogService,
{
PreferencesService = preferencesService;
_winoServerConnectionManager = winoServerConnectionManager;
StatePersistanceService = statePersistanceService;
StatePersistenceService = statePersistenceService;
NavigationService = navigationService;

_mailService = mailService;
Expand All @@ -165,6 +171,8 @@ public MailListPageViewModel(IDialogService dialogService,
SelectedFilterOption = FilterOptions[0];
SelectedSortingOption = SortingOptions[0];

mailListLength = statePersistenceService.MailListPaneLength;

selectionChangedObservable = Observable.FromEventPattern<NotifyCollectionChangedEventArgs>(SelectedItems, nameof(SelectedItems.CollectionChanged));
selectionChangedObservable
.Throttle(TimeSpan.FromMilliseconds(100))
Expand Down Expand Up @@ -257,7 +265,7 @@ private async void ActiveMailItemChanged(MailItemViewModel selectedMailItemViewM
{
if (_activeMailItem == selectedMailItemViewModel) return;

// Don't update active mail item if Ctrl key is pressed or multi selection is ennabled.
// Don't update active mail item if Ctrl key is pressed or multi selection is enabled.
// User is probably trying to select multiple items.
// This is not the same behavior in Windows Mail,
// but it's a trash behavior.
Expand All @@ -266,7 +274,7 @@ private async void ActiveMailItemChanged(MailItemViewModel selectedMailItemViewM

bool isMultiSelecting = isCtrlKeyPressed || IsMultiSelectionModeEnabled;

if (isMultiSelecting ? StatePersistanceService.IsReaderNarrowed : false)
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());
Expand Down
37 changes: 14 additions & 23 deletions Wino.Mail.ViewModels/PersonalizationPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,24 @@ public partial class PersonalizationPageViewModel : BaseViewModel

public bool IsSelectedWindowsAccentColor => SelectedAppColor == Colors.LastOrDefault();

public ObservableCollection<AppColorViewModel> Colors { get; set; } = new ObservableCollection<AppColorViewModel>();
public ObservableCollection<AppColorViewModel> Colors { get; set; } = [];

public List<ElementThemeContainer> ElementThemes { get; set; } = new List<ElementThemeContainer>()
{
public List<ElementThemeContainer> 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<MailListPaneLengthPreferences> PaneLengths { get; set; } = new List<MailListPaneLengthPreferences>()
{
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<MailListDisplayMode> InformationDisplayModes { get; set; } = new List<MailListDisplayMode>()
{
public List<MailListDisplayMode> InformationDisplayModes { get; set; } =
[
MailListDisplayMode.Compact,
MailListDisplayMode.Medium,
MailListDisplayMode.Spacious
};
];

public List<AppThemeBase> AppThemes { get; set; }

[ObservableProperty]
private MailListPaneLengthPreferences selectedMailListPaneLength;

[ObservableProperty]
private ElementThemeContainer selectedElementTheme;

Expand Down Expand Up @@ -123,6 +110,13 @@ public AppThemeBase SelectedAppTheme

#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,
Expand Down Expand Up @@ -179,7 +173,6 @@ private void SetInitialValues()
{
SelectedElementTheme = ElementThemes.Find(a => a.NativeTheme == _themeService.RootTheme);
SelectedInfoDisplayMode = PreferencesService.MailItemDisplayMode;
SelectedMailListPaneLength = PaneLengths.Find(a => a.Length == StatePersistanceService.MailListPaneLength);

var currentAccentColor = _themeService.AccentColor;

Expand Down Expand Up @@ -289,8 +282,6 @@ private void PersonalizationSettingsUpdated(object sender, System.ComponentModel
{
_themeService.CurrentApplicationThemeId = SelectedAppTheme.Id;
}
else if (e.PropertyName == nameof(SelectedMailListPaneLength) && SelectedMailListPaneLength != null)
StatePersistanceService.MailListPaneLength = SelectedMailListPaneLength.Length;
else
{
if (e.PropertyName == nameof(SelectedInfoDisplayMode))
Expand Down
27 changes: 27 additions & 0 deletions Wino.Mail/Converters/GridLengthConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml;

namespace Wino.Converters
{
public class GridLengthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is double doubleValue)
{
return new GridLength(doubleValue);
}
return new GridLength(1, GridUnitType.Auto);
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is GridLength gridLength)
{
return gridLength.Value;
}
return 0.0;
}
}
}
1 change: 1 addition & 0 deletions Wino.Mail/Styles/Converters.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
xmlns:converters="using:Wino.Converters">
<converters:ReverseBooleanToVisibilityConverter x:Key="ReverseBooleanToVisibilityConverter" />
<converters:ReverseBooleanConverter x:Key="ReverseBooleanConverter" />
<converters:GridLengthConverter x:Key="GridLengthConverter" />
</ResourceDictionary>
Loading

0 comments on commit d623129

Please sign in to comment.