Improved keyboad shortcuts.
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using System;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models;
|
||||
using Wino.Mail.Views.Abstract;
|
||||
using Wino.Messaging.Client.Calendar;
|
||||
|
||||
@@ -17,14 +23,13 @@ public sealed partial class CalendarAppShell : CalendarAppShellAbstract,
|
||||
public CalendarAppShell()
|
||||
{
|
||||
InitializeComponent();
|
||||
PreviewKeyDown += OnPreviewKeyDown;
|
||||
|
||||
// Window.Current.SetTitleBar(DragArea);
|
||||
ManageCalendarDisplayType(ViewModel.StatePersistenceService.CalendarDisplayType);
|
||||
}
|
||||
|
||||
private void ManageCalendarDisplayType(Core.Domain.Enums.CalendarDisplayType displayType)
|
||||
{
|
||||
// Go to different states based on the display type.
|
||||
if (displayType == Core.Domain.Enums.CalendarDisplayType.Month)
|
||||
{
|
||||
VisualStateManager.GoToState(this, STATE_VerticalCalendar, false);
|
||||
@@ -44,12 +49,6 @@ public sealed partial class CalendarAppShell : CalendarAppShellAbstract,
|
||||
ManageCalendarDisplayType(message.NewDisplayType);
|
||||
}
|
||||
|
||||
//private void ShellFrameContentNavigated(object sender, Microsoft.UI.Xaml.Navigation.NavigationEventArgs e)
|
||||
// => RealAppBar.ShellFrameContent = (e.Content as BasePage).ShellContent;
|
||||
|
||||
//private void AppBarBackButtonClicked(Core.UWP.Controls.WinoAppTitleBar sender, RoutedEventArgs args)
|
||||
// => ViewModel.NavigationService.GoBack();
|
||||
|
||||
protected override void RegisterRecipients()
|
||||
{
|
||||
base.RegisterRecipients();
|
||||
@@ -63,4 +62,98 @@ public sealed partial class CalendarAppShell : CalendarAppShellAbstract,
|
||||
|
||||
WeakReferenceMessenger.Default.Unregister<CalendarDisplayTypeChangedMessage>(this);
|
||||
}
|
||||
|
||||
private async void OnPreviewKeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.KeyStatus.RepeatCount > 1 || ShouldIgnoreShortcut())
|
||||
return;
|
||||
|
||||
var key = NormalizeKey(e.Key);
|
||||
if (string.IsNullOrEmpty(key))
|
||||
return;
|
||||
|
||||
var shortcutService = WinoApplication.Current.Services.GetRequiredService<IKeyboardShortcutService>();
|
||||
var shortcut = await shortcutService.GetShortcutForKeyAsync(WinoApplicationMode.Calendar, key, GetCurrentModifierKeys());
|
||||
|
||||
if (shortcut == null)
|
||||
return;
|
||||
|
||||
var details = new KeyboardShortcutTriggerDetails
|
||||
{
|
||||
ShortcutId = shortcut.Id,
|
||||
Mode = shortcut.Mode,
|
||||
Action = shortcut.Action,
|
||||
Key = shortcut.Key,
|
||||
ModifierKeys = shortcut.ModifierKeys,
|
||||
Sender = sender,
|
||||
Origin = FocusManager.GetFocusedElement(XamlRoot)
|
||||
};
|
||||
|
||||
await ViewModel.KeyboardShortcutHook(details);
|
||||
|
||||
if (InnerShellFrame.Content is BasePage activePage && activePage.AssociatedViewModel != null)
|
||||
{
|
||||
await activePage.AssociatedViewModel.KeyboardShortcutHook(details);
|
||||
}
|
||||
|
||||
if (details.Handled)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShouldIgnoreShortcut()
|
||||
{
|
||||
var focusedElement = FocusManager.GetFocusedElement(XamlRoot);
|
||||
|
||||
if (focusedElement is TextBox or AutoSuggestBox or PasswordBox or RichEditBox or ComboBox)
|
||||
return true;
|
||||
|
||||
if (focusedElement is FrameworkElement frameworkElement)
|
||||
{
|
||||
var typeName = frameworkElement.GetType().Name;
|
||||
if (typeName.Contains("WebView", StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ModifierKeys GetCurrentModifierKeys()
|
||||
{
|
||||
var modifiers = ModifierKeys.None;
|
||||
|
||||
if (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(Windows.System.VirtualKey.Control).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down))
|
||||
modifiers |= ModifierKeys.Control;
|
||||
if (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(Windows.System.VirtualKey.Menu).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down))
|
||||
modifiers |= ModifierKeys.Alt;
|
||||
if (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(Windows.System.VirtualKey.Shift).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down))
|
||||
modifiers |= ModifierKeys.Shift;
|
||||
if (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(Windows.System.VirtualKey.LeftWindows).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down) ||
|
||||
Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(Windows.System.VirtualKey.RightWindows).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down))
|
||||
{
|
||||
modifiers |= ModifierKeys.Windows;
|
||||
}
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
private static string NormalizeKey(Windows.System.VirtualKey key)
|
||||
{
|
||||
return key switch
|
||||
{
|
||||
Windows.System.VirtualKey.Control or
|
||||
Windows.System.VirtualKey.LeftControl or
|
||||
Windows.System.VirtualKey.RightControl or
|
||||
Windows.System.VirtualKey.Menu or
|
||||
Windows.System.VirtualKey.LeftMenu or
|
||||
Windows.System.VirtualKey.RightMenu or
|
||||
Windows.System.VirtualKey.Shift or
|
||||
Windows.System.VirtualKey.LeftShift or
|
||||
Windows.System.VirtualKey.RightShift or
|
||||
Windows.System.VirtualKey.LeftWindows or
|
||||
Windows.System.VirtualKey.RightWindows => string.Empty,
|
||||
_ => key.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,8 +470,8 @@
|
||||
<Border
|
||||
x:Name="AttachmentsPane"
|
||||
Margin="0,8,0,0"
|
||||
AllowDrop="True"
|
||||
Padding="16"
|
||||
AllowDrop="True"
|
||||
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
|
||||
CornerRadius="{StaticResource ControlCornerRadius}"
|
||||
DragLeave="AttachmentsPane_DragLeave"
|
||||
@@ -487,7 +487,10 @@
|
||||
Style="{StaticResource TransparentActionButtonStyle}">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<coreControls:WinoFontIcon FontSize="14" Icon="AttachmentNew" />
|
||||
<TextBlock FontSize="18" FontWeight="SemiBold" Text="+" />
|
||||
<TextBlock
|
||||
FontSize="18"
|
||||
FontWeight="SemiBold"
|
||||
Text="+" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
@@ -560,7 +563,20 @@
|
||||
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Text="{x:Bind domain:Translator.CalendarEventCompose_Notes}" />
|
||||
</StackPanel>
|
||||
<!-- Notes Editor -->
|
||||
<mailControls:EditorTabbedCommandBarControl CommandTarget="{x:Bind NotesEditor}" />
|
||||
<mailControls:EditorTabbedCommandBarControl CommandTarget="{x:Bind NotesEditor}">
|
||||
<mailControls:EditorTabbedCommandBarControl.PaneCustomContent>
|
||||
<toolkit:TabbedCommandBarItem
|
||||
CommandAlignment="Right"
|
||||
IsDynamicOverflowEnabled="True"
|
||||
OverflowButtonAlignment="Left">
|
||||
<AppBarButton Click="ToggleNotesEditorThemeClicked" ToolTipService.ToolTip="{x:Bind GetEditorThemeToolTip(NotesEditor.IsEditorDarkMode), Mode=OneWay}">
|
||||
<AppBarButton.Icon>
|
||||
<coreControls:WinoFontIcon Icon="{x:Bind GetEditorThemeIcon(NotesEditor.IsEditorDarkMode), Mode=OneWay}" />
|
||||
</AppBarButton.Icon>
|
||||
</AppBarButton>
|
||||
</toolkit:TabbedCommandBarItem>
|
||||
</mailControls:EditorTabbedCommandBarControl.PaneCustomContent>
|
||||
</mailControls:EditorTabbedCommandBarControl>
|
||||
<mailControls:WebViewEditorControl
|
||||
x:Name="NotesEditor"
|
||||
MinHeight="500"
|
||||
|
||||
@@ -15,6 +15,7 @@ using Windows.Storage;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Messaging.Client.Shell;
|
||||
using Wino.Calendar.ViewModels.Data;
|
||||
using Wino.Mail.WinUI.Controls;
|
||||
using Wino.Mail.WinUI.Views.Abstract;
|
||||
|
||||
namespace Wino.Calendar.Views;
|
||||
@@ -29,6 +30,15 @@ public sealed partial class CalendarEventComposePage : CalendarEventComposePageA
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WinoIconGlyph GetEditorThemeIcon(bool isDarkMode) => isDarkMode ? WinoIconGlyph.LightEditor : WinoIconGlyph.DarkEditor;
|
||||
|
||||
public string GetEditorThemeToolTip(bool isDarkMode) => isDarkMode ? Translator.Composer_LightTheme : Translator.Composer_DarkTheme;
|
||||
|
||||
private void ToggleNotesEditorThemeClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NotesEditor.ToggleEditorTheme();
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
@@ -145,14 +145,13 @@
|
||||
Visibility="{x:Bind ViewModel.IsDraftBusy, Mode=OneWay}">
|
||||
<ProgressRing IsActive="True" />
|
||||
</AppBarButton>
|
||||
<AppBarToggleButton
|
||||
x:Name="EditorThemeToggleButton"
|
||||
IsChecked="{x:Bind WebViewEditor.IsEditorDarkMode, Mode=TwoWay}"
|
||||
ToolTipService.ToolTip="Toggle editor dark mode">
|
||||
<AppBarToggleButton.Icon>
|
||||
<coreControls:WinoFontIcon Icon="DarkEditor" />
|
||||
</AppBarToggleButton.Icon>
|
||||
</AppBarToggleButton>
|
||||
<AppBarButton
|
||||
Click="ToggleEditorThemeClicked"
|
||||
ToolTipService.ToolTip="{x:Bind GetEditorThemeToolTip(WebViewEditor.IsEditorDarkMode), Mode=OneWay}">
|
||||
<AppBarButton.Icon>
|
||||
<coreControls:WinoFontIcon Icon="{x:Bind GetEditorThemeIcon(WebViewEditor.IsEditorDarkMode), Mode=OneWay}" />
|
||||
</AppBarButton.Icon>
|
||||
</AppBarButton>
|
||||
<AppBarButton Command="{x:Bind ViewModel.DiscardCommand}" Label="{x:Bind domain:Translator.Buttons_Discard}">
|
||||
<AppBarButton.Icon>
|
||||
<coreControls:WinoFontIcon Icon="Delete" />
|
||||
|
||||
@@ -22,6 +22,7 @@ using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Models.Reader;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Mail.ViewModels.Messages;
|
||||
using Wino.Mail.WinUI.Controls;
|
||||
using Wino.Mail.WinUI.Extensions;
|
||||
using Wino.Messaging.Client.Mails;
|
||||
using Wino.Messaging.Client.Shell;
|
||||
@@ -43,6 +44,15 @@ public sealed partial class ComposePage : ComposePageAbstract,
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WinoIconGlyph GetEditorThemeIcon(bool isDarkMode) => isDarkMode ? WinoIconGlyph.LightEditor : WinoIconGlyph.DarkEditor;
|
||||
|
||||
public string GetEditorThemeToolTip(bool isDarkMode) => isDarkMode ? Translator.Composer_LightTheme : Translator.Composer_DarkTheme;
|
||||
|
||||
private void ToggleEditorThemeClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WebViewEditor.ToggleEditorTheme();
|
||||
}
|
||||
|
||||
private async void GlobalFocusManagerGotFocus(object? sender, FocusManagerGotFocusEventArgs e)
|
||||
{
|
||||
// In order to delegate cursor to the inner editor for WebView2.
|
||||
|
||||
@@ -52,7 +52,6 @@ public sealed partial class MailListPage : MailListPageAbstract,
|
||||
|
||||
private IStatePersistanceService StatePersistenceService { get; } = WinoApplication.Current.Services.GetService<IStatePersistanceService>() ?? throw new Exception($"Can't resolve {nameof(KeyPressService)}");
|
||||
private IKeyPressService KeyPressService { get; } = WinoApplication.Current.Services.GetService<IKeyPressService>() ?? throw new Exception($"Can't resolve {nameof(KeyPressService)}");
|
||||
private IKeyboardShortcutService KeyboardShortcutService { get; } = WinoApplication.Current.Services.GetService<IKeyboardShortcutService>() ?? throw new Exception($"Can't resolve {nameof(IKeyboardShortcutService)}");
|
||||
public MailListPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -671,19 +670,7 @@ public sealed partial class MailListPage : MailListPageAbstract,
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check keyboard shortcuts from service.
|
||||
ModifierKeys modifiers = args.Modifiers.ToDomainModifierKeys();
|
||||
|
||||
var operation = await KeyboardShortcutService.GetMailOperationForKeyAsync(args.Key.ToString(), modifiers);
|
||||
|
||||
if (operation != null)
|
||||
{
|
||||
ViewModel.ExecuteMailOperationCommand.Execute(operation);
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Handled = false;
|
||||
}
|
||||
args.Handled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.Linq;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using MoreLinq;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Helpers;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Mail.WinUI.Views.Abstract;
|
||||
using Wino.Messaging.Client.Navigation;
|
||||
@@ -42,7 +42,7 @@ public sealed partial class ManageAccountsPage : ManageAccountsPageAbstract,
|
||||
AccountPagesFrame.Navigated += AccountPagesFrameNavigated;
|
||||
|
||||
var initialRequest = new BreadcrumbNavigationRequested(Translator.MenuManageAccounts, WinoPage.AccountManagementPage);
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(initialRequest, true));
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(initialRequest, true, backStackDepth: AccountPagesFrame.BackStack.Count + 1));
|
||||
|
||||
var accountManagementPageType = ViewModel.NavigationService.GetPageType(WinoPage.AccountManagementPage);
|
||||
|
||||
@@ -69,15 +69,7 @@ public sealed partial class ManageAccountsPage : ManageAccountsPageAbstract,
|
||||
|
||||
void IRecipient<BreadcrumbNavigationRequested>.Receive(BreadcrumbNavigationRequested message)
|
||||
{
|
||||
var pageType = ViewModel.NavigationService.GetPageType(message.PageType);
|
||||
|
||||
if (pageType == null) return;
|
||||
|
||||
AccountPagesFrame.Navigate(pageType, message.Parameter, new SlideNavigationTransitionInfo() { Effect = Microsoft.UI.Xaml.Media.Animation.SlideNavigationTransitionEffect.FromRight });
|
||||
|
||||
PageHistory.ForEach(a => a.IsActive = false);
|
||||
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(message, true));
|
||||
BreadcrumbNavigationHelper.Navigate(AccountPagesFrame, PageHistory, message, ViewModel.NavigationService.GetPageType);
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
@@ -89,40 +81,20 @@ public sealed partial class ManageAccountsPage : ManageAccountsPageAbstract,
|
||||
|
||||
private void GoBackFrame(Core.Domain.Enums.NavigationTransitionEffect slideEffect)
|
||||
{
|
||||
if (AccountPagesFrame.CanGoBack)
|
||||
{
|
||||
PageHistory.RemoveAt(PageHistory.Count - 1);
|
||||
if (!BreadcrumbNavigationHelper.GoBack(AccountPagesFrame, PageHistory, slideEffect))
|
||||
return;
|
||||
|
||||
var winuiEffect = slideEffect switch
|
||||
{
|
||||
Core.Domain.Enums.NavigationTransitionEffect.FromLeft => Microsoft.UI.Xaml.Media.Animation.SlideNavigationTransitionEffect.FromLeft,
|
||||
_ => Microsoft.UI.Xaml.Media.Animation.SlideNavigationTransitionEffect.FromRight,
|
||||
};
|
||||
|
||||
AccountPagesFrame.GoBack(new SlideNavigationTransitionInfo() { Effect = winuiEffect });
|
||||
|
||||
// Set the new last item as active
|
||||
if (PageHistory.Count > 0)
|
||||
{
|
||||
PageHistory.ForEach(a => a.IsActive = false);
|
||||
PageHistory[PageHistory.Count - 1].IsActive = true;
|
||||
}
|
||||
|
||||
// Update back button visibility after navigation
|
||||
ViewModel.StatePersistenceService.IsManageAccountsNavigating = AccountPagesFrame.CanGoBack;
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
ViewModel.StatePersistenceService.IsManageAccountsNavigating = AccountPagesFrame.CanGoBack;
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
private void BreadItemClicked(Microsoft.UI.Xaml.Controls.BreadcrumbBar sender, Microsoft.UI.Xaml.Controls.BreadcrumbBarItemClickedEventArgs args)
|
||||
{
|
||||
var clickedPageHistory = PageHistory[args.Index];
|
||||
if (!BreadcrumbNavigationHelper.NavigateTo(AccountPagesFrame, PageHistory, args.Index))
|
||||
return;
|
||||
|
||||
// Trigger GoBack repeatedly until we reach the clicked breadcrumb item
|
||||
while (PageHistory.FirstOrDefault(a => a.IsActive) != clickedPageHistory)
|
||||
{
|
||||
ViewModel.NavigationService.GoBack();
|
||||
}
|
||||
ViewModel.StatePersistenceService.IsManageAccountsNavigating = AccountPagesFrame.CanGoBack;
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
public void Receive(BackBreadcrumNavigationRequested message)
|
||||
|
||||
@@ -221,6 +221,17 @@
|
||||
<FontIcon Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" Glyph="" />
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard
|
||||
Click="SettingOptionClicked"
|
||||
Description="{x:Bind domain:Translator.Settings_KeyboardShortcuts_Description}"
|
||||
Header="{x:Bind domain:Translator.Settings_KeyboardShortcuts_Title}"
|
||||
IsClickEnabled="True"
|
||||
Tag="{x:Bind enums:WinoPage.KeyboardShortcutsPage}">
|
||||
<controls:SettingsCard.HeaderIcon>
|
||||
<FontIcon Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" Glyph="" />
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</abstract:SettingOptionsPageAbstract>
|
||||
|
||||
@@ -52,19 +52,28 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock
|
||||
Margin="0,0,0,4"
|
||||
Style="{ThemeResource BodyStrongTextBlockStyle}"
|
||||
Text="{x:Bind MailOperationDisplayName}" />
|
||||
Text="{x:Bind ActionDisplayName}" />
|
||||
<TextBlock
|
||||
Opacity="0.8"
|
||||
Style="{ThemeResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind DisplayName}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="8,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{ThemeResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind ModeDisplayName}" />
|
||||
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Margin="4,0"
|
||||
@@ -73,7 +82,7 @@
|
||||
Content=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
Style="{ThemeResource SubtleButtonStyle}"
|
||||
ToolTipService.ToolTip="Edit" />
|
||||
ToolTipService.ToolTip="{x:Bind domain:Translator.Buttons_Edit}" />
|
||||
|
||||
<Button
|
||||
Grid.Column="3"
|
||||
@@ -83,7 +92,7 @@
|
||||
Content=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
Style="{ThemeResource SubtleButtonStyle}"
|
||||
ToolTipService.ToolTip="Delete" />
|
||||
ToolTipService.ToolTip="{x:Bind domain:Translator.Buttons_Delete}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.Linq;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using MoreLinq;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Helpers;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Messaging.Client.Navigation;
|
||||
using Wino.Views.Abstract;
|
||||
@@ -35,7 +35,7 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
|
||||
SettingsFrame.Navigate(typeof(SettingOptionsPage), null, new SuppressNavigationTransitionInfo());
|
||||
|
||||
var initialRequest = new BreadcrumbNavigationRequested(Translator.MenuSettings, WinoPage.SettingOptionsPage);
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(initialRequest, true));
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(initialRequest, true, backStackDepth: SettingsFrame.BackStack.Count + 1));
|
||||
|
||||
if (e.Parameter is WinoPage parameterPage)
|
||||
{
|
||||
@@ -99,15 +99,7 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
|
||||
|
||||
void IRecipient<BreadcrumbNavigationRequested>.Receive(BreadcrumbNavigationRequested message)
|
||||
{
|
||||
var pageType = ViewModel.NavigationService.GetPageType(message.PageType);
|
||||
|
||||
if (pageType == null) return;
|
||||
|
||||
SettingsFrame.Navigate(pageType, message.Parameter, new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight });
|
||||
|
||||
PageHistory.ForEach(a => a.IsActive = false);
|
||||
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(message, true));
|
||||
BreadcrumbNavigationHelper.Navigate(SettingsFrame, PageHistory, message, ViewModel.NavigationService.GetPageType);
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
@@ -119,40 +111,20 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
|
||||
|
||||
private void GoBackFrame(Core.Domain.Enums.NavigationTransitionEffect slideEffect)
|
||||
{
|
||||
if (SettingsFrame.CanGoBack)
|
||||
{
|
||||
PageHistory.RemoveAt(PageHistory.Count - 1);
|
||||
if (!BreadcrumbNavigationHelper.GoBack(SettingsFrame, PageHistory, slideEffect))
|
||||
return;
|
||||
|
||||
var winuiEffect = slideEffect switch
|
||||
{
|
||||
Core.Domain.Enums.NavigationTransitionEffect.FromLeft => Microsoft.UI.Xaml.Media.Animation.SlideNavigationTransitionEffect.FromLeft,
|
||||
_ => Microsoft.UI.Xaml.Media.Animation.SlideNavigationTransitionEffect.FromRight,
|
||||
};
|
||||
|
||||
SettingsFrame.GoBack(new SlideNavigationTransitionInfo() { Effect = winuiEffect });
|
||||
|
||||
// Set the new last item as active
|
||||
if (PageHistory.Count > 0)
|
||||
{
|
||||
PageHistory.ForEach(a => a.IsActive = false);
|
||||
PageHistory[PageHistory.Count - 1].IsActive = true;
|
||||
}
|
||||
|
||||
// Update back button visibility after navigation
|
||||
ViewModel.StatePersistenceService.IsSettingsNavigating = SettingsFrame.CanGoBack;
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
ViewModel.StatePersistenceService.IsSettingsNavigating = SettingsFrame.CanGoBack;
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
private void BreadItemClicked(Microsoft.UI.Xaml.Controls.BreadcrumbBar sender, Microsoft.UI.Xaml.Controls.BreadcrumbBarItemClickedEventArgs args)
|
||||
{
|
||||
var clickedPageHistory = PageHistory[args.Index];
|
||||
if (!BreadcrumbNavigationHelper.NavigateTo(SettingsFrame, PageHistory, args.Index))
|
||||
return;
|
||||
|
||||
// Trigger GoBack repeatedly until we reach the clicked breadcrumb item
|
||||
while (PageHistory.FirstOrDefault(a => a.IsActive) != clickedPageHistory)
|
||||
{
|
||||
ViewModel.NavigationService.GoBack();
|
||||
}
|
||||
ViewModel.StatePersistenceService.IsSettingsNavigating = SettingsFrame.CanGoBack;
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
public void Receive(BackBreadcrumNavigationRequested message)
|
||||
|
||||
@@ -3,8 +3,8 @@ using System.Linq;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using MoreLinq;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Helpers;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Mail.WinUI.Views.Abstract;
|
||||
using Wino.Messaging.Client.Navigation;
|
||||
@@ -45,16 +45,7 @@ public sealed partial class WelcomeHostPage : WelcomeHostPageAbstract,
|
||||
|
||||
public void Receive(BreadcrumbNavigationRequested message)
|
||||
{
|
||||
var pageType = ViewModel.NavigationService.GetPageType(message.PageType);
|
||||
if (pageType == null) return;
|
||||
|
||||
WizardFrame.Navigate(pageType, message.Parameter, new SlideNavigationTransitionInfo
|
||||
{
|
||||
Effect = SlideNavigationTransitionEffect.FromRight
|
||||
});
|
||||
|
||||
PageHistory.ForEach(a => a.IsActive = false);
|
||||
PageHistory.Add(new BreadcrumbNavigationItemViewModel(message, isActive: true, stepNumber: PageHistory.Count + 1));
|
||||
BreadcrumbNavigationHelper.Navigate(WizardFrame, PageHistory, message, ViewModel.NavigationService.GetPageType);
|
||||
}
|
||||
|
||||
public void Receive(BackBreadcrumNavigationRequested message)
|
||||
@@ -64,33 +55,11 @@ public sealed partial class WelcomeHostPage : WelcomeHostPageAbstract,
|
||||
|
||||
private void GoBackFrame()
|
||||
{
|
||||
if (!WizardFrame.CanGoBack) return;
|
||||
|
||||
PageHistory.RemoveAt(PageHistory.Count - 1);
|
||||
WizardFrame.GoBack(new SlideNavigationTransitionInfo
|
||||
{
|
||||
Effect = SlideNavigationTransitionEffect.FromLeft
|
||||
});
|
||||
|
||||
if (PageHistory.Count > 0)
|
||||
{
|
||||
PageHistory.ForEach(a => a.IsActive = false);
|
||||
PageHistory[PageHistory.Count - 1].IsActive = true;
|
||||
}
|
||||
BreadcrumbNavigationHelper.GoBack(WizardFrame, PageHistory, NavigationTransitionEffect.FromLeft);
|
||||
}
|
||||
|
||||
private void BreadItemClicked(Microsoft.UI.Xaml.Controls.BreadcrumbBar sender, Microsoft.UI.Xaml.Controls.BreadcrumbBarItemClickedEventArgs args)
|
||||
{
|
||||
var clickedItem = PageHistory[args.Index];
|
||||
var currentActive = PageHistory.FirstOrDefault(a => a.IsActive);
|
||||
|
||||
// Only allow navigating backwards (clicking items before current)
|
||||
if (currentActive == null || args.Index >= PageHistory.IndexOf(currentActive))
|
||||
return;
|
||||
|
||||
while (PageHistory.FirstOrDefault(a => a.IsActive) != clickedItem && WizardFrame.CanGoBack)
|
||||
{
|
||||
GoBackFrame();
|
||||
}
|
||||
BreadcrumbNavigationHelper.NavigateTo(WizardFrame, PageHistory, args.Index);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user