Better shell
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<UserControl
|
||||
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:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:domain="using:Wino.Core.Domain">
|
||||
|
||||
<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:Segmented>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Mail.WinUI.Controls;
|
||||
|
||||
public sealed partial class AppModeFooterSwitcherControl : UserControl
|
||||
{
|
||||
private readonly IStatePersistanceService _statePersistenceService;
|
||||
private readonly INavigationService _navigationService;
|
||||
private bool _isUpdatingSelection;
|
||||
|
||||
public AppModeFooterSwitcherControl()
|
||||
{
|
||||
_statePersistenceService = WinoApplication.Current.Services.GetRequiredService<IStatePersistanceService>();
|
||||
_navigationService = WinoApplication.Current.Services.GetRequiredService<INavigationService>();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Loaded += ControlLoaded;
|
||||
Unloaded += ControlUnloaded;
|
||||
}
|
||||
|
||||
private void ControlLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_statePersistenceService.StatePropertyChanged += StatePropertyChanged;
|
||||
UpdateSelection(_statePersistenceService.ApplicationMode);
|
||||
}
|
||||
|
||||
private void ControlUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_statePersistenceService.StatePropertyChanged -= StatePropertyChanged;
|
||||
}
|
||||
|
||||
private void StatePropertyChanged(object? sender, string propertyName)
|
||||
{
|
||||
if (propertyName != nameof(IStatePersistanceService.ApplicationMode))
|
||||
return;
|
||||
|
||||
DispatcherQueue.TryEnqueue(() => UpdateSelection(_statePersistenceService.ApplicationMode));
|
||||
}
|
||||
|
||||
private void ModeSegmentedControlSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_isUpdatingSelection)
|
||||
return;
|
||||
|
||||
var selectedMode = ModeSegmentedControl.SelectedIndex switch
|
||||
{
|
||||
1 => WinoApplicationMode.Calendar,
|
||||
2 => WinoApplicationMode.Contacts,
|
||||
_ => WinoApplicationMode.Mail
|
||||
};
|
||||
|
||||
if (selectedMode == _statePersistenceService.ApplicationMode)
|
||||
return;
|
||||
|
||||
_navigationService.ChangeApplicationMode(selectedMode);
|
||||
}
|
||||
|
||||
private void UpdateSelection(WinoApplicationMode mode)
|
||||
{
|
||||
_isUpdatingSelection = true;
|
||||
ModeSegmentedControl.SelectedIndex = mode switch
|
||||
{
|
||||
WinoApplicationMode.Calendar => 1,
|
||||
WinoApplicationMode.Contacts => 2,
|
||||
_ => 0
|
||||
};
|
||||
_isUpdatingSelection = false;
|
||||
}
|
||||
}
|
||||
@@ -80,9 +80,9 @@
|
||||
|
||||
<muxc:ProgressRing
|
||||
x:Name="BusyRing"
|
||||
Grid.Column="2"
|
||||
Width="14"
|
||||
Height="14"
|
||||
Grid.Column="2"
|
||||
Margin="0,2,2,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
|
||||
@@ -22,18 +22,14 @@
|
||||
<DataTemplate x:DataType="models:UpdateNoteSection">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Padding="8" Spacing="12">
|
||||
<controls:MarkdownTextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Text="{x:Bind Title, Mode=OneTime}" />
|
||||
<controls:MarkdownTextBlock HorizontalAlignment="Center" Text="{x:Bind Title, Mode=OneTime}" />
|
||||
<Image
|
||||
Width="{x:Bind ActualImageWidth, Mode=OneTime}"
|
||||
Height="{x:Bind ActualImageHeight, Mode=OneTime}"
|
||||
HorizontalAlignment="Center"
|
||||
Source="{x:Bind ImageUrl, Mode=OneTime}"
|
||||
Stretch="Uniform" />
|
||||
<controls:MarkdownTextBlock
|
||||
HorizontalAlignment="Stretch"
|
||||
Text="{x:Bind Description, Mode=OneTime}" />
|
||||
<controls:MarkdownTextBlock HorizontalAlignment="Stretch" Text="{x:Bind Description, Mode=OneTime}" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</DataTemplate>
|
||||
@@ -44,7 +40,7 @@
|
||||
x:Name="FlipViewPager"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
SelectedPageIndex="0"
|
||||
SelectedIndexChanged="OnPipsPagerSelectedIndexChanged" />
|
||||
SelectedIndexChanged="OnPipsPagerSelectedIndexChanged"
|
||||
SelectedPageIndex="0" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user