From e1994de36119e253cdf77a050b89206f4f317ada Mon Sep 17 00:00:00 2001 From: U+5BFA <62196528+onein528@users.noreply.github.com> Date: Sat, 11 Mar 2023 01:06:17 +0900 Subject: [PATCH] Feature: Introduce NavigationViewItemButtonStyle to Settings dialog (#11584) --- src/Files.App/App.xaml | 3 - src/Files.App/Dialogs/SettingsDialog.xaml | 230 +++---- src/Files.App/Dialogs/SettingsDialog.xaml.cs | 25 +- .../NavigationViewItemButtonStyle.xaml | 571 ++++++++++++++++++ src/Files.App/Views/Settings/AboutPage.xaml | 21 +- .../Views/Settings/AboutPage.xaml.cs | 10 +- .../Views/Settings/AdvancedPage.xaml | 10 +- .../Views/Settings/AdvancedPage.xaml.cs | 2 +- .../Views/Settings/AppearancePage.xaml | 14 +- .../Views/Settings/AppearancePage.xaml.cs | 2 +- src/Files.App/Views/Settings/FoldersPage.xaml | 15 +- .../Views/Settings/FoldersPage.xaml.cs | 2 +- .../Views/Settings/PreferencesPage.xaml | 23 +- .../Views/Settings/PreferencesPage.xaml.cs | 2 +- src/Files.App/Views/Settings/TagsPage.xaml | 8 +- src/Files.App/Views/Settings/TagsPage.xaml.cs | 2 +- 16 files changed, 750 insertions(+), 190 deletions(-) create mode 100644 src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml diff --git a/src/Files.App/App.xaml b/src/Files.App/App.xaml index aa09f953674a..aa4e10a5ea79 100644 --- a/src/Files.App/App.xaml +++ b/src/Files.App/App.xaml @@ -44,7 +44,6 @@ - @@ -56,7 +55,6 @@ - @@ -68,7 +66,6 @@ - diff --git a/src/Files.App/Dialogs/SettingsDialog.xaml b/src/Files.App/Dialogs/SettingsDialog.xaml index 3096aabfa0a8..d310c194b0e3 100644 --- a/src/Files.App/Dialogs/SettingsDialog.xaml +++ b/src/Files.App/Dialogs/SettingsDialog.xaml @@ -6,133 +6,135 @@ xmlns:helpers="using:Files.App.Helpers" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Closing="ContentDialog_Closing" + DataContext="{x:Bind ViewModel, Mode=OneWay}" RequestedTheme="{x:Bind RootAppElement.RequestedTheme, Mode=OneWay}" Style="{StaticResource DefaultContentDialogStyle}" mc:Ignorable="d"> + + + + + 1100 0 - - - - - - + + + + + - - + + + - - + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + diff --git a/src/Files.App/Dialogs/SettingsDialog.xaml.cs b/src/Files.App/Dialogs/SettingsDialog.xaml.cs index e8f641b0fe8c..e21bee35cae9 100644 --- a/src/Files.App/Dialogs/SettingsDialog.xaml.cs +++ b/src/Files.App/Dialogs/SettingsDialog.xaml.cs @@ -1,4 +1,4 @@ -using Files.App.Settings; +using Files.App.Views.Settings; using Files.Backend.ViewModels.Dialogs; using Files.Shared.Enums; using Microsoft.UI.Xaml; @@ -10,24 +10,21 @@ namespace Files.App.Dialogs { public sealed partial class SettingsDialog : ContentDialog, IDialog { - public SettingsDialogViewModel ViewModel - { - get => (SettingsDialogViewModel)DataContext; - set => DataContext = value; - } + public SettingsDialogViewModel ViewModel { get; set; } - // for some reason the requested theme wasn't being set on the content dialog, so this is used to manually bind to the requested app theme - private FrameworkElement RootAppElement => App.Window.Content as FrameworkElement; + private FrameworkElement RootAppElement + => (FrameworkElement)App.Window.Content; public SettingsDialog() { InitializeComponent(); - SettingsPane.SelectedItem = SettingsPane.MenuItems[0]; + App.Window.SizeChanged += Current_SizeChanged; UpdateDialogLayout(); } - public new async Task ShowAsync() => (DialogResult)await base.ShowAsync(); + public new async Task ShowAsync() + => (DialogResult)await base.ShowAsync(); private void Current_SizeChanged(object sender, WindowSizeChangedEventArgs e) { @@ -38,10 +35,10 @@ private void UpdateDialogLayout() { ContainerGrid.Height = App.Window.Bounds.Height <= 760 ? App.Window.Bounds.Height - 70 : 690; ContainerGrid.Width = App.Window.Bounds.Width <= 1100 ? App.Window.Bounds.Width : 1100; - SettingsPane.PaneDisplayMode = App.Window.Bounds.Width < 700 ? NavigationViewPaneDisplayMode.LeftCompact : NavigationViewPaneDisplayMode.Left; + MainSettingsNavigationView.PaneDisplayMode = App.Window.Bounds.Width < 700 ? NavigationViewPaneDisplayMode.LeftCompact : NavigationViewPaneDisplayMode.Left; } - private void SettingsPane_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) + private void MainSettingsNavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) { var selectedItem = (NavigationViewItem)args.SelectedItem; int selectedItemTag = Convert.ToInt32(selectedItem.Tag); @@ -63,9 +60,9 @@ private void ContentDialog_Closing(ContentDialog sender, ContentDialogClosingEve App.Window.SizeChanged -= Current_SizeChanged; } - private void ButtonClose_Click(object sender, RoutedEventArgs e) + private void CloseSettingsDialogButton_Click(object sender, RoutedEventArgs e) { Hide(); } } -} \ No newline at end of file +} diff --git a/src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml b/src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml new file mode 100644 index 000000000000..ee3478425227 --- /dev/null +++ b/src/Files.App/ResourceDictionaries/NavigationViewItemButtonStyle.xaml @@ -0,0 +1,571 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1,1,1,1 + 40 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Files.App/Views/Settings/AboutPage.xaml b/src/Files.App/Views/Settings/AboutPage.xaml index 9fcd0ecde2c9..f264f2cd0b4b 100644 --- a/src/Files.App/Views/Settings/AboutPage.xaml +++ b/src/Files.App/Views/Settings/AboutPage.xaml @@ -1,16 +1,19 @@ + + + + - - + + LinkClicked="MarkdownTextBlock_LinkClicked" + Text="{x:Bind ViewModel.ThirdPartyNotices, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> diff --git a/src/Files.App/Views/Settings/AboutPage.xaml.cs b/src/Files.App/Views/Settings/AboutPage.xaml.cs index 382496e5fc59..48d9249b7629 100644 --- a/src/Files.App/Views/Settings/AboutPage.xaml.cs +++ b/src/Files.App/Views/Settings/AboutPage.xaml.cs @@ -4,21 +4,13 @@ using System; using Windows.System; -namespace Files.App.Settings +namespace Files.App.Views.Settings { public sealed partial class AboutPage : Page { - public AboutViewModel ViewModel - { - get => (AboutViewModel)DataContext; - set => DataContext = value; - } - public AboutPage() { InitializeComponent(); - - ViewModel = new AboutViewModel(); } private void ThirdPartyLicenses_Click(object sender, bool e) diff --git a/src/Files.App/Views/Settings/AdvancedPage.xaml b/src/Files.App/Views/Settings/AdvancedPage.xaml index 92fa8ab51cea..2780abba6904 100644 --- a/src/Files.App/Views/Settings/AdvancedPage.xaml +++ b/src/Files.App/Views/Settings/AdvancedPage.xaml @@ -1,5 +1,5 @@  + + - + @@ -129,4 +131,4 @@ - \ No newline at end of file + diff --git a/src/Files.App/Views/Settings/AdvancedPage.xaml.cs b/src/Files.App/Views/Settings/AdvancedPage.xaml.cs index 852304600c3f..fa5fbade284f 100644 --- a/src/Files.App/Views/Settings/AdvancedPage.xaml.cs +++ b/src/Files.App/Views/Settings/AdvancedPage.xaml.cs @@ -1,6 +1,6 @@ using Microsoft.UI.Xaml.Controls; -namespace Files.App.Settings +namespace Files.App.Views.Settings { public sealed partial class AdvancedPage : Page { diff --git a/src/Files.App/Views/Settings/AppearancePage.xaml b/src/Files.App/Views/Settings/AppearancePage.xaml index c414d52161c7..6d8ff05c553c 100644 --- a/src/Files.App/Views/Settings/AppearancePage.xaml +++ b/src/Files.App/Views/Settings/AppearancePage.xaml @@ -1,17 +1,18 @@  + @@ -82,8 +83,9 @@ + - + @@ -139,7 +141,7 @@ - @@ -168,4 +170,4 @@ - \ No newline at end of file + diff --git a/src/Files.App/Views/Settings/AppearancePage.xaml.cs b/src/Files.App/Views/Settings/AppearancePage.xaml.cs index 9d938be964e0..b1d51cfdb3b4 100644 --- a/src/Files.App/Views/Settings/AppearancePage.xaml.cs +++ b/src/Files.App/Views/Settings/AppearancePage.xaml.cs @@ -1,6 +1,6 @@ using Microsoft.UI.Xaml.Controls; -namespace Files.App.Settings +namespace Files.App.Views.Settings { public sealed partial class AppearancePage : Page { diff --git a/src/Files.App/Views/Settings/FoldersPage.xaml b/src/Files.App/Views/Settings/FoldersPage.xaml index d5beeaaf4da2..d8f89ecffe5e 100644 --- a/src/Files.App/Views/Settings/FoldersPage.xaml +++ b/src/Files.App/Views/Settings/FoldersPage.xaml @@ -1,25 +1,20 @@  + + - + diff --git a/src/Files.App/Views/Settings/FoldersPage.xaml.cs b/src/Files.App/Views/Settings/FoldersPage.xaml.cs index b8f9f9027ef9..f52001854f17 100644 --- a/src/Files.App/Views/Settings/FoldersPage.xaml.cs +++ b/src/Files.App/Views/Settings/FoldersPage.xaml.cs @@ -1,6 +1,6 @@ using Microsoft.UI.Xaml.Controls; -namespace Files.App.Settings +namespace Files.App.Views.Settings { public sealed partial class FoldersPage : Page { diff --git a/src/Files.App/Views/Settings/PreferencesPage.xaml b/src/Files.App/Views/Settings/PreferencesPage.xaml index 0e7bd0f0e17c..99ff743ca45e 100644 --- a/src/Files.App/Views/Settings/PreferencesPage.xaml +++ b/src/Files.App/Views/Settings/PreferencesPage.xaml @@ -1,25 +1,23 @@  + + - + @@ -33,7 +31,6 @@ - @@ -45,7 +42,7 @@ ItemsSource="{x:Bind ViewModel.AppLanguages}" SelectedIndex="{x:Bind ViewModel.SelectedAppLanguageIndex, Mode=TwoWay}"> - + @@ -68,7 +65,7 @@ ItemsSource="{x:Bind ViewModel.DateFormats}" SelectedIndex="{x:Bind ViewModel.SelectedDateTimeFormatIndex, Mode=TwoWay}"> - + - - \ No newline at end of file + diff --git a/src/Files.App/Views/Settings/PreferencesPage.xaml.cs b/src/Files.App/Views/Settings/PreferencesPage.xaml.cs index 1df7d3b642aa..01d02394e910 100644 --- a/src/Files.App/Views/Settings/PreferencesPage.xaml.cs +++ b/src/Files.App/Views/Settings/PreferencesPage.xaml.cs @@ -1,6 +1,6 @@ using Microsoft.UI.Xaml.Controls; -namespace Files.App.Settings +namespace Files.App.Views.Settings { public sealed partial class PreferencesPage : Page { diff --git a/src/Files.App/Views/Settings/TagsPage.xaml b/src/Files.App/Views/Settings/TagsPage.xaml index 31567920b8fe..e489ec21dbc1 100644 --- a/src/Files.App/Views/Settings/TagsPage.xaml +++ b/src/Files.App/Views/Settings/TagsPage.xaml @@ -1,5 +1,5 @@  + + - + diff --git a/src/Files.App/Views/Settings/TagsPage.xaml.cs b/src/Files.App/Views/Settings/TagsPage.xaml.cs index bcbf40c9de4b..0a5d5e99c1fc 100644 --- a/src/Files.App/Views/Settings/TagsPage.xaml.cs +++ b/src/Files.App/Views/Settings/TagsPage.xaml.cs @@ -7,7 +7,7 @@ using System.Linq; using Windows.System; -namespace Files.App.Settings +namespace Files.App.Views.Settings { public sealed partial class TagsPage : Page {