ShellContent improvements.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Wino.Mail.WinUI.Controls.CalendarTitleBarContent"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:calendarControls="using:Wino.Calendar.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style
|
||||
x:Key="CalendarNavigationButtonStyle"
|
||||
BasedOn="{StaticResource DefaultButtonStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="Width" Value="44" />
|
||||
<Setter Property="Height" Value="36" />
|
||||
<Setter Property="Padding" Value="10,6" />
|
||||
<Setter Property="CornerRadius" Value="8" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="4,0,0,0" Background="Transparent">
|
||||
<Grid ColumnSpacing="16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
x:Name="VisibleDateRangeTextBlock"
|
||||
Grid.Column="1"
|
||||
MaxHeight="30"
|
||||
Margin="0,4,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
IsHitTestVisible="False"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
TextAlignment="Center" />
|
||||
|
||||
<StackPanel
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Spacing="8">
|
||||
<StackPanel
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Spacing="4">
|
||||
<Button
|
||||
Click="PreviousDateClicked"
|
||||
Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<PathIcon Data="F1 M 8.72 18.599998 C 8.879999 18.733334 9.059999 18.799999 9.26 18.799999 C 9.459999 18.799999 9.633332 18.719999 9.78 18.559999 C 9.926666 18.4 10 18.219999 10 18.019999 C 10 17.82 9.92 17.653332 9.76 17.52 L 4.52 12.559999 L 17.24 12.559999 C 17.453333 12.559999 17.633331 12.486667 17.779999 12.339999 C 17.926666 12.193334 18 12.013333 18 11.799999 C 18 11.586666 17.926666 11.406667 17.779999 11.259999 C 17.633331 11.113333 17.453333 11.039999 17.24 11.039999 L 4.52 11.039999 L 9.76 6.08 C 9.973333 5.893333 10.046666 5.653332 9.98 5.359999 C 9.913333 5.066666 9.74 4.880001 9.46 4.799999 C 9.179999 4.720001 8.933332 4.786667 8.72 5 L 2.32 11.08 C 2.16 11.24 2.053333 11.426666 2 11.639999 C 1.973333 11.746666 1.973333 11.853333 2 11.959999 C 2.053333 12.173333 2.16 12.360001 2.32 12.52 Z " />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Click="NextDateClicked"
|
||||
Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<PathIcon Data="F1 M 11.28 5 C 11.12 4.866667 10.94 4.806667 10.74 4.82 C 10.539999 4.833334 10.366666 4.913334 10.219999 5.059999 C 10.073333 5.206665 10 5.379999 10 5.58 C 10 5.779999 10.08 5.946667 10.24 6.08 L 15.48 11.039999 L 2.76 11.039999 C 2.546667 11.039999 2.366667 11.113333 2.22 11.259999 C 2.073333 11.406667 2 11.586666 2 11.799999 C 2 12.013333 2.073333 12.193334 2.22 12.339999 C 2.366667 12.486667 2.546667 12.559999 2.76 12.559999 L 15.48 12.559999 L 10.24 17.52 C 10.026667 17.706665 9.953333 17.946667 10.02 18.24 C 10.086666 18.533333 10.259999 18.719999 10.54 18.799999 C 10.82 18.879999 11.066667 18.813334 11.28 18.599998 L 17.68 12.52 C 17.84 12.360001 17.946667 12.173333 18 11.959999 C 18 11.853333 18 11.746666 18 11.639999 C 17.946667 11.426666 17.84 11.24 17.68 11.08 Z " />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<calendarControls:WinoCalendarTypeSelectorControl
|
||||
x:Name="CalendarTypeSelector"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Wino.Calendar.Controls;
|
||||
using Wino.Core.Domain.Enums;
|
||||
|
||||
namespace Wino.Mail.WinUI.Controls;
|
||||
|
||||
public sealed partial class CalendarTitleBarContent : UserControl
|
||||
{
|
||||
public event EventHandler? PreviousDateRequested;
|
||||
public event EventHandler? NextDateRequested;
|
||||
|
||||
public CalendarTitleBarContent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string VisibleDateRangeText
|
||||
{
|
||||
get => VisibleDateRangeTextBlock.Text;
|
||||
set => VisibleDateRangeTextBlock.Text = value;
|
||||
}
|
||||
|
||||
public ICommand? TodayClickedCommand
|
||||
{
|
||||
get => CalendarTypeSelector.TodayClickedCommand;
|
||||
set => CalendarTypeSelector.TodayClickedCommand = value;
|
||||
}
|
||||
|
||||
public int DisplayDayCount
|
||||
{
|
||||
get => CalendarTypeSelector.DisplayDayCount;
|
||||
set => CalendarTypeSelector.DisplayDayCount = value;
|
||||
}
|
||||
|
||||
public CalendarDisplayType SelectedType
|
||||
{
|
||||
get => CalendarTypeSelector.SelectedType;
|
||||
set => CalendarTypeSelector.SelectedType = value;
|
||||
}
|
||||
|
||||
public long RegisterSelectedTypeChanged(DependencyPropertyChangedCallback callback)
|
||||
=> CalendarTypeSelector.RegisterPropertyChangedCallback(WinoCalendarTypeSelectorControl.SelectedTypeProperty, callback);
|
||||
|
||||
public void UnregisterSelectedTypeChanged(long token)
|
||||
=> CalendarTypeSelector.UnregisterPropertyChangedCallback(WinoCalendarTypeSelectorControl.SelectedTypeProperty, token);
|
||||
|
||||
private void PreviousDateClicked(object sender, RoutedEventArgs e)
|
||||
=> PreviousDateRequested?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
private void NextDateClicked(object sender, RoutedEventArgs e)
|
||||
=> NextDateRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
@@ -92,14 +92,10 @@
|
||||
BorderBrush="Transparent"
|
||||
Visibility="{x:Bind helpers:XamlHelpers.ReverseBoolToVisibilityConverter(PreferencesService.IsWinoAccountButtonHidden), Mode=OneWay}">
|
||||
<Button.Flyout>
|
||||
<Flyout
|
||||
x:Name="WinoAccountFlyout"
|
||||
Placement="Bottom">
|
||||
<Flyout x:Name="WinoAccountFlyout" Placement="Bottom">
|
||||
<Grid MinWidth="320" MaxWidth="360">
|
||||
<!-- Signed Out View -->
|
||||
<StackPanel
|
||||
x:Name="WinoAccountSignedOutView"
|
||||
Spacing="16">
|
||||
<StackPanel x:Name="WinoAccountSignedOutView" Spacing="16">
|
||||
|
||||
<!-- Hero header with gradient and icon -->
|
||||
<Border
|
||||
@@ -162,8 +158,8 @@
|
||||
Glyph="" />
|
||||
<StackPanel Grid.Column="1" Spacing="2">
|
||||
<TextBlock
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
FontWeight="SemiBold"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind domain:Translator.WinoAccount_Titlebar_SyncBenefitTitle}" />
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
@@ -196,8 +192,8 @@
|
||||
Glyph="" />
|
||||
<StackPanel Grid.Column="1" Spacing="2">
|
||||
<TextBlock
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
FontWeight="SemiBold"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind domain:Translator.WinoAccount_Titlebar_AddonsBenefitTitle}" />
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -15,6 +16,7 @@ using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
using Wino.Extensions;
|
||||
using Wino.Mail.WinUI.Activation;
|
||||
using Wino.Mail.WinUI.Controls;
|
||||
using Wino.Mail.WinUI.Extensions;
|
||||
using Wino.Mail.WinUI.Interfaces;
|
||||
using Wino.Mail.WinUI.Views;
|
||||
@@ -41,6 +43,9 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
|
||||
public ObservableCollection<SynchronizationActionItem> SyncActionItems { get; } = new();
|
||||
private bool _calendarReminderServerStartAttempted;
|
||||
private ICalendarShellClient? _activeCalendarClient;
|
||||
private readonly CalendarTitleBarContent _calendarTitleBarContent = new();
|
||||
private long _calendarTypeSelectorChangedToken;
|
||||
|
||||
public ShellWindow()
|
||||
{
|
||||
@@ -51,6 +56,9 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
MinWidth = 420;
|
||||
MinHeight = 420;
|
||||
ConfigureTitleBar();
|
||||
_calendarTypeSelectorChangedToken = _calendarTitleBarContent.RegisterSelectedTypeChanged(CalendarTypeSelectorSelectedTypeChanged);
|
||||
_calendarTitleBarContent.PreviousDateRequested += CalendarTitleBarContentPreviousDateRequested;
|
||||
_calendarTitleBarContent.NextDateRequested += CalendarTitleBarContentNextDateRequested;
|
||||
|
||||
// Handle window closing event to minimize to tray instead of closing
|
||||
Closed += OnWindowClosed;
|
||||
@@ -130,8 +138,7 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
_ = StartCalendarReminderServerAsync();
|
||||
}
|
||||
|
||||
if (e.Content is BasePage basePage)
|
||||
ShellTitleBar.Content = basePage.ShellContent;
|
||||
ApplyTitleBarContent();
|
||||
}
|
||||
|
||||
private async Task StartCalendarReminderServerAsync()
|
||||
@@ -158,10 +165,7 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
|
||||
public void Receive(TitleBarShellContentUpdated message)
|
||||
{
|
||||
if (MainShellFrame.Content is WinoAppShell shellPage)
|
||||
{
|
||||
ShellTitleBar.Content = shellPage.ShellContent;
|
||||
}
|
||||
ApplyTitleBarContent();
|
||||
}
|
||||
|
||||
public void Receive(ApplicationThemeChanged message)
|
||||
@@ -257,6 +261,121 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
});
|
||||
}
|
||||
|
||||
private void CalendarTypeSelectorSelectedTypeChanged(DependencyObject sender, DependencyProperty dp)
|
||||
{
|
||||
if (_activeCalendarClient == null)
|
||||
return;
|
||||
|
||||
var selectedType = _calendarTitleBarContent.SelectedType;
|
||||
if (_activeCalendarClient.StatePersistenceService.CalendarDisplayType != selectedType)
|
||||
{
|
||||
_activeCalendarClient.StatePersistenceService.CalendarDisplayType = selectedType;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyTitleBarContent()
|
||||
{
|
||||
if (MainShellFrame.Content is not WinoAppShell shellPage)
|
||||
{
|
||||
AttachCalendarClient(null);
|
||||
ShellTitleBar.Content = MainShellFrame.Content is BasePage basePage ? basePage.ShellContent : null;
|
||||
return;
|
||||
}
|
||||
|
||||
AttachCalendarClient(shellPage.ViewModel.CalendarClient);
|
||||
|
||||
if (shellPage.ViewModel.IsCalendarMode && !shellPage.ViewModel.StatePersistenceService.IsEventDetailsVisible)
|
||||
{
|
||||
RefreshCalendarSelector();
|
||||
ShellTitleBar.Content = _calendarTitleBarContent;
|
||||
return;
|
||||
}
|
||||
|
||||
ShellTitleBar.Content = shellPage.GetShellFrame().Content is BasePage page ? page.ShellContent : null;
|
||||
}
|
||||
|
||||
private void AttachCalendarClient(ICalendarShellClient? calendarClient)
|
||||
{
|
||||
if (ReferenceEquals(_activeCalendarClient, calendarClient))
|
||||
return;
|
||||
|
||||
if (_activeCalendarClient != null)
|
||||
{
|
||||
_activeCalendarClient.PropertyChanged -= CalendarClientPropertyChanged;
|
||||
_activeCalendarClient.StatePersistenceService.StatePropertyChanged -= CalendarStatePersistenceServiceChanged;
|
||||
}
|
||||
|
||||
_activeCalendarClient = calendarClient;
|
||||
|
||||
if (_activeCalendarClient != null)
|
||||
{
|
||||
_activeCalendarClient.PropertyChanged += CalendarClientPropertyChanged;
|
||||
_activeCalendarClient.StatePersistenceService.StatePropertyChanged += CalendarStatePersistenceServiceChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void CalendarClientPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (!DispatcherQueue.HasThreadAccess)
|
||||
{
|
||||
var enqueued = DispatcherQueue.TryEnqueue(() => CalendarClientPropertyChanged(sender, e));
|
||||
if (!enqueued)
|
||||
throw new InvalidOperationException("Could not marshal calendar client changes onto the UI thread.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == nameof(ICalendarShellClient.VisibleDateRangeText))
|
||||
{
|
||||
RefreshCalendarSelector();
|
||||
}
|
||||
}
|
||||
|
||||
private void CalendarStatePersistenceServiceChanged(object? sender, string propertyName)
|
||||
{
|
||||
if (!DispatcherQueue.HasThreadAccess)
|
||||
{
|
||||
var enqueued = DispatcherQueue.TryEnqueue(() => CalendarStatePersistenceServiceChanged(sender, propertyName));
|
||||
if (!enqueued)
|
||||
throw new InvalidOperationException("Could not marshal title bar state changes onto the UI thread.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (propertyName == nameof(IStatePersistanceService.CalendarDisplayType) ||
|
||||
propertyName == nameof(IStatePersistanceService.DayDisplayCount))
|
||||
{
|
||||
RefreshCalendarSelector();
|
||||
return;
|
||||
}
|
||||
|
||||
if (propertyName == nameof(IStatePersistanceService.IsEventDetailsVisible))
|
||||
{
|
||||
ApplyTitleBarContent();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshCalendarSelector()
|
||||
{
|
||||
if (_activeCalendarClient == null)
|
||||
return;
|
||||
|
||||
_calendarTitleBarContent.VisibleDateRangeText = _activeCalendarClient.VisibleDateRangeText;
|
||||
_calendarTitleBarContent.TodayClickedCommand = _activeCalendarClient.TodayClickedCommand;
|
||||
_calendarTitleBarContent.DisplayDayCount = _activeCalendarClient.StatePersistenceService.DayDisplayCount;
|
||||
|
||||
if (_calendarTitleBarContent.SelectedType != _activeCalendarClient.StatePersistenceService.CalendarDisplayType)
|
||||
{
|
||||
_calendarTitleBarContent.SelectedType = _activeCalendarClient.StatePersistenceService.CalendarDisplayType;
|
||||
}
|
||||
}
|
||||
|
||||
private void CalendarTitleBarContentPreviousDateRequested(object? sender, EventArgs e)
|
||||
=> _activeCalendarClient?.PreviousDateRangeCommand.Execute(null);
|
||||
|
||||
private void CalendarTitleBarContentNextDateRequested(object? sender, EventArgs e)
|
||||
=> _activeCalendarClient?.NextDateRangeCommand.Execute(null);
|
||||
|
||||
private void OnAppWindowClosing(object sender, Microsoft.UI.Windowing.AppWindowClosingEventArgs e)
|
||||
{
|
||||
if ((Application.Current as App)?.IsExiting == true)
|
||||
@@ -270,6 +389,10 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
private void OnWindowClosed(object sender, WindowEventArgs e)
|
||||
{
|
||||
AppWindow.Closing -= OnAppWindowClosing;
|
||||
AttachCalendarClient(null);
|
||||
_calendarTitleBarContent.UnregisterSelectedTypeChanged(_calendarTypeSelectorChangedToken);
|
||||
_calendarTitleBarContent.PreviousDateRequested -= CalendarTitleBarContentPreviousDateRequested;
|
||||
_calendarTitleBarContent.NextDateRequested -= CalendarTitleBarContentNextDateRequested;
|
||||
UnregisterRecipients();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:abstract="using:Wino.Mail.WinUI.Views.Abstract"
|
||||
xmlns:animations="using:CommunityToolkit.WinUI.Animations"
|
||||
xmlns:calendarControls="using:Wino.Calendar.Controls"
|
||||
xmlns:communityControls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:controls="using:Wino.Controls"
|
||||
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
|
||||
@@ -409,98 +408,11 @@
|
||||
SeperatorTemplate="{StaticResource SeperatorTemplate}"
|
||||
SettingsShellPageItemTemplate="{StaticResource SettingsShellPageItemTemplate}"
|
||||
SettingsShellSectionItemTemplate="{StaticResource SettingsShellSectionItemTemplate}"
|
||||
WinoAccountSettingsShellPageItemTemplate="{StaticResource SettingsShellWinoAccountItemTemplate}"
|
||||
StoreUpdateItemTemplate="{StaticResource StoreUpdateItemTemplate}" />
|
||||
StoreUpdateItemTemplate="{StaticResource StoreUpdateItemTemplate}"
|
||||
WinoAccountSettingsShellPageItemTemplate="{StaticResource SettingsShellWinoAccountItemTemplate}" />
|
||||
|
||||
<Style
|
||||
x:Key="CalendarNavigationButtonStyle"
|
||||
BasedOn="{StaticResource DefaultButtonStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Margin" Value="0,4,0,0" />
|
||||
<Setter Property="Padding" Value="8,4,8,6" />
|
||||
<Setter Property="CornerRadius" Value="6" />
|
||||
<Setter Property="Width" Value="40" />
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
|
||||
<abstract:WinoAppShellAbstract.ShellContent>
|
||||
<Grid Margin="4,0,0,0" Background="Transparent">
|
||||
<ContentPresenter x:Name="DynamicPageShellContentPresenter" />
|
||||
<Grid
|
||||
x:Name="CalendarShellContentRoot"
|
||||
ColumnSpacing="12"
|
||||
Visibility="Collapsed">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid x:Name="ShellContentArea" ColumnSpacing="12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel
|
||||
x:Name="NavigationTitleStack"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,12,4"
|
||||
Orientation="Horizontal"
|
||||
Spacing="6">
|
||||
<Button
|
||||
x:Name="PreviousDateButton"
|
||||
Click="PreviousDateClicked"
|
||||
Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<PathIcon x:Name="PreviousDateButtonPathIcon" Data="F1 M 8.72 18.599998 C 8.879999 18.733334 9.059999 18.799999 9.26 18.799999 C 9.459999 18.799999 9.633332 18.719999 9.78 18.559999 C 9.926666 18.4 10 18.219999 10 18.019999 C 10 17.82 9.92 17.653332 9.76 17.52 L 4.52 12.559999 L 17.24 12.559999 C 17.453333 12.559999 17.633331 12.486667 17.779999 12.339999 C 17.926666 12.193334 18 12.013333 18 11.799999 C 18 11.586666 17.926666 11.406667 17.779999 11.259999 C 17.633331 11.113333 17.453333 11.039999 17.24 11.039999 L 4.52 11.039999 L 9.76 6.08 C 9.973333 5.893333 10.046666 5.653332 9.98 5.359999 C 9.913333 5.066666 9.74 4.880001 9.46 4.799999 C 9.179999 4.720001 8.933332 4.786667 8.72 5 L 2.32 11.08 C 2.16 11.24 2.053333 11.426666 2 11.639999 C 1.973333 11.746666 1.973333 11.853333 2 11.959999 C 2.053333 12.173333 2.16 12.360001 2.32 12.52 Z " />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
x:Name="NextDateButton"
|
||||
Click="NextDateClicked"
|
||||
Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<PathIcon x:Name="NextDateButtonPathIcon" Data="F1 M 11.28 5 C 11.12 4.866667 10.94 4.806667 10.74 4.82 C 10.539999 4.833334 10.366666 4.913334 10.219999 5.059999 C 10.073333 5.206665 10 5.379999 10 5.58 C 10 5.779999 10.08 5.946667 10.24 6.08 L 15.48 11.039999 L 2.76 11.039999 C 2.546667 11.039999 2.366667 11.113333 2.22 11.259999 C 2.073333 11.406667 2 11.586666 2 11.799999 C 2 12.013333 2.073333 12.193334 2.22 12.339999 C 2.366667 12.486667 2.546667 12.559999 2.76 12.559999 L 15.48 12.559999 L 10.24 17.52 C 10.026667 17.706665 9.953333 17.946667 10.02 18.24 C 10.086666 18.533333 10.259999 18.719999 10.54 18.799999 C 10.82 18.879999 11.066667 18.813334 11.28 18.599998 L 17.68 12.52 C 17.84 12.360001 17.946667 12.173333 18 11.959999 C 18 11.853333 18 11.746666 18 11.639999 C 17.946667 11.426666 17.84 11.24 17.68 11.08 Z " />
|
||||
</Button>
|
||||
|
||||
<calendarControls:CustomCalendarFlipView
|
||||
x:Name="DayHeaderNavigationItemsFlipView"
|
||||
MaxHeight="30"
|
||||
Margin="8,4,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalContentAlignment="Left"
|
||||
Background="Transparent"
|
||||
FontSize="14"
|
||||
FontWeight="Normal"
|
||||
IsHitTestVisible="False">
|
||||
<FlipView.ItemTemplate>
|
||||
<DataTemplate x:DataType="x:String">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind}" />
|
||||
</DataTemplate>
|
||||
</FlipView.ItemTemplate>
|
||||
</calendarControls:CustomCalendarFlipView>
|
||||
</StackPanel>
|
||||
|
||||
<AutoSuggestBox
|
||||
x:Name="SearchBox"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
BorderBrush="Transparent"
|
||||
PlaceholderText="Search" />
|
||||
</Grid>
|
||||
|
||||
<calendarControls:WinoCalendarTypeSelectorControl
|
||||
x:Name="CalendarTypeSelector"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</abstract:WinoAppShellAbstract.ShellContent>
|
||||
|
||||
<Grid
|
||||
x:Name="RootGrid"
|
||||
Padding="0"
|
||||
@@ -738,36 +650,15 @@
|
||||
<AdaptiveTrigger MinWindowWidth="0" />
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="NavigationTitleStack.Visibility" Value="Collapsed" />
|
||||
<Setter Target="SearchBox.(Grid.ColumnSpan)" Value="2" />
|
||||
<Setter Target="navigationView.IsPaneOpen" Value="False" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
||||
<VisualStateGroup x:Name="CalendarOrientationStates">
|
||||
<VisualState x:Name="HorizontalCalendar" />
|
||||
<VisualState x:Name="VerticalCalendar">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="DayHeaderNavigationItemsFlipView.ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel Orientation="Vertical" />
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="PreviousDateButtonPathIcon.Data" Value="F1 M 3.2 10.52 C 2.986666 10.733333 2.92 10.98 3 11.259999 C 3.08 11.54 3.266666 11.713333 3.56 11.78 C 3.853333 11.846666 4.093333 11.773333 4.28 11.559999 L 9.24 6.32 L 9.24 19.039999 C 9.24 19.253332 9.313333 19.433332 9.46 19.58 C 9.606666 19.726665 9.786666 19.799999 10 19.799999 C 10.213333 19.799999 10.393332 19.726665 10.54 19.58 C 10.686666 19.433332 10.76 19.253332 10.76 19.039999 L 10.76 6.32 L 15.719999 11.559999 C 15.906666 11.773333 16.139999 11.846666 16.42 11.78 C 16.700001 11.713333 16.886665 11.54 16.98 11.259999 C 17.073332 10.98 17.013332 10.733333 16.799999 10.52 L 10.719999 4.119999 C 10.559999 3.959999 10.373333 3.853333 10.16 3.799999 C 10.053333 3.799999 9.946667 3.799999 9.84 3.799999 C 9.626666 3.853333 9.439999 3.959999 9.28 4.119999 Z " />
|
||||
<Setter Target="NextDateButtonPathIcon.Data" Value="F1 M 16.799999 13.079999 C 16.933332 12.92 16.993332 12.74 16.98 12.539999 C 16.966665 12.34 16.886665 12.166667 16.74 12.02 C 16.593334 11.873333 16.42 11.799999 16.219999 11.799999 C 16.02 11.799999 15.853333 11.879999 15.719999 12.039999 L 10.76 17.279999 L 10.76 4.559999 C 10.76 4.346666 10.686666 4.166668 10.54 4.02 C 10.393332 3.873333 10.213333 3.799999 10 3.799999 C 9.786666 3.799999 9.606666 3.873333 9.46 4.02 C 9.313333 4.166668 9.24 4.346666 9.24 4.559999 L 9.24 17.279999 L 4.28 12.039999 C 4.146667 11.879999 3.98 11.799999 3.78 11.799999 C 3.58 11.799999 3.4 11.873333 3.24 12.02 C 3.08 12.166667 3 12.34 3 12.539999 C 3 12.74 3.066667 12.92 3.2 13.079999 L 9.28 19.48 C 9.439999 19.639999 9.626666 19.746666 9.84 19.799999 C 9.946667 19.799999 10.053333 19.799999 10.16 19.799999 C 10.373333 19.746666 10.559999 19.639999 10.719999 19.48 Z " />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
||||
<VisualStateGroup x:Name="ShellStateContentGroup">
|
||||
<VisualState x:Name="DefaultShellContentState" />
|
||||
<VisualState x:Name="EventDetailsContentState">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="ShellContentArea.Visibility" Value="Collapsed" />
|
||||
<Setter Target="CalendarTypeSelector.Visibility" Value="Collapsed" />
|
||||
<Setter Target="RangeSummaryCard.IsEnabled" Value="False" />
|
||||
<Setter Target="CalendarHostListView.IsEnabled" Value="False" />
|
||||
</VisualState.Setters>
|
||||
|
||||
@@ -13,7 +13,6 @@ using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using Windows.Foundation;
|
||||
using Windows.System;
|
||||
using Wino.Calendar.Controls;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Enums;
|
||||
@@ -45,8 +44,6 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
IRecipient<CalendarDisplayTypeChangedMessage>,
|
||||
IRecipient<AccountCreatedMessage>
|
||||
{
|
||||
private const string StateHorizontalCalendar = "HorizontalCalendar";
|
||||
private const string StateVerticalCalendar = "VerticalCalendar";
|
||||
private const string StateDefaultShellContent = "DefaultShellContentState";
|
||||
private const string StateEventDetailsContent = "EventDetailsContentState";
|
||||
private WinoApplicationMode? _activeMode;
|
||||
@@ -68,12 +65,9 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
ViewModel.PropertyChanged += ViewModelPropertyChanged;
|
||||
ViewModel.PreferencesService.PreferenceChanged += PreferencesServiceChanged;
|
||||
ViewModel.StatePersistenceService.StatePropertyChanged += StatePersistenceServiceChanged;
|
||||
CalendarTypeSelector.RegisterPropertyChangedCallback(WinoCalendarTypeSelectorControl.SelectedTypeProperty, CalendarTypeSelectorSelectedTypeChanged);
|
||||
|
||||
InitializeCalendarControls();
|
||||
ManageCalendarDisplayType(ViewModel.CalendarClient.StatePersistenceService.CalendarDisplayType);
|
||||
UpdateEventDetailsVisualState();
|
||||
ApplyTitleBarContent();
|
||||
}
|
||||
|
||||
public bool HasShellContent => InnerShellFrame.Content != null;
|
||||
@@ -98,8 +92,7 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
|
||||
ViewModel.CurrentClient.Activate(activationContext);
|
||||
ResetShellModeNavigationState();
|
||||
|
||||
ApplyTitleBarContent();
|
||||
NotifyTitleBarContentChanged();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
@@ -126,17 +119,11 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
|
||||
private void ApplyModeLayout()
|
||||
{
|
||||
var isCalendarMode = ViewModel.IsCalendarMode;
|
||||
|
||||
CalendarShellContentRoot.Visibility = isCalendarMode ? Visibility.Visible : Visibility.Collapsed;
|
||||
DynamicPageShellContentPresenter.Visibility = isCalendarMode ? Visibility.Collapsed : Visibility.Visible;
|
||||
|
||||
RefreshCalendarControls();
|
||||
ManageCalendarDisplayType(ViewModel.CalendarClient.StatePersistenceService.CalendarDisplayType);
|
||||
UpdateEventDetailsVisualState();
|
||||
UpdateTitleBarSubtitle();
|
||||
UpdateNavigationPaneLayout(navigationView.DisplayMode);
|
||||
ApplyTitleBarContent();
|
||||
NotifyTitleBarContentChanged();
|
||||
}
|
||||
|
||||
private void DeactivateCurrentMode()
|
||||
@@ -166,8 +153,6 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
|
||||
ViewModel.CurrentClient.Deactivate();
|
||||
}
|
||||
|
||||
DynamicPageShellContentPresenter.Content = null;
|
||||
}
|
||||
|
||||
private void ResetShellModeNavigationState()
|
||||
@@ -177,20 +162,6 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
InnerShellFrame.ForwardStack.Clear();
|
||||
}
|
||||
|
||||
private void ApplyTitleBarContent()
|
||||
{
|
||||
if (ViewModel.IsCalendarMode)
|
||||
{
|
||||
CalendarShellContentRoot.Visibility = Visibility.Visible;
|
||||
DynamicPageShellContentPresenter.Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
CalendarShellContentRoot.Visibility = Visibility.Collapsed;
|
||||
DynamicPageShellContentPresenter.Visibility = Visibility.Visible;
|
||||
DynamicPageShellContentPresenter.Content = InnerShellFrame.Content is BasePage page ? page.ShellContent : null;
|
||||
}
|
||||
|
||||
private void UpdateTitleBarSubtitle()
|
||||
{
|
||||
if (ViewModel.IsContactsMode)
|
||||
@@ -208,24 +179,8 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
ViewModel.StatePersistenceService.CoreWindowTitle = string.Empty;
|
||||
}
|
||||
|
||||
private void ManageCalendarDisplayType(Core.Domain.Enums.CalendarDisplayType displayType)
|
||||
{
|
||||
DayHeaderNavigationItemsFlipView.DisplayType = displayType;
|
||||
|
||||
if (CalendarTypeSelector.SelectedType != displayType)
|
||||
{
|
||||
CalendarTypeSelector.SelectedType = displayType;
|
||||
}
|
||||
|
||||
VisualStateManager.GoToState(this, displayType == Core.Domain.Enums.CalendarDisplayType.Month
|
||||
? StateVerticalCalendar
|
||||
: StateHorizontalCalendar, false);
|
||||
}
|
||||
|
||||
private void InitializeCalendarControls()
|
||||
{
|
||||
CalendarTypeSelector.TodayClickedCommand = ViewModel.CalendarClient.TodayClickedCommand;
|
||||
DayHeaderNavigationItemsFlipView.ItemsSource = ViewModel.CalendarClient.DateNavigationHeaderItems;
|
||||
CalendarHostListView.ItemsSource = ViewModel.CalendarClient.GroupedAccountCalendars;
|
||||
|
||||
RefreshCalendarControls();
|
||||
@@ -233,9 +188,6 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
|
||||
private void RefreshCalendarControls()
|
||||
{
|
||||
DayHeaderNavigationItemsFlipView.ItemsSource = ViewModel.CalendarClient.DateNavigationHeaderItems;
|
||||
DayHeaderNavigationItemsFlipView.SelectedIndex = ViewModel.CalendarClient.SelectedDateNavigationHeaderIndex;
|
||||
CalendarTypeSelector.DisplayDayCount = ViewModel.CalendarClient.StatePersistenceService.DayDisplayCount;
|
||||
CalendarHostListView.ItemsSource = ViewModel.CalendarClient.GroupedAccountCalendars;
|
||||
SynchronizeVisibleDateRangeCalendar();
|
||||
}
|
||||
@@ -255,16 +207,6 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
false);
|
||||
}
|
||||
|
||||
private void CalendarTypeSelectorSelectedTypeChanged(DependencyObject sender, DependencyProperty dp)
|
||||
{
|
||||
var selectedType = CalendarTypeSelector.SelectedType;
|
||||
|
||||
if (ViewModel.CalendarClient.StatePersistenceService.CalendarDisplayType != selectedType)
|
||||
{
|
||||
ViewModel.CalendarClient.StatePersistenceService.CalendarDisplayType = selectedType;
|
||||
}
|
||||
}
|
||||
|
||||
private async void NewCalendarEventNavigationItemTapped(object sender, TappedRoutedEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
@@ -280,16 +222,10 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
await InvokeNewCalendarEventAsync();
|
||||
}
|
||||
|
||||
private void PreviousDateClicked(object sender, RoutedEventArgs e)
|
||||
=> ViewModel.CalendarClient.PreviousDateRangeCommand.Execute(null);
|
||||
|
||||
private void NextDateClicked(object sender, RoutedEventArgs e)
|
||||
=> ViewModel.CalendarClient.NextDateRangeCommand.Execute(null);
|
||||
|
||||
private Task InvokeNewCalendarEventAsync()
|
||||
=> ViewModel.CalendarClient.HandleNavigationItemInvokedAsync(new NewCalendarEventMenuItem());
|
||||
|
||||
public void Receive(CalendarDisplayTypeChangedMessage message) => ManageCalendarDisplayType(message.NewDisplayType);
|
||||
public void Receive(CalendarDisplayTypeChangedMessage message) => NotifyTitleBarContentChanged();
|
||||
|
||||
public void Receive(AccountCreatedMessage message)
|
||||
{
|
||||
@@ -404,7 +340,7 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
|
||||
private void ShellFrameContentNavigated(object sender, NavigationEventArgs e)
|
||||
{
|
||||
ApplyTitleBarContent();
|
||||
NotifyTitleBarContentChanged();
|
||||
|
||||
if (ViewModel.IsMailMode)
|
||||
{
|
||||
@@ -499,18 +435,6 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == nameof(ICalendarShellClient.DateNavigationHeaderItems))
|
||||
{
|
||||
DayHeaderNavigationItemsFlipView.ItemsSource = ViewModel.CalendarClient.DateNavigationHeaderItems;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == nameof(ICalendarShellClient.SelectedDateNavigationHeaderIndex))
|
||||
{
|
||||
DayHeaderNavigationItemsFlipView.SelectedIndex = ViewModel.CalendarClient.SelectedDateNavigationHeaderIndex;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == nameof(ICalendarShellClient.CurrentVisibleRange) ||
|
||||
e.PropertyName == nameof(ICalendarShellClient.VisibleDateRangeText))
|
||||
{
|
||||
@@ -631,22 +555,26 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
{
|
||||
if (propertyName == nameof(IStatePersistanceService.CalendarDisplayType))
|
||||
{
|
||||
ManageCalendarDisplayType(ViewModel.CalendarClient.StatePersistenceService.CalendarDisplayType);
|
||||
NotifyTitleBarContentChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
if (propertyName == nameof(IStatePersistanceService.DayDisplayCount))
|
||||
{
|
||||
CalendarTypeSelector.DisplayDayCount = ViewModel.CalendarClient.StatePersistenceService.DayDisplayCount;
|
||||
NotifyTitleBarContentChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
if (propertyName == nameof(IStatePersistanceService.IsEventDetailsVisible))
|
||||
{
|
||||
UpdateEventDetailsVisualState();
|
||||
NotifyTitleBarContentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private static void NotifyTitleBarContentChanged()
|
||||
=> WeakReferenceMessenger.Default.Send(new TitleBarShellContentUpdated());
|
||||
|
||||
private void UpdateNavigationPaneLayout(NavigationViewDisplayMode displayMode)
|
||||
{
|
||||
if (displayMode == NavigationViewDisplayMode.Expanded && navigationView.IsPaneOpen)
|
||||
|
||||
Reference in New Issue
Block a user