Couple UI Fixes (#255)
- Disabled UI navigation cache for all pages. - Restore the renderer<>composer page animation back. - IdlePage functionality into mail list page. - Couple bugfixes.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AppCenter;
|
||||
using Microsoft.AppCenter.Analytics;
|
||||
@@ -12,9 +11,7 @@ using Serilog;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.ApplicationModel.Core;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.Foundation.Metadata;
|
||||
using Windows.Globalization;
|
||||
using Windows.Storage;
|
||||
using Windows.System.Profile;
|
||||
using Windows.UI;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
@@ -18,6 +19,14 @@ namespace Wino.Services
|
||||
{
|
||||
public class WinoNavigationService : IWinoNavigationService
|
||||
{
|
||||
private readonly IStatePersistanceService _statePersistanceService;
|
||||
|
||||
private WinoPage[] _renderingPageTypes = new WinoPage[]
|
||||
{
|
||||
WinoPage.MailRenderingPage,
|
||||
WinoPage.ComposePage
|
||||
};
|
||||
|
||||
private Frame GetCoreFrame(NavigationReferenceFrame frameType)
|
||||
{
|
||||
if (Window.Current.Content is Frame appFrame && appFrame.Content is AppShell shellPage)
|
||||
@@ -36,6 +45,11 @@ namespace Wino.Services
|
||||
}
|
||||
}
|
||||
|
||||
public WinoNavigationService(IStatePersistanceService statePersistanceService)
|
||||
{
|
||||
_statePersistanceService = statePersistanceService;
|
||||
}
|
||||
|
||||
private Type GetPageType(WinoPage winoPage)
|
||||
{
|
||||
switch (winoPage)
|
||||
@@ -85,6 +99,8 @@ namespace Wino.Services
|
||||
var pageType = GetPageType(page);
|
||||
Frame shellFrame = GetCoreFrame(NavigationReferenceFrame.ShellFrame);
|
||||
|
||||
_statePersistanceService.IsReadingMail = _renderingPageTypes.Contains(page);
|
||||
|
||||
if (shellFrame != null)
|
||||
{
|
||||
var currentFrameType = GetCurrentFrameType(ref shellFrame);
|
||||
|
||||
@@ -46,8 +46,6 @@ namespace Wino.Views
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsComposerDarkModeProperty = DependencyProperty.Register(nameof(IsComposerDarkMode), typeof(bool), typeof(ComposePage), new PropertyMetadata(false, OnIsComposerDarkModeChanged));
|
||||
|
||||
|
||||
public WebView2 GetWebView() => Chromium;
|
||||
|
||||
private TaskCompletionSource<bool> DOMLoadedTask = new TaskCompletionSource<bool>();
|
||||
@@ -336,6 +334,12 @@ namespace Wino.Views
|
||||
base.OnNavigatingFrom(e);
|
||||
|
||||
DisposeDisposables();
|
||||
DisposeWebView2();
|
||||
}
|
||||
|
||||
private void DisposeWebView2()
|
||||
{
|
||||
if (Chromium == null) return;
|
||||
|
||||
Chromium.CoreWebView2Initialized -= ChromiumInitialized;
|
||||
|
||||
@@ -344,6 +348,9 @@ namespace Wino.Views
|
||||
Chromium.CoreWebView2.DOMContentLoaded -= DOMLoaded;
|
||||
Chromium.CoreWebView2.WebMessageReceived -= ScriptMessageRecieved;
|
||||
}
|
||||
|
||||
Chromium.Close();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
private void DisposeDisposables()
|
||||
|
||||
@@ -9,22 +9,7 @@
|
||||
xmlns:controls="using:Wino.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!-- Empty Page for Mail Rendering Sub Frame. -->
|
||||
<Grid>
|
||||
<StackPanel
|
||||
Opacity="0.5"
|
||||
Spacing="6"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<!-- Empty page for disposing composer or renderer page. -->
|
||||
<Grid />
|
||||
|
||||
<controls:WinoFontIcon Icon="Mail" FontSize="80" />
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="31"
|
||||
Text="{x:Bind ViewModel.SelectedMessageText, Mode=OneWay}"
|
||||
Style="{StaticResource SubheaderTextBlockStyle}"
|
||||
x:Name="CountTextBlock" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</abstract:IdlePageAbstract>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
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"
|
||||
mc:Ignorable="d">
|
||||
@@ -478,6 +479,7 @@
|
||||
x:Name="SelectionModeToggle"
|
||||
Grid.Column="1"
|
||||
Checked="SelectionModeToggleChecked"
|
||||
IsChecked="{x:Bind ViewModel.IsMultiSelectionModeEnabled, Mode=TwoWay}"
|
||||
Style="{StaticResource TopCommandBarToggleButtonStyle}"
|
||||
Unchecked="SelectionModeToggleUnchecked">
|
||||
<ToggleButton.Content>
|
||||
@@ -807,13 +809,28 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Mail Rendering Frame -->
|
||||
<Frame
|
||||
x:Name="RenderingFrame"
|
||||
Grid.Column="1"
|
||||
IsNavigationStackEnabled="False" />
|
||||
<Grid Grid.Column="1" x:Name="RenderingGrid">
|
||||
<!-- 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">
|
||||
|
||||
<controls:WinoFontIcon Icon="Mail" FontSize="80" />
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="31"
|
||||
Text="{x:Bind ViewModel.SelectedMessageText, Mode=OneWay}"
|
||||
Style="{StaticResource SubheaderTextBlockStyle}"
|
||||
x:Name="CountTextBlock" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Wino.Views
|
||||
|
||||
private IStatePersistanceService StatePersistanceService { get; } = App.Current.Services.GetService<IStatePersistanceService>();
|
||||
private IPreferencesService PreferencesService { get; } = App.Current.Services.GetService<IPreferencesService>();
|
||||
private IKeyPressService KeyPressService { get; } = App.Current.Services.GetService<IKeyPressService>();
|
||||
|
||||
public MailListPage()
|
||||
{
|
||||
@@ -67,14 +68,10 @@ namespace Wino.Views
|
||||
{
|
||||
base.OnNavigatedFrom(e);
|
||||
|
||||
// Force to go to empty page to dispose compose or rendering.
|
||||
if (!(RenderingFrame.Content is IdlePage))
|
||||
{
|
||||
RenderingFrame.Navigate(typeof(IdlePage), null);
|
||||
}
|
||||
|
||||
this.Bindings.StopTracking();
|
||||
|
||||
RenderingFrame.Navigate(typeof(IdlePage));
|
||||
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
@@ -153,35 +150,61 @@ namespace Wino.Views
|
||||
|
||||
private void UpdateAdaptiveness()
|
||||
{
|
||||
var readerGridVisibility = !(StatePersistanceService.IsReadingMail && StatePersistanceService.IsReaderNarrowed) ? Visibility.Visible : Visibility.Collapsed;
|
||||
ReaderGridContainer.Visibility = readerGridVisibility;
|
||||
ReaderGrid.Visibility = readerGridVisibility;
|
||||
RenderingFrame.Visibility = StatePersistanceService.IsReadingMail ? Visibility.Visible : (StatePersistanceService.IsReaderNarrowed ? Visibility.Collapsed : Visibility.Visible);
|
||||
|
||||
if (RenderingFrame.Visibility == Visibility.Collapsed)
|
||||
bool shouldDisplayNoMessagePanel, shouldDisplayMailingList, shouldDisplayRenderingFrame;
|
||||
|
||||
// This is the smallest state UI can get.
|
||||
// Either mailing list or rendering grid is visible.
|
||||
if (StatePersistanceService.IsReaderNarrowed)
|
||||
{
|
||||
Grid.SetColumn(ReaderGrid, 0);
|
||||
Grid.SetColumnSpan(ReaderGrid, 2);
|
||||
Grid.SetColumn(ReaderGridContainer, 0);
|
||||
Grid.SetColumnSpan(ReaderGridContainer, 2);
|
||||
// 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
|
||||
{
|
||||
Grid.SetColumn(ReaderGrid, 0);
|
||||
Grid.SetColumnSpan(ReaderGrid, 1);
|
||||
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);
|
||||
}
|
||||
|
||||
if (ReaderGrid.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
Grid.SetColumn(RenderingFrame, 0);
|
||||
Grid.SetColumnSpan(RenderingFrame, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Grid.SetColumn(RenderingFrame, 1);
|
||||
Grid.SetColumnSpan(RenderingFrame, 1);
|
||||
// Rendering grid should take the rest of the space.
|
||||
Grid.SetColumn(RenderingGrid, 1);
|
||||
Grid.SetColumnSpan(RenderingGrid, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,8 +286,6 @@ namespace Wino.Views
|
||||
if (message.SelectedMailItemViewModel == null)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
|
||||
|
||||
ViewModel.NavigationService.Navigate(WinoPage.IdlePage, ViewModel.SelectedItemCount, NavigationReferenceFrame.RenderingFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -298,7 +319,6 @@ namespace Wino.Views
|
||||
|
||||
if (message.SelectedMailItemViewModel == null) return;
|
||||
|
||||
|
||||
if (IsComposingPageActive())
|
||||
{
|
||||
PrepareComposePageWebViewTransition();
|
||||
@@ -358,11 +378,6 @@ namespace Wino.Views
|
||||
|
||||
public void Receive(ActiveMailFolderChangedEvent message)
|
||||
{
|
||||
if (!(RenderingFrame.Content is IdlePage))
|
||||
{
|
||||
RenderingFrame.Navigate(typeof(IdlePage), null);
|
||||
}
|
||||
|
||||
UpdateAdaptiveness();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace Wino.Views
|
||||
private bool isRenderingInProgress = false;
|
||||
private TaskCompletionSource<bool> DOMLoadedTask = new TaskCompletionSource<bool>();
|
||||
|
||||
private bool isChromiumDisposed = false;
|
||||
|
||||
public WebView2 GetWebView() => Chromium;
|
||||
|
||||
public MailRenderingPage()
|
||||
@@ -43,7 +45,6 @@ namespace Wino.Views
|
||||
|
||||
Environment.SetEnvironmentVariable("WEBVIEW2_DEFAULT_BACKGROUND_COLOR", "00FFFFFF");
|
||||
Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--enable-features=OverlayScrollbar,msOverlayScrollbarWinStyle,msOverlayScrollbarWinStyleAnimation");
|
||||
NavigationCacheMode = NavigationCacheMode.Enabled;
|
||||
}
|
||||
|
||||
public override async void OnEditorThemeChanged()
|
||||
@@ -77,7 +78,7 @@ namespace Wino.Views
|
||||
}
|
||||
script += ");";
|
||||
|
||||
return await Chromium.ExecuteScriptAsync(script);
|
||||
return isChromiumDisposed ? string.Empty : await Chromium.ExecuteScriptAsync(script);
|
||||
}
|
||||
|
||||
private async Task RenderInternalAsync(string htmlBody)
|
||||
@@ -129,9 +130,33 @@ namespace Wino.Views
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedFrom(e);
|
||||
|
||||
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
|
||||
|
||||
base.OnNavigatedFrom(e);
|
||||
// Disposing the page.
|
||||
// Make sure the WebView2 is disposed properly.
|
||||
|
||||
DisposeWebView2();
|
||||
}
|
||||
|
||||
private void DisposeWebView2()
|
||||
{
|
||||
if (Chromium == null) return;
|
||||
|
||||
Chromium.CoreWebView2Initialized -= CoreWebViewInitialized;
|
||||
Chromium.NavigationStarting -= WebViewNavigationStarting;
|
||||
|
||||
if (Chromium.CoreWebView2 != null)
|
||||
{
|
||||
Chromium.CoreWebView2.DOMContentLoaded -= DOMContentLoaded;
|
||||
Chromium.CoreWebView2.NewWindowRequested -= WindowRequested;
|
||||
}
|
||||
|
||||
isChromiumDisposed = true;
|
||||
|
||||
Chromium.Close();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
|
||||
@@ -588,8 +588,8 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\IdlePage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\ImapSetup\AdvancedImapSetupPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
@@ -895,4 +895,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user