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_TryAgain": "Try Again",
"Buttons_Yes": "Yes",
"Buttons_Reset": "Reset",
"Center": "Center",
"ComingSoon": "Coming soon...",
"ComposerFrom": "From: ",
@@ -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",
@@ -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",

View File

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

View File

@@ -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;
@@ -120,6 +120,12 @@ namespace Wino.Mail.ViewModels
[ObservableProperty]
private string barMessage;
[ObservableProperty]
private double mailListLength = 420;
[ObservableProperty]
private double maxMailListLength = 1200;
[ObservableProperty]
private string barTitle;
@@ -141,7 +147,7 @@ namespace Wino.Mail.ViewModels
public MailListPageViewModel(IDialogService dialogService,
IWinoNavigationService navigationService,
IMailService mailService,
IStatePersistanceService statePersistanceService,
IStatePersistanceService statePersistenceService,
IFolderService folderService,
IThreadingStrategyProvider threadingStrategyProvider,
IContextMenuItemService contextMenuItemService,
@@ -152,7 +158,7 @@ namespace Wino.Mail.ViewModels
{
PreferencesService = preferencesService;
_winoServerConnectionManager = winoServerConnectionManager;
StatePersistanceService = statePersistanceService;
StatePersistenceService = statePersistenceService;
NavigationService = navigationService;
_mailService = mailService;
@@ -165,6 +171,8 @@ namespace Wino.Mail.ViewModels
SelectedFilterOption = FilterOptions[0];
SelectedSortingOption = SortingOptions[0];
mailListLength = statePersistenceService.MailListPaneLength;
selectionChangedObservable = Observable.FromEventPattern<NotifyCollectionChangedEventArgs>(SelectedItems, nameof(SelectedItems.CollectionChanged));
selectionChangedObservable
.Throttle(TimeSpan.FromMilliseconds(100))
@@ -257,7 +265,7 @@ namespace Wino.Mail.ViewModels
{
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.
@@ -266,7 +274,7 @@ namespace Wino.Mail.ViewModels
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());

View File

@@ -25,37 +25,24 @@ namespace Wino.Mail.ViewModels
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;
@@ -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))

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">
<converters:ReverseBooleanToVisibilityConverter x:Key="ReverseBooleanToVisibilityConverter" />
<converters:ReverseBooleanConverter x:Key="ReverseBooleanConverter" />
<converters:GridLengthConverter x:Key="GridLengthConverter" />
</ResourceDictionary>

View File

@@ -6,6 +6,7 @@
xmlns:collections="using:CommunityToolkit.Mvvm.Collections"
xmlns:controls="using:Wino.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:Wino.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:domain="using:Wino.Core.Domain"
xmlns:enums="using:Wino.Core.Domain.Enums"
@@ -20,9 +21,8 @@
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
xmlns:viewModelData="using:Wino.Mail.ViewModels.Data"
xmlns:wino="using:Wino"
xmlns:converters="using:Wino.Converters"
x:Name="root"
Loaded="MailListPageLoaded"
SizeChanged="PageSizeChanged"
mc:Ignorable="d">
<Page.Resources>
@@ -181,11 +181,11 @@
<DataTemplate x:DataType="viewModelData:ThreadMailItemViewModel">
<controls:WinoExpander
x:Name="ThreadExpander"
Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
BackgroundSizing="InnerBorderEdge"
BorderThickness="0"
Padding="0"
IsExpanded="{x:Bind IsThreadExpanded, Mode=TwoWay}">
<muxc:Expander.Header>
<controls:MailItemDisplayInformationControl
@@ -276,9 +276,9 @@
<AutoSuggestBox
x:Name="SearchBar"
Margin="2,0,-2,0"
VerticalAlignment="Center"
BorderBrush="Transparent"
Margin="2,0,-2,0"
GotFocus="SearchBoxFocused"
LostFocus="SearchBarUnfocused"
PlaceholderText="{x:Bind domain:Translator.SearchBarPlaceholder}"
@@ -296,23 +296,20 @@
<Grid x:Name="RootGrid" Padding="0,0,0,7">
<Grid.ColumnDefinitions>
<ColumnDefinition
x:Name="ReaderColumn"
Width="*"
MaxWidth="{x:Bind ViewModel.StatePersistanceService.MailListPaneLength, Mode=OneWay}" />
<ColumnDefinition x:Name="MailListColumn" Width="{x:Bind ViewModel.MailListLength, Mode=OneWay, Converter={StaticResource GridLengthConverter}}" />
<ColumnDefinition x:Name="RendererColumn" Width="*" />
</Grid.ColumnDefinitions>
<!-- Mail Items -->
<Border
x:Name="ReaderGridContainer"
x:Name="MailListContainer"
Grid.Column="0"
Padding="5,0,0,0"
Background="{ThemeResource WinoContentZoneBackgroud}"
BorderBrush="{StaticResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="7">
<Grid x:Name="ReaderGrid">
<Grid x:Name="MailListGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -604,11 +601,11 @@
<SemanticZoom x:Name="SemanticZoomContainer" CanChangeViews="{x:Bind ViewModel.PreferencesService.IsSemanticZoomEnabled, Mode=OneWay}">
<SemanticZoom.ZoomedInView>
<listview:WinoListView
ui:ScrollViewerExtensions.VerticalScrollBarMargin="0"
x:Name="MailListView"
HorizontalContentAlignment="Stretch"
ui:ScrollViewerExtensions.EnableMiddleClickScrolling="True"
ui:ListViewExtensions.ItemContainerStretchDirection="Horizontal"
ui:ScrollViewerExtensions.EnableMiddleClickScrolling="True"
ui:ScrollViewerExtensions.VerticalScrollBarMargin="0"
ItemDeletedCommand="{x:Bind ViewModel.MailOperationCommand}"
ItemTemplateSelector="{StaticResource MailItemDisplaySelector}"
ItemsSource="{x:Bind MailCollectionViewSource.View, Mode=OneWay}"
@@ -684,74 +681,39 @@
</Grid>
</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 -->
<Frame x:Name="RenderingFrame" IsNavigationStackEnabled="False" />
<!-- No Mail Selected Message -->
<StackPanel
x:Name="NoMailSelectedPanel"
Opacity="0.5"
Spacing="6"
HorizontalAlignment="Center"
VerticalAlignment="Center">
VerticalAlignment="Center"
Opacity="0.5"
Spacing="6">
<controls:WinoFontIcon Icon="Mail" FontSize="80" />
<controls:WinoFontIcon FontSize="80" Icon="Mail" />
<TextBlock
x:Name="CountTextBlock"
HorizontalAlignment="Center"
FontSize="31"
Text="{x:Bind ViewModel.SelectedMessageText, Mode=OneWay}"
Style="{StaticResource SubheaderTextBlockStyle}"
x:Name="CountTextBlock" />
Text="{x:Bind ViewModel.SelectedMessageText, Mode=OneWay}" />
</StackPanel>
</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>
</abstract:MailListPageAbstract>

View File

@@ -40,11 +40,9 @@ namespace Wino.Views
IRecipient<ShellStateUpdated>,
IRecipient<DisposeRenderingFrameRequested>
{
private const string NarrowVisualStateKey = "NarrowState";
private const string AdaptivenessStatesKey = "AdaptiveStates";
private const double RENDERING_COLUMN_MIN_WIDTH = 300;
private IStatePersistanceService StatePersistanceService { get; } = App.Current.Services.GetService<IStatePersistanceService>();
private IPreferencesService PreferencesService { get; } = App.Current.Services.GetService<IPreferencesService>();
private IStatePersistanceService StatePersistenceService { get; } = App.Current.Services.GetService<IStatePersistanceService>();
private IKeyPressService KeyPressService { get; } = App.Current.Services.GetService<IKeyPressService>();
public MailListPage()
@@ -90,7 +88,7 @@ namespace Wino.Views
SelectAllCheckbox.Unchecked += SelectAllCheckboxUnchecked;
}
private void SelectionModeToggleChecked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
private void SelectionModeToggleChecked(object sender, RoutedEventArgs e)
{
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);
}
private void SelectAllCheckboxChecked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
private void SelectAllCheckboxChecked(object sender, RoutedEventArgs e)
{
MailListView.SelectAllWino();
}
private void SelectAllCheckboxUnchecked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
private void SelectAllCheckboxUnchecked(object sender, RoutedEventArgs e)
{
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)
{
// Single item in thread selected.
@@ -446,21 +373,6 @@ namespace Wino.Views
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)
{
if (args.Key == Windows.System.VirtualKey.Delete)
@@ -568,5 +480,89 @@ namespace Wino.Views
{
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\WinoFontIcon.cs" />
<Compile Include="Controls\WinoSwipeControlItems.cs" />
<Compile Include="Converters\GridLengthConverter.cs" />
<Compile Include="Dialogs\AccountEditDialog.xaml.cs">
<DependentUpon>AccountEditDialog.xaml</DependentUpon>
</Compile>