Shell improvements.
This commit is contained in:
@@ -1,38 +1,32 @@
|
||||
<UserControl
|
||||
<controls:Segmented
|
||||
x:Class="Wino.Mail.WinUI.Controls.AppModeFooterSwitcherControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
Loaded="ControlLoaded"
|
||||
SelectionChanged="ModeSegmentedControlSelectionChanged"
|
||||
Unloaded="ControlUnloaded">
|
||||
|
||||
<Grid>
|
||||
<controls:Segmented
|
||||
x:Name="ModeSegmentedControl"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectionChanged="ModeSegmentedControlSelectionChanged">
|
||||
<controls:SegmentedItem ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeMail, Mode=OneWay}">
|
||||
<controls:SegmentedItem.Icon>
|
||||
<SymbolIcon Symbol="Mail" />
|
||||
</controls:SegmentedItem.Icon>
|
||||
</controls:SegmentedItem>
|
||||
<controls:SegmentedItem ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeCalendar, Mode=OneWay}">
|
||||
<controls:SegmentedItem.Icon>
|
||||
<SymbolIcon Symbol="Calendar" />
|
||||
</controls:SegmentedItem.Icon>
|
||||
</controls:SegmentedItem>
|
||||
<controls:SegmentedItem ToolTipService.ToolTip="{x:Bind domain:Translator.ContactsPage_Title, Mode=OneWay}">
|
||||
<controls:SegmentedItem.Icon>
|
||||
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="" />
|
||||
</controls:SegmentedItem.Icon>
|
||||
</controls:SegmentedItem>
|
||||
<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>
|
||||
<controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeMail, Mode=OneWay}">
|
||||
<controls:SegmentedItem.Icon>
|
||||
<SymbolIcon Symbol="Mail" />
|
||||
</controls:SegmentedItem.Icon>
|
||||
</controls:SegmentedItem>
|
||||
<controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.KeyboardShortcuts_ModeCalendar, Mode=OneWay}">
|
||||
<controls:SegmentedItem.Icon>
|
||||
<SymbolIcon Symbol="Calendar" />
|
||||
</controls:SegmentedItem.Icon>
|
||||
</controls:SegmentedItem>
|
||||
<controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.ContactsPage_Title, Mode=OneWay}">
|
||||
<controls:SegmentedItem.Icon>
|
||||
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="" />
|
||||
</controls:SegmentedItem.Icon>
|
||||
</controls:SegmentedItem>
|
||||
<controls:SegmentedItem Padding="0" ToolTipService.ToolTip="{x:Bind domain:Translator.MenuSettings, Mode=OneWay}">
|
||||
<controls:SegmentedItem.Icon>
|
||||
<SymbolIcon Symbol="Setting" />
|
||||
</controls:SegmentedItem.Icon>
|
||||
</controls:SegmentedItem>
|
||||
</controls:Segmented>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using CommunityToolkit.WinUI.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
@@ -8,12 +8,25 @@ using Wino.Core.Domain;
|
||||
|
||||
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 INavigationService _navigationService;
|
||||
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()
|
||||
{
|
||||
_statePersistenceService = WinoApplication.Current.Services.GetRequiredService<IStatePersistanceService>();
|
||||
@@ -22,9 +35,15 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private static void OnOrientationChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs _)
|
||||
{
|
||||
((AppModeFooterSwitcherControl)dependencyObject).UpdateOrientationState();
|
||||
}
|
||||
|
||||
private void ControlLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_statePersistenceService.StatePropertyChanged += StatePropertyChanged;
|
||||
UpdateOrientationState();
|
||||
UpdateSelection(_statePersistenceService.ApplicationMode);
|
||||
}
|
||||
|
||||
@@ -45,14 +64,14 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
|
||||
if (_isUpdatingSelection)
|
||||
return;
|
||||
|
||||
if (ModeSegmentedControl.SelectedIndex == 3)
|
||||
if (SelectedIndex == 3)
|
||||
{
|
||||
_navigationService.Navigate(WinoPage.SettingsPage);
|
||||
UpdateSelection(_statePersistenceService.ApplicationMode);
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedMode = ModeSegmentedControl.SelectedIndex switch
|
||||
var selectedMode = SelectedIndex switch
|
||||
{
|
||||
1 => WinoApplicationMode.Calendar,
|
||||
2 => WinoApplicationMode.Contacts,
|
||||
@@ -68,7 +87,7 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
|
||||
private void UpdateSelection(WinoApplicationMode mode)
|
||||
{
|
||||
_isUpdatingSelection = true;
|
||||
ModeSegmentedControl.SelectedIndex = mode switch
|
||||
SelectedIndex = mode switch
|
||||
{
|
||||
WinoApplicationMode.Calendar => 1,
|
||||
WinoApplicationMode.Contacts => 2,
|
||||
@@ -76,4 +95,24 @@ public sealed partial class AppModeFooterSwitcherControl : UserControl
|
||||
};
|
||||
_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()
|
||||
{
|
||||
var itemsSource = GetItemsSource();
|
||||
|
||||
if (SelectedIndex < 0)
|
||||
{
|
||||
ActiveCanvas = null;
|
||||
ActiveVerticalScrollViewer = null;
|
||||
if (itemsSource == null || itemsSource.Count == 0)
|
||||
{
|
||||
ActiveCanvas = null;
|
||||
ActiveVerticalScrollViewer = null;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,9 +136,7 @@ public partial class WinoCalendarFlipView : CustomCalendarFlipView, IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
// Container not ready yet - will be updated when OnContainerPrepared is called
|
||||
ActiveCanvas = null;
|
||||
ActiveVerticalScrollViewer = null;
|
||||
// Container not ready yet - keep the current active elements until OnContainerPrepared updates them.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user