Shell improvements.

This commit is contained in:
Burak Kaan Köse
2026-03-12 11:28:41 +01:00
parent 9dd68fd62e
commit 861b991eee
7 changed files with 115 additions and 55 deletions
@@ -1,38 +1,32 @@
<UserControl <controls:Segmented
x:Class="Wino.Mail.WinUI.Controls.AppModeFooterSwitcherControl" x:Class="Wino.Mail.WinUI.Controls.AppModeFooterSwitcherControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
xmlns:controls="using:CommunityToolkit.WinUI.Controls" xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:domain="using:Wino.Core.Domain" xmlns:domain="using:Wino.Core.Domain"
Padding="0"
HorizontalAlignment="Stretch"
Loaded="ControlLoaded" Loaded="ControlLoaded"
SelectionChanged="ModeSegmentedControlSelectionChanged"
Unloaded="ControlUnloaded"> Unloaded="ControlUnloaded">
<controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeMail, Mode=OneWay}">
<Grid> <controls:SegmentedItem.Icon>
<controls:Segmented <SymbolIcon Symbol="Mail" />
x:Name="ModeSegmentedControl" </controls:SegmentedItem.Icon>
HorizontalAlignment="Stretch" </controls:SegmentedItem>
SelectionChanged="ModeSegmentedControlSelectionChanged"> <controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeCalendar, Mode=OneWay}">
<controls:SegmentedItem ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeMail, Mode=OneWay}"> <controls:SegmentedItem.Icon>
<controls:SegmentedItem.Icon> <SymbolIcon Symbol="Calendar" />
<SymbolIcon Symbol="Mail" /> </controls:SegmentedItem.Icon>
</controls:SegmentedItem.Icon> </controls:SegmentedItem>
</controls:SegmentedItem> <controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.ContactsPage_Title, Mode=OneWay}">
<controls:SegmentedItem ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeCalendar, Mode=OneWay}"> <controls:SegmentedItem.Icon>
<controls:SegmentedItem.Icon> <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE716;" />
<SymbolIcon Symbol="Calendar" /> </controls:SegmentedItem.Icon>
</controls:SegmentedItem.Icon> </controls:SegmentedItem>
</controls:SegmentedItem> <controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.MenuSettings, Mode=OneWay}">
<controls:SegmentedItem ToolTipService.ToolTip="{x:Bind domain:Translator.ContactsPage_Title, Mode=OneWay}"> <controls:SegmentedItem.Icon>
<controls:SegmentedItem.Icon> <SymbolIcon Symbol="Setting" />
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE716;" /> </controls:SegmentedItem.Icon>
</controls:SegmentedItem.Icon> </controls:SegmentedItem>
</controls:SegmentedItem> </controls:Segmented>
<controls:SegmentedItem ToolTipService.ToolTip="{x:Bind domain:Translator.MenuSettings, Mode=OneWay}">
<controls:SegmentedItem.Icon>
<SymbolIcon Symbol="Setting" />
</controls:SegmentedItem.Icon>
</controls:SegmentedItem>
</controls:Segmented>
</Grid>
</UserControl>
@@ -1,4 +1,4 @@
using System; using CommunityToolkit.WinUI.Controls;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
@@ -8,12 +8,25 @@ using Wino.Core.Domain;
namespace Wino.Mail.WinUI.Controls; namespace Wino.Mail.WinUI.Controls;
public sealed partial class AppModeFooterSwitcherControl : UserControl public sealed partial class AppModeFooterSwitcherControl : Segmented
{ {
private const double VerticalItemExtent = 44;
private readonly IStatePersistanceService _statePersistenceService; private readonly IStatePersistanceService _statePersistenceService;
private readonly INavigationService _navigationService; private readonly INavigationService _navigationService;
private bool _isUpdatingSelection; private bool _isUpdatingSelection;
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
nameof(Orientation),
typeof(Orientation),
typeof(AppModeFooterSwitcherControl),
new PropertyMetadata(Orientation.Horizontal, OnOrientationChanged));
public Orientation Orientation
{
get => (Orientation)GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}
public AppModeFooterSwitcherControl() public AppModeFooterSwitcherControl()
{ {
_statePersistenceService = WinoApplication.Current.Services.GetRequiredService<IStatePersistanceService>(); _statePersistenceService = WinoApplication.Current.Services.GetRequiredService<IStatePersistanceService>();
@@ -22,9 +35,15 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
InitializeComponent(); InitializeComponent();
} }
private static void OnOrientationChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs _)
{
((AppModeFooterSwitcherControl)dependencyObject).UpdateOrientationState();
}
private void ControlLoaded(object sender, RoutedEventArgs e) private void ControlLoaded(object sender, RoutedEventArgs e)
{ {
_statePersistenceService.StatePropertyChanged += StatePropertyChanged; _statePersistenceService.StatePropertyChanged += StatePropertyChanged;
UpdateOrientationState();
UpdateSelection(_statePersistenceService.ApplicationMode); UpdateSelection(_statePersistenceService.ApplicationMode);
} }
@@ -45,14 +64,14 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
if (_isUpdatingSelection) if (_isUpdatingSelection)
return; return;
if (ModeSegmentedControl.SelectedIndex == 3) if (SelectedIndex == 3)
{ {
_navigationService.Navigate(WinoPage.SettingsPage); _navigationService.Navigate(WinoPage.SettingsPage);
UpdateSelection(_statePersistenceService.ApplicationMode); UpdateSelection(_statePersistenceService.ApplicationMode);
return; return;
} }
var selectedMode = ModeSegmentedControl.SelectedIndex switch var selectedMode = SelectedIndex switch
{ {
1 => WinoApplicationMode.Calendar, 1 => WinoApplicationMode.Calendar,
2 => WinoApplicationMode.Contacts, 2 => WinoApplicationMode.Contacts,
@@ -68,7 +87,7 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
private void UpdateSelection(WinoApplicationMode mode) private void UpdateSelection(WinoApplicationMode mode)
{ {
_isUpdatingSelection = true; _isUpdatingSelection = true;
ModeSegmentedControl.SelectedIndex = mode switch SelectedIndex = mode switch
{ {
WinoApplicationMode.Calendar => 1, WinoApplicationMode.Calendar => 1,
WinoApplicationMode.Contacts => 2, WinoApplicationMode.Contacts => 2,
@@ -76,4 +95,24 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
}; };
_isUpdatingSelection = false; _isUpdatingSelection = false;
} }
private void UpdateOrientationState()
{
foreach (var item in Items)
{
if (item is not SegmentedItem segmentedItem)
continue;
if (Orientation == Orientation.Vertical)
{
segmentedItem.Width = VerticalItemExtent;
segmentedItem.Height = VerticalItemExtent;
}
else
{
segmentedItem.ClearValue(WidthProperty);
segmentedItem.ClearValue(HeightProperty);
}
}
}
} }
@@ -115,10 +115,16 @@ public partial class WinoCalendarFlipView : CustomCalendarFlipView, IDisposable
private void UpdateActiveElements() private void UpdateActiveElements()
{ {
var itemsSource = GetItemsSource();
if (SelectedIndex < 0) if (SelectedIndex < 0)
{ {
ActiveCanvas = null; if (itemsSource == null || itemsSource.Count == 0)
ActiveVerticalScrollViewer = null; {
ActiveCanvas = null;
ActiveVerticalScrollViewer = null;
}
return; return;
} }
@@ -130,9 +136,7 @@ public partial class WinoCalendarFlipView : CustomCalendarFlipView, IDisposable
} }
else else
{ {
// Container not ready yet - will be updated when OnContainerPrepared is called // Container not ready yet - keep the current active elements until OnContainerPrepared updates them.
ActiveCanvas = null;
ActiveVerticalScrollViewer = null;
} }
} }
@@ -3,7 +3,7 @@
"Wino.Mail.WinUI (Package)": { "Wino.Mail.WinUI (Package)": {
"commandName": "MsixPackage", "commandName": "MsixPackage",
"doNotLaunchApp": false, "doNotLaunchApp": false,
"nativeDebugging": false "nativeDebugging": true
}, },
"Wino.Mail.WinUI (Unpackaged)": { "Wino.Mail.WinUI (Unpackaged)": {
"commandName": "Project" "commandName": "Project"
@@ -7,6 +7,10 @@
xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives" xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives"
xmlns:winoControls="using:Wino.Mail.WinUI.Controls"> xmlns:winoControls="using:Wino.Mail.WinUI.Controls">
<ItemsPanelTemplate x:Key="FooterAppModeSwitcherVerticalItemsPanelTemplate">
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
<Style x:Key="CalendarShellNavigationViewStyle" TargetType="controls:NavigationView"> <Style x:Key="CalendarShellNavigationViewStyle" TargetType="controls:NavigationView">
<Setter Property="PaneToggleButtonStyle" Value="{StaticResource PaneToggleButtonStyle}" /> <Setter Property="PaneToggleButtonStyle" Value="{StaticResource PaneToggleButtonStyle}" />
<Setter Property="IsTabStop" Value="False" /> <Setter Property="IsTabStop" Value="False" />
@@ -396,12 +400,13 @@
VerticalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
IsTabStop="False" /> IsTabStop="False" />
<Border <Border
x:Name="FooterAppModeSwitcherBorder"
Grid.Row="3" Grid.Row="3"
Margin="8,8,8,12" Margin="8,8,8,12"
Padding="8" Padding="8"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
CornerRadius="{ThemeResource OverlayCornerRadius}"> CornerRadius="{ThemeResource OverlayCornerRadius}">
<winoControls:AppModeFooterSwitcherControl /> <winoControls:AppModeFooterSwitcherControl x:Name="FooterAppModeSwitcher" />
</Border> </Border>
</Grid> </Grid>
</Grid> </Grid>
@@ -525,6 +530,13 @@
<Setter Target="PaneAutoSuggestBoxPresenter.Visibility" Value="Collapsed" /> <Setter Target="PaneAutoSuggestBoxPresenter.Visibility" Value="Collapsed" />
<Setter Target="PaneAutoSuggestButton.Visibility" Value="Visible" /> <Setter Target="PaneAutoSuggestButton.Visibility" Value="Visible" />
<Setter Target="PaneCustomContentBorder.Visibility" Value="Collapsed" /> <Setter Target="PaneCustomContentBorder.Visibility" Value="Collapsed" />
<Setter Target="FooterAppModeSwitcher.ItemsPanel" Value="{StaticResource FooterAppModeSwitcherVerticalItemsPanelTemplate}" />
<Setter Target="FooterAppModeSwitcher.Orientation" Value="Vertical" />
<Setter Target="FooterAppModeSwitcherBorder.Margin" Value="0" />
<Setter Target="FooterAppModeSwitcherBorder.Padding" Value="0" />
<Setter Target="FooterAppModeSwitcherBorder.Background" Value="Transparent" />
<Setter Target="FooterAppModeSwitcher.BorderThickness" Value="0" />
<Setter Target="FooterAppModeSwitcher.Background" Value="Transparent" />
</VisualState.Setters> </VisualState.Setters>
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
+13 -12
View File
@@ -11,17 +11,17 @@
xmlns:coreControls="using:Wino.Mail.WinUI.Controls" xmlns:coreControls="using:Wino.Mail.WinUI.Controls"
xmlns:coreConverters="using:Wino.Mail.WinUI.Converters" xmlns:coreConverters="using:Wino.Mail.WinUI.Converters"
xmlns:coreSelectors="using:Wino.Mail.WinUI.Selectors" xmlns:coreSelectors="using:Wino.Mail.WinUI.Selectors"
xmlns:data="using:Wino.Calendar.ViewModels.Data"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:data="using:Wino.Calendar.ViewModels.Data"
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"
xmlns:helpers="using:Wino.Helpers" xmlns:helpers="using:Wino.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:menu="using:Wino.Core.Domain.MenuItems" xmlns:menu="using:Wino.Core.Domain.MenuItems"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
x:Name="Root"
Loaded="OnLoaded" Loaded="OnLoaded"
PreviewKeyDown="OnPreviewKeyDown" PreviewKeyDown="OnPreviewKeyDown"
x:Name="Root"
mc:Ignorable="d"> mc:Ignorable="d">
<Page.Resources> <Page.Resources>
@@ -425,8 +425,8 @@
<ContentPresenter x:Name="DynamicPageShellContentPresenter" /> <ContentPresenter x:Name="DynamicPageShellContentPresenter" />
<Grid <Grid
x:Name="CalendarShellContentRoot" x:Name="CalendarShellContentRoot"
Visibility="Collapsed" ColumnSpacing="12"
ColumnSpacing="12"> Visibility="Collapsed">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@@ -468,8 +468,7 @@
Background="Transparent" Background="Transparent"
FontSize="14" FontSize="14"
FontWeight="Normal" FontWeight="Normal"
IsHitTestVisible="False" IsHitTestVisible="False">
>
<FlipView.ItemTemplate> <FlipView.ItemTemplate>
<DataTemplate x:DataType="x:String"> <DataTemplate x:DataType="x:String">
<TextBlock <TextBlock
@@ -504,13 +503,11 @@
Padding="0" Padding="0"
ColumnSpacing="0" ColumnSpacing="0"
RowSpacing="0"> RowSpacing="0">
<muxc:NavigationView <muxc:NavigationView
x:Name="navigationView" x:Name="navigationView"
Grid.Row="1" Grid.Row="1"
Grid.ColumnSpan="3" Grid.ColumnSpan="3"
Margin="-1,-1,0,0" Margin="-1,-1,0,0"
Style="{StaticResource CalendarShellNavigationViewStyle}"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AlwaysShowHeader="True" AlwaysShowHeader="True"
@@ -527,14 +524,18 @@
PaneDisplayMode="Auto" PaneDisplayMode="Auto"
PaneOpening="NavigationPaneOpening" PaneOpening="NavigationPaneOpening"
ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"
SelectionChanged="MenuSelectionChanged"> SelectionChanged="MenuSelectionChanged"
Style="{StaticResource CalendarShellNavigationViewStyle}">
<muxc:NavigationView.ContentTransitions> <muxc:NavigationView.ContentTransitions>
<TransitionCollection> <TransitionCollection>
<AddDeleteThemeTransition /> <AddDeleteThemeTransition />
</TransitionCollection> </TransitionCollection>
</muxc:NavigationView.ContentTransitions> </muxc:NavigationView.ContentTransitions>
<muxc:NavigationView.PaneCustomContent> <muxc:NavigationView.PaneCustomContent>
<Grid x:Name="PaneCustomContent" Padding="0,0,0,6" Visibility="Collapsed"> <Grid
x:Name="PaneCustomContent"
Padding="0,0,0,6"
Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@@ -639,13 +640,13 @@
IsHitTestVisible="{x:Bind navigationView.IsPaneOpen, Mode=OneWay}" IsHitTestVisible="{x:Bind navigationView.IsPaneOpen, Mode=OneWay}"
IsTabStop="False" IsTabStop="False"
Maximum="1000" Maximum="1000"
Minimum="116" /> Minimum="160" />
<!-- Main Content --> <!-- Main Content -->
<Frame <Frame
x:Name="InnerShellFrame" x:Name="InnerShellFrame"
CacheSize="0"
Padding="0,0,7,7" Padding="0,0,7,7"
CacheSize="0"
IsNavigationStackEnabled="True" IsNavigationStackEnabled="True"
Navigated="ShellFrameContentNavigated"> Navigated="ShellFrameContentNavigated">
<Frame.ContentTransitions> <Frame.ContentTransitions>
@@ -439,6 +439,16 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
private void CalendarClientPropertyChanged(object? sender, PropertyChangedEventArgs e) 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 property changes onto the UI thread.");
return;
}
if (e.PropertyName == nameof(ICalendarShellClient.DateNavigationHeaderItems)) if (e.PropertyName == nameof(ICalendarShellClient.DateNavigationHeaderItems))
{ {
DayHeaderNavigationItemsFlipView.ItemsSource = ViewModel.CalendarClient.DateNavigationHeaderItems; DayHeaderNavigationItemsFlipView.ItemsSource = ViewModel.CalendarClient.DateNavigationHeaderItems;