Merge pull request #325 from bkaankose/features/mail-list-splitter

Mail List splitter
This commit is contained in:
Burak Kaan Köse
2024-08-19 21:21:28 +02:00
committed by GitHub
11 changed files with 222 additions and 230 deletions

View File

@@ -1,4 +0,0 @@
namespace Wino.Core.Domain.Models.Personalization
{
public record MailListPaneLengthPreferences(string Title, double Length);
}

View File

@@ -45,6 +45,7 @@
"Buttons_SignIn": "Sign In", "Buttons_SignIn": "Sign In",
"Buttons_TryAgain": "Try Again", "Buttons_TryAgain": "Try Again",
"Buttons_Yes": "Yes", "Buttons_Yes": "Yes",
"Buttons_Reset": "Reset",
"Center": "Center", "Center": "Center",
"ComingSoon": "Coming soon...", "ComingSoon": "Coming soon...",
"ComposerFrom": "From: ", "ComposerFrom": "From: ",
@@ -278,6 +279,7 @@
"Info_UnsubscribeSuccessMessage": "Successfully unsubscribed from {0}.", "Info_UnsubscribeSuccessMessage": "Successfully unsubscribed from {0}.",
"Info_UnsubscribeErrorMessage": "Failed to unsubscribe", "Info_UnsubscribeErrorMessage": "Failed to unsubscribe",
"Info_CantDeletePrimaryAliasMessage": "Primary alias can't be deleted. Please change your alias before deleting this one", "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_AuthenticationMethod": "Authentication method",
"ImapAdvancedSetupDialog_ConnectionSecurity": "Connection security", "ImapAdvancedSetupDialog_ConnectionSecurity": "Connection security",
"ImapAuthenticationMethod_Auto": "Auto", "ImapAuthenticationMethod_Auto": "Auto",
@@ -480,8 +482,8 @@
"SettingsNoAccountSetupMessage": "You didn't setup any accounts yet.", "SettingsNoAccountSetupMessage": "You didn't setup any accounts yet.",
"SettingsNotifications_Description": "Turn on or off notifications for this account.", "SettingsNotifications_Description": "Turn on or off notifications for this account.",
"SettingsNotifications_Title": "Notifications", "SettingsNotifications_Title": "Notifications",
"SettingsPaneLength_Description": "Change the width of the mail list.", "SettingsPaneLengthReset_Description": "Reset the size of the mail list to original if you have issues with it.",
"SettingsPaneLength_Title": "Mail List Pane Length", "SettingsPaneLengthReset_Title": "Reset Mail List Size",
"SettingsPaypal_Description": "Show much more love ❤️ All donations are appreciated.", "SettingsPaypal_Description": "Show much more love ❤️ All donations are appreciated.",
"SettingsPaypal_Title": "Donate via PayPal", "SettingsPaypal_Title": "Donate via PayPal",
"SettingsPersonalizationMailDisplayCompactMode": "Compact Mode", "SettingsPersonalizationMailDisplayCompactMode": "Compact Mode",

View File

@@ -248,6 +248,11 @@ namespace Wino.Core.Domain
/// </summary> /// </summary>
public static string Buttons_Yes => Resources.GetTranslatedString(@"Buttons_Yes"); public static string Buttons_Yes => Resources.GetTranslatedString(@"Buttons_Yes");
/// <summary>
/// Reset
/// </summary>
public static string Buttons_Reset => Resources.GetTranslatedString(@"Buttons_Reset");
/// <summary> /// <summary>
/// Center /// Center
/// </summary> /// </summary>
@@ -1413,6 +1418,11 @@ namespace Wino.Core.Domain
/// </summary> /// </summary>
public static string Info_CantDeletePrimaryAliasMessage => Resources.GetTranslatedString(@"Info_CantDeletePrimaryAliasMessage"); public static string Info_CantDeletePrimaryAliasMessage => Resources.GetTranslatedString(@"Info_CantDeletePrimaryAliasMessage");
/// <summary>
/// The Mail List size has been reset.
/// </summary>
public static string Info_MailListSizeResetSuccessMessage => Resources.GetTranslatedString(@"Info_MailListSizeResetSuccessMessage");
/// <summary> /// <summary>
/// Authentication method /// Authentication method
/// </summary> /// </summary>
@@ -2424,14 +2434,14 @@ namespace Wino.Core.Domain
public static string SettingsNotifications_Title => Resources.GetTranslatedString(@"SettingsNotifications_Title"); public static string SettingsNotifications_Title => Resources.GetTranslatedString(@"SettingsNotifications_Title");
/// <summary> /// <summary>
/// Change the width of the mail list. /// Reset the size of the mail list to original if you have issues with it.
/// </summary> /// </summary>
public static string SettingsPaneLength_Description => Resources.GetTranslatedString(@"SettingsPaneLength_Description"); public static string SettingsPaneLengthReset_Description => Resources.GetTranslatedString(@"SettingsPaneLengthReset_Description");
/// <summary> /// <summary>
/// Mail List Pane Length /// Reset Mail List Size
/// </summary> /// </summary>
public static string SettingsPaneLength_Title => Resources.GetTranslatedString(@"SettingsPaneLength_Title"); public static string SettingsPaneLengthReset_Title => Resources.GetTranslatedString(@"SettingsPaneLengthReset_Title");
/// <summary> /// <summary>
/// Show much more love ❤️ All donations are appreciated. /// Show much more love ❤️ All donations are appreciated.

View File

@@ -68,7 +68,7 @@ namespace Wino.Mail.ViewModels
private CancellationTokenSource listManipulationCancellationTokenSource = new CancellationTokenSource(); private CancellationTokenSource listManipulationCancellationTokenSource = new CancellationTokenSource();
public IWinoNavigationService NavigationService { get; } public IWinoNavigationService NavigationService { get; }
public IStatePersistanceService StatePersistanceService { get; } public IStatePersistanceService StatePersistenceService { get; }
public IPreferencesService PreferencesService { get; } public IPreferencesService PreferencesService { get; }
private readonly IMailService _mailService; private readonly IMailService _mailService;
@@ -120,6 +120,12 @@ namespace Wino.Mail.ViewModels
[ObservableProperty] [ObservableProperty]
private string barMessage; private string barMessage;
[ObservableProperty]
private double mailListLength = 420;
[ObservableProperty]
private double maxMailListLength = 1200;
[ObservableProperty] [ObservableProperty]
private string barTitle; private string barTitle;
@@ -141,7 +147,7 @@ namespace Wino.Mail.ViewModels
public MailListPageViewModel(IDialogService dialogService, public MailListPageViewModel(IDialogService dialogService,
IWinoNavigationService navigationService, IWinoNavigationService navigationService,
IMailService mailService, IMailService mailService,
IStatePersistanceService statePersistanceService, IStatePersistanceService statePersistenceService,
IFolderService folderService, IFolderService folderService,
IThreadingStrategyProvider threadingStrategyProvider, IThreadingStrategyProvider threadingStrategyProvider,
IContextMenuItemService contextMenuItemService, IContextMenuItemService contextMenuItemService,
@@ -152,7 +158,7 @@ namespace Wino.Mail.ViewModels
{ {
PreferencesService = preferencesService; PreferencesService = preferencesService;
_winoServerConnectionManager = winoServerConnectionManager; _winoServerConnectionManager = winoServerConnectionManager;
StatePersistanceService = statePersistanceService; StatePersistenceService = statePersistenceService;
NavigationService = navigationService; NavigationService = navigationService;
_mailService = mailService; _mailService = mailService;
@@ -165,6 +171,8 @@ namespace Wino.Mail.ViewModels
SelectedFilterOption = FilterOptions[0]; SelectedFilterOption = FilterOptions[0];
SelectedSortingOption = SortingOptions[0]; SelectedSortingOption = SortingOptions[0];
mailListLength = statePersistenceService.MailListPaneLength;
selectionChangedObservable = Observable.FromEventPattern<NotifyCollectionChangedEventArgs>(SelectedItems, nameof(SelectedItems.CollectionChanged)); selectionChangedObservable = Observable.FromEventPattern<NotifyCollectionChangedEventArgs>(SelectedItems, nameof(SelectedItems.CollectionChanged));
selectionChangedObservable selectionChangedObservable
.Throttle(TimeSpan.FromMilliseconds(100)) .Throttle(TimeSpan.FromMilliseconds(100))
@@ -257,7 +265,7 @@ namespace Wino.Mail.ViewModels
{ {
if (_activeMailItem == selectedMailItemViewModel) return; 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. // User is probably trying to select multiple items.
// This is not the same behavior in Windows Mail, // This is not the same behavior in Windows Mail,
// but it's a trash behavior. // but it's a trash behavior.
@@ -266,7 +274,7 @@ namespace Wino.Mail.ViewModels
bool isMultiSelecting = isCtrlKeyPressed || IsMultiSelectionModeEnabled; 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. // Don't change the active mail item if the reader is narrowed, but just update the shell.
Messenger.Send(new ShellStateUpdated()); Messenger.Send(new ShellStateUpdated());

View File

@@ -25,37 +25,24 @@ namespace Wino.Mail.ViewModels
public bool IsSelectedWindowsAccentColor => SelectedAppColor == Colors.LastOrDefault(); 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.Light, Translator.ElementTheme_Light),
new ElementThemeContainer(ApplicationElementTheme.Dark, Translator.ElementTheme_Dark), new ElementThemeContainer(ApplicationElementTheme.Dark, Translator.ElementTheme_Dark),
new ElementThemeContainer(ApplicationElementTheme.Default, Translator.ElementTheme_Default), new ElementThemeContainer(ApplicationElementTheme.Default, Translator.ElementTheme_Default),
}; ];
public List<MailListPaneLengthPreferences> PaneLengths { get; set; } = new List<MailListPaneLengthPreferences>() public List<MailListDisplayMode> InformationDisplayModes { get; set; } =
{ [
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>()
{
MailListDisplayMode.Compact, MailListDisplayMode.Compact,
MailListDisplayMode.Medium, MailListDisplayMode.Medium,
MailListDisplayMode.Spacious MailListDisplayMode.Spacious
}; ];
public List<AppThemeBase> AppThemes { get; set; } public List<AppThemeBase> AppThemes { get; set; }
[ObservableProperty]
private MailListPaneLengthPreferences selectedMailListPaneLength;
[ObservableProperty] [ObservableProperty]
private ElementThemeContainer selectedElementTheme; private ElementThemeContainer selectedElementTheme;
@@ -123,6 +110,13 @@ namespace Wino.Mail.ViewModels
#endregion #endregion
[RelayCommand]
private void ResetMailListPaneLength()
{
StatePersistanceService.MailListPaneLength = 420;
DialogService.InfoBarMessage(Translator.GeneralTitle_Info, Translator.Info_MailListSizeResetSuccessMessage, InfoBarMessageType.Success);
}
public AsyncRelayCommand CreateCustomThemeCommand { get; set; } public AsyncRelayCommand CreateCustomThemeCommand { get; set; }
public PersonalizationPageViewModel(IDialogService dialogService, public PersonalizationPageViewModel(IDialogService dialogService,
IStatePersistanceService statePersistanceService, IStatePersistanceService statePersistanceService,
@@ -179,7 +173,6 @@ namespace Wino.Mail.ViewModels
{ {
SelectedElementTheme = ElementThemes.Find(a => a.NativeTheme == _themeService.RootTheme); SelectedElementTheme = ElementThemes.Find(a => a.NativeTheme == _themeService.RootTheme);
SelectedInfoDisplayMode = PreferencesService.MailItemDisplayMode; SelectedInfoDisplayMode = PreferencesService.MailItemDisplayMode;
SelectedMailListPaneLength = PaneLengths.Find(a => a.Length == StatePersistanceService.MailListPaneLength);
var currentAccentColor = _themeService.AccentColor; var currentAccentColor = _themeService.AccentColor;
@@ -289,8 +282,6 @@ namespace Wino.Mail.ViewModels
{ {
_themeService.CurrentApplicationThemeId = SelectedAppTheme.Id; _themeService.CurrentApplicationThemeId = SelectedAppTheme.Id;
} }
else if (e.PropertyName == nameof(SelectedMailListPaneLength) && SelectedMailListPaneLength != null)
StatePersistanceService.MailListPaneLength = SelectedMailListPaneLength.Length;
else else
{ {
if (e.PropertyName == nameof(SelectedInfoDisplayMode)) if (e.PropertyName == nameof(SelectedInfoDisplayMode))

View File

@@ -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;
}
}
}

View File

@@ -4,4 +4,5 @@
xmlns:converters="using:Wino.Converters"> xmlns:converters="using:Wino.Converters">
<converters:ReverseBooleanToVisibilityConverter x:Key="ReverseBooleanToVisibilityConverter" /> <converters:ReverseBooleanToVisibilityConverter x:Key="ReverseBooleanToVisibilityConverter" />
<converters:ReverseBooleanConverter x:Key="ReverseBooleanConverter" /> <converters:ReverseBooleanConverter x:Key="ReverseBooleanConverter" />
<converters:GridLengthConverter x:Key="GridLengthConverter" />
</ResourceDictionary> </ResourceDictionary>

View File

@@ -6,6 +6,7 @@
xmlns:collections="using:CommunityToolkit.Mvvm.Collections" xmlns:collections="using:CommunityToolkit.Mvvm.Collections"
xmlns:controls="using:Wino.Controls" xmlns:controls="using:Wino.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls" xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:Wino.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:domain="using:Wino.Core.Domain" xmlns:domain="using:Wino.Core.Domain"
xmlns:enums="using:Wino.Core.Domain.Enums" xmlns:enums="using:Wino.Core.Domain.Enums"
@@ -20,9 +21,8 @@
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
xmlns:viewModelData="using:Wino.Mail.ViewModels.Data" xmlns:viewModelData="using:Wino.Mail.ViewModels.Data"
xmlns:wino="using:Wino" xmlns:wino="using:Wino"
xmlns:converters="using:Wino.Converters"
x:Name="root" x:Name="root"
Loaded="MailListPageLoaded" SizeChanged="PageSizeChanged"
mc:Ignorable="d"> mc:Ignorable="d">
<Page.Resources> <Page.Resources>
@@ -181,11 +181,11 @@
<DataTemplate x:DataType="viewModelData:ThreadMailItemViewModel"> <DataTemplate x:DataType="viewModelData:ThreadMailItemViewModel">
<controls:WinoExpander <controls:WinoExpander
x:Name="ThreadExpander" x:Name="ThreadExpander"
Padding="0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
BackgroundSizing="InnerBorderEdge" BackgroundSizing="InnerBorderEdge"
BorderThickness="0" BorderThickness="0"
Padding="0"
IsExpanded="{x:Bind IsThreadExpanded, Mode=TwoWay}"> IsExpanded="{x:Bind IsThreadExpanded, Mode=TwoWay}">
<muxc:Expander.Header> <muxc:Expander.Header>
<controls:MailItemDisplayInformationControl <controls:MailItemDisplayInformationControl
@@ -276,9 +276,9 @@
<AutoSuggestBox <AutoSuggestBox
x:Name="SearchBar" x:Name="SearchBar"
Margin="2,0,-2,0"
VerticalAlignment="Center" VerticalAlignment="Center"
BorderBrush="Transparent" BorderBrush="Transparent"
Margin="2,0,-2,0"
GotFocus="SearchBoxFocused" GotFocus="SearchBoxFocused"
LostFocus="SearchBarUnfocused" LostFocus="SearchBarUnfocused"
PlaceholderText="{x:Bind domain:Translator.SearchBarPlaceholder}" PlaceholderText="{x:Bind domain:Translator.SearchBarPlaceholder}"
@@ -296,23 +296,20 @@
<Grid x:Name="RootGrid" Padding="0,0,0,7"> <Grid x:Name="RootGrid" Padding="0,0,0,7">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition <ColumnDefinition x:Name="MailListColumn" Width="{x:Bind ViewModel.MailListLength, Mode=OneWay, Converter={StaticResource GridLengthConverter}}" />
x:Name="ReaderColumn"
Width="*"
MaxWidth="{x:Bind ViewModel.StatePersistanceService.MailListPaneLength, Mode=OneWay}" />
<ColumnDefinition x:Name="RendererColumn" Width="*" /> <ColumnDefinition x:Name="RendererColumn" Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Mail Items --> <!-- Mail Items -->
<Border <Border
x:Name="ReaderGridContainer" x:Name="MailListContainer"
Grid.Column="0" Grid.Column="0"
Padding="5,0,0,0" Padding="5,0,0,0"
Background="{ThemeResource WinoContentZoneBackgroud}" Background="{ThemeResource WinoContentZoneBackgroud}"
BorderBrush="{StaticResource CardStrokeColorDefaultBrush}" BorderBrush="{StaticResource CardStrokeColorDefaultBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="7"> CornerRadius="7">
<Grid x:Name="ReaderGrid"> <Grid x:Name="MailListGrid">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@@ -604,11 +601,11 @@
<SemanticZoom x:Name="SemanticZoomContainer" CanChangeViews="{x:Bind ViewModel.PreferencesService.IsSemanticZoomEnabled, Mode=OneWay}"> <SemanticZoom x:Name="SemanticZoomContainer" CanChangeViews="{x:Bind ViewModel.PreferencesService.IsSemanticZoomEnabled, Mode=OneWay}">
<SemanticZoom.ZoomedInView> <SemanticZoom.ZoomedInView>
<listview:WinoListView <listview:WinoListView
ui:ScrollViewerExtensions.VerticalScrollBarMargin="0"
x:Name="MailListView" x:Name="MailListView"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
ui:ScrollViewerExtensions.EnableMiddleClickScrolling="True"
ui:ListViewExtensions.ItemContainerStretchDirection="Horizontal" ui:ListViewExtensions.ItemContainerStretchDirection="Horizontal"
ui:ScrollViewerExtensions.EnableMiddleClickScrolling="True"
ui:ScrollViewerExtensions.VerticalScrollBarMargin="0"
ItemDeletedCommand="{x:Bind ViewModel.MailOperationCommand}" ItemDeletedCommand="{x:Bind ViewModel.MailOperationCommand}"
ItemTemplateSelector="{StaticResource MailItemDisplaySelector}" ItemTemplateSelector="{StaticResource MailItemDisplaySelector}"
ItemsSource="{x:Bind MailCollectionViewSource.View, Mode=OneWay}" ItemsSource="{x:Bind MailCollectionViewSource.View, Mode=OneWay}"
@@ -684,74 +681,39 @@
</Grid> </Grid>
</Border> </Border>
<controls1:PropertySizer
x:Name="MailListSizer"
Grid.Column="1"
Width="16"
HorizontalAlignment="Left"
Binding="{x:Bind ViewModel.MailListLength, Mode=TwoWay}"
Canvas.ZIndex="20"
ManipulationCompleted="MailListSizerManipulationCompleted"
Maximum="{x:Bind ViewModel.MaxMailListLength, Mode=OneWay}"
Minimum="270"
Opacity="0" />
<Grid Grid.Column="1" x:Name="RenderingGrid"> <Grid x:Name="RenderingGrid" Grid.Column="1">
<!-- Mail Rendering Frame --> <!-- Mail Rendering Frame -->
<Frame x:Name="RenderingFrame" IsNavigationStackEnabled="False" /> <Frame x:Name="RenderingFrame" IsNavigationStackEnabled="False" />
<!-- No Mail Selected Message --> <!-- No Mail Selected Message -->
<StackPanel <StackPanel
x:Name="NoMailSelectedPanel" x:Name="NoMailSelectedPanel"
Opacity="0.5"
Spacing="6"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center"> VerticalAlignment="Center"
Opacity="0.5"
Spacing="6">
<controls:WinoFontIcon Icon="Mail" FontSize="80" /> <controls:WinoFontIcon FontSize="80" Icon="Mail" />
<TextBlock <TextBlock
x:Name="CountTextBlock"
HorizontalAlignment="Center" HorizontalAlignment="Center"
FontSize="31" FontSize="31"
Text="{x:Bind ViewModel.SelectedMessageText, Mode=OneWay}"
Style="{StaticResource SubheaderTextBlockStyle}" Style="{StaticResource SubheaderTextBlockStyle}"
x:Name="CountTextBlock" /> Text="{x:Bind ViewModel.SelectedMessageText, Mode=OneWay}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="AdaptiveStates" CurrentStateChanged="AdaptivenessChanged">
<VisualState x:Name="NormalState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{x:Bind helpers:XamlHelpers.MailListAdaptivityConverter(ViewModel.StatePersistanceService.MailListPaneLength), Mode=OneWay}" />
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowState">
<VisualState.Setters>
<Setter Target="ReaderGrid.MaxWidth" Value="10000" />
</VisualState.Setters>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
<!-- Pane open adjustments -->
<VisualStateGroup x:Name="PaneStates">
<VisualState x:Name="PaneOpened">
<VisualState.Setters>
<!--<Setter Target="RootGrid.Margin" Value="-6,0,0,0" />-->
<Setter Target="ReaderGrid.Margin" Value="-4,0,0,0" />
</VisualState.Setters>
<VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind PreferencesService.IsNavigationPaneOpened, Mode=OneWay}" />
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="PaneClosed" />
</VisualStateGroup>
<!-- Mail reader states -->
<VisualStateGroup x:Name="ReaderStates">
<VisualState x:Name="ReaderActive">
<VisualState.Setters>
<Setter Target="ReaderGrid.CornerRadius" Value="0" />
</VisualState.Setters>
<VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind StatePersistanceService.IsReadingMail, Mode=OneWay}" />
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid> </Grid>
</abstract:MailListPageAbstract> </abstract:MailListPageAbstract>

View File

@@ -40,11 +40,9 @@ namespace Wino.Views
IRecipient<ShellStateUpdated>, IRecipient<ShellStateUpdated>,
IRecipient<DisposeRenderingFrameRequested> IRecipient<DisposeRenderingFrameRequested>
{ {
private const string NarrowVisualStateKey = "NarrowState"; private const double RENDERING_COLUMN_MIN_WIDTH = 300;
private const string AdaptivenessStatesKey = "AdaptiveStates";
private IStatePersistanceService StatePersistanceService { get; } = App.Current.Services.GetService<IStatePersistanceService>(); private IStatePersistanceService StatePersistenceService { get; } = App.Current.Services.GetService<IStatePersistanceService>();
private IPreferencesService PreferencesService { get; } = App.Current.Services.GetService<IPreferencesService>();
private IKeyPressService KeyPressService { get; } = App.Current.Services.GetService<IKeyPressService>(); private IKeyPressService KeyPressService { get; } = App.Current.Services.GetService<IKeyPressService>();
public MailListPage() public MailListPage()
@@ -90,7 +88,7 @@ namespace Wino.Views
SelectAllCheckbox.Unchecked += SelectAllCheckboxUnchecked; SelectAllCheckbox.Unchecked += SelectAllCheckboxUnchecked;
} }
private void SelectionModeToggleChecked(object sender, Windows.UI.Xaml.RoutedEventArgs e) private void SelectionModeToggleChecked(object sender, RoutedEventArgs e)
{ {
ChangeSelectionMode(ListViewSelectionMode.Multiple); ChangeSelectionMode(ListViewSelectionMode.Multiple);
} }
@@ -132,92 +130,21 @@ namespace Wino.Views
} }
} }
private void SelectionModeToggleUnchecked(object sender, Windows.UI.Xaml.RoutedEventArgs e) private void SelectionModeToggleUnchecked(object sender, RoutedEventArgs e)
{ {
ChangeSelectionMode(ListViewSelectionMode.Extended); ChangeSelectionMode(ListViewSelectionMode.Extended);
} }
private void SelectAllCheckboxChecked(object sender, Windows.UI.Xaml.RoutedEventArgs e) private void SelectAllCheckboxChecked(object sender, RoutedEventArgs e)
{ {
MailListView.SelectAllWino(); MailListView.SelectAllWino();
} }
private void SelectAllCheckboxUnchecked(object sender, Windows.UI.Xaml.RoutedEventArgs e) private void SelectAllCheckboxUnchecked(object sender, RoutedEventArgs e)
{ {
MailListView.ClearSelections(); MailListView.ClearSelections();
} }
#region Mostly UI
private void UpdateAdaptiveness()
{
bool shouldDisplayNoMessagePanel, shouldDisplayMailingList, shouldDisplayRenderingFrame;
// This is the smallest state UI can get.
// Either mailing list or rendering grid is visible.
if (StatePersistanceService.IsReaderNarrowed)
{
// Start visibility checks by no message panel.
bool isMultiSelectionEnabled = ViewModel.IsMultiSelectionModeEnabled || KeyPressService.IsCtrlKeyPressed();
shouldDisplayMailingList = isMultiSelectionEnabled ? true : (!ViewModel.HasSelectedItems || ViewModel.HasMultipleItemSelections);
shouldDisplayNoMessagePanel = shouldDisplayMailingList ? false : !ViewModel.HasSelectedItems || ViewModel.HasMultipleItemSelections;
shouldDisplayRenderingFrame = shouldDisplayMailingList ? false : !shouldDisplayNoMessagePanel;
}
else
{
shouldDisplayMailingList = true;
shouldDisplayNoMessagePanel = !ViewModel.HasSelectedItems || ViewModel.HasMultipleItemSelections;
shouldDisplayRenderingFrame = !shouldDisplayNoMessagePanel;
}
ReaderGridContainer.Visibility = shouldDisplayMailingList ? Visibility.Visible : Visibility.Collapsed;
RenderingFrame.Visibility = shouldDisplayRenderingFrame ? Visibility.Visible : Visibility.Collapsed;
NoMailSelectedPanel.Visibility = shouldDisplayNoMessagePanel ? Visibility.Visible : Visibility.Collapsed;
if (StatePersistanceService.IsReaderNarrowed)
{
if (RenderingFrame.Visibility == Visibility.Visible && ReaderGridContainer.Visibility == Visibility.Collapsed)
{
// Extend rendering frame to full width.
Grid.SetColumn(RenderingGrid, 0);
Grid.SetColumnSpan(RenderingGrid, 2);
Grid.SetColumn(ReaderGrid, 0);
Grid.SetColumnSpan(ReaderGrid, 2);
}
else if (RenderingFrame.Visibility == Visibility.Collapsed && NoMailSelectedPanel.Visibility == Visibility.Collapsed)
{
// Only mail list is available.
// Extend the mailing list.
Grid.SetColumn(ReaderGridContainer, 0);
Grid.SetColumnSpan(ReaderGridContainer, 2);
}
}
else
{
// Mailing list is always visible on the first part.
Grid.SetColumn(ReaderGridContainer, 0);
Grid.SetColumnSpan(ReaderGridContainer, 1);
// Rendering grid should take the rest of the space.
Grid.SetColumn(RenderingGrid, 1);
Grid.SetColumnSpan(RenderingGrid, 1);
}
}
private void AdaptivenessChanged(object sender, VisualStateChangedEventArgs e)
{
StatePersistanceService.IsReaderNarrowed = e.NewState.Name == "NarrowState";
UpdateAdaptiveness();
}
#endregion
void IRecipient<ResetSingleMailItemSelectionEvent>.Receive(ResetSingleMailItemSelectionEvent message) void IRecipient<ResetSingleMailItemSelectionEvent>.Receive(ResetSingleMailItemSelectionEvent message)
{ {
// Single item in thread selected. // Single item in thread selected.
@@ -446,21 +373,6 @@ namespace Wino.Views
SearchBar.PlaceholderText = Translator.SearchBarPlaceholder; SearchBar.PlaceholderText = Translator.SearchBarPlaceholder;
} }
private void MailListPageLoaded(object sender, RoutedEventArgs e)
{
// App might open with narrowed state.
// VSM will not trigger in this case.
// Set values to force updating adaptiveness.
var groups = VisualStateManager.GetVisualStateGroups(RootGrid);
var adaptiveState = groups.FirstOrDefault(a => a.Name == AdaptivenessStatesKey);
if (adaptiveState == null) return;
// This should force UpdateAdaptiveness call.
StatePersistanceService.IsReaderNarrowed = adaptiveState.CurrentState.Name == NarrowVisualStateKey;
}
private void ProcessMailItemKeyboardAccelerator(UIElement sender, ProcessKeyboardAcceleratorEventArgs args) private void ProcessMailItemKeyboardAccelerator(UIElement sender, ProcessKeyboardAcceleratorEventArgs args)
{ {
if (args.Key == Windows.System.VirtualKey.Delete) if (args.Key == Windows.System.VirtualKey.Delete)
@@ -568,5 +480,89 @@ namespace Wino.Views
{ {
ViewModel.NavigationService.Navigate(WinoPage.IdlePage, null, NavigationReferenceFrame.RenderingFrame, NavigationTransitionType.DrillIn); ViewModel.NavigationService.Navigate(WinoPage.IdlePage, null, NavigationReferenceFrame.RenderingFrame, NavigationTransitionType.DrillIn);
} }
private void PageSizeChanged(object sender, SizeChangedEventArgs e)
{
ViewModel.MaxMailListLength = e.NewSize.Width - RENDERING_COLUMN_MIN_WIDTH;
StatePersistenceService.IsReaderNarrowed = e.NewSize.Width < StatePersistenceService.MailListPaneLength + RENDERING_COLUMN_MIN_WIDTH;
UpdateAdaptiveness();
}
private void MailListSizerManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
StatePersistenceService.MailListPaneLength = ViewModel.MailListLength;
}
private void UpdateAdaptiveness()
{
bool shouldDisplayNoMessagePanel, shouldDisplayMailingList, shouldDisplayRenderingFrame;
bool isMultiSelectionEnabled = ViewModel.IsMultiSelectionModeEnabled || KeyPressService.IsCtrlKeyPressed();
// This is the smallest state UI can get.
// Either mailing list or rendering grid is visible.
if (StatePersistenceService.IsReaderNarrowed)
{
// Start visibility checks by no message panel.
shouldDisplayMailingList = isMultiSelectionEnabled ? true : (!ViewModel.HasSelectedItems || ViewModel.HasMultipleItemSelections);
shouldDisplayNoMessagePanel = shouldDisplayMailingList ? false : !ViewModel.HasSelectedItems || ViewModel.HasMultipleItemSelections;
shouldDisplayRenderingFrame = shouldDisplayMailingList ? false : !shouldDisplayNoMessagePanel;
}
else
{
shouldDisplayMailingList = true;
shouldDisplayNoMessagePanel = !ViewModel.HasSelectedItems || ViewModel.HasMultipleItemSelections;
shouldDisplayRenderingFrame = !shouldDisplayNoMessagePanel;
}
MailListContainer.Visibility = shouldDisplayMailingList ? Visibility.Visible : Visibility.Collapsed;
RenderingFrame.Visibility = shouldDisplayRenderingFrame ? Visibility.Visible : Visibility.Collapsed;
NoMailSelectedPanel.Visibility = shouldDisplayNoMessagePanel ? Visibility.Visible : Visibility.Collapsed;
if (StatePersistenceService.IsReaderNarrowed == true)
{
if (ViewModel.HasSingleItemSelection && !isMultiSelectionEnabled)
{
MailListColumn.Width = new GridLength(0);
RendererColumn.Width = new GridLength(1, GridUnitType.Star);
Grid.SetColumn(MailListContainer, 0);
Grid.SetColumnSpan(RenderingGrid, 2);
MailListContainer.Visibility = Visibility.Collapsed;
RenderingGrid.Visibility = Visibility.Visible;
}
else
{
MailListColumn.Width = new GridLength(1, GridUnitType.Star);
RendererColumn.Width = new GridLength(0);
Grid.SetColumnSpan(MailListContainer, 2);
MailListContainer.Margin = new Thickness(7, 0, 7, 0);
MailListContainer.Visibility = Visibility.Visible;
RenderingGrid.Visibility = Visibility.Collapsed;
SearchBar.Margin = new Thickness(8, 0, -2, 0);
MailListSizer.Visibility = Visibility.Collapsed;
}
}
else
{
MailListColumn.Width = new GridLength(StatePersistenceService.MailListPaneLength);
RendererColumn.Width = new GridLength(1, GridUnitType.Star);
MailListContainer.Margin = new Thickness(0, 0, 0, 0);
Grid.SetColumn(MailListContainer, 0);
Grid.SetColumn(RenderingGrid, 1);
Grid.SetColumnSpan(MailListContainer, 1);
Grid.SetColumnSpan(RenderingGrid, 1);
MailListContainer.Visibility = Visibility.Visible;
RenderingGrid.Visibility = Visibility.Visible;
SearchBar.Margin = new Thickness(2, 0, -2, 0);
MailListSizer.Visibility = Visibility.Visible;
}
}
} }
} }

File diff suppressed because one or more lines are too long

View File

@@ -249,6 +249,7 @@
<Compile Include="Controls\WinoFontIconSource.cs" /> <Compile Include="Controls\WinoFontIconSource.cs" />
<Compile Include="Controls\WinoFontIcon.cs" /> <Compile Include="Controls\WinoFontIcon.cs" />
<Compile Include="Controls\WinoSwipeControlItems.cs" /> <Compile Include="Controls\WinoSwipeControlItems.cs" />
<Compile Include="Converters\GridLengthConverter.cs" />
<Compile Include="Dialogs\AccountEditDialog.xaml.cs"> <Compile Include="Dialogs\AccountEditDialog.xaml.cs">
<DependentUpon>AccountEditDialog.xaml</DependentUpon> <DependentUpon>AccountEditDialog.xaml</DependentUpon>
</Compile> </Compile>