From 914219324a677997d04b9bc0d40fdd44d3931549 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Fri, 17 May 2024 03:41:45 +0600 Subject: [PATCH] Re-add updating color scheme right after it changed --- .../ViewModels/SettingsPaneThemeViewModel.cs | 14 ++++++++++++++ .../SettingPages/Views/SettingsPaneTheme.xaml | 3 ++- .../SettingPages/Views/SettingsPaneTheme.xaml.cs | 8 +++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index 7cd050333..89f4fe15c 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -13,6 +13,9 @@ using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.ViewModel; +using ModernWpf; +using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager; +using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager; namespace Flow.Launcher.SettingPages.ViewModels; @@ -371,6 +374,17 @@ public partial class SettingsPaneThemeViewModel : BaseModel App.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes)); } + public void UpdateColorScheme() + { + ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = Settings.ColorScheme switch + { + Constant.Light => ApplicationTheme.Light, + Constant.Dark => ApplicationTheme.Dark, + Constant.System => null, + _ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme + }; + } + public SettingsPaneThemeViewModel(Settings settings) { Settings = settings; diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml index 097f7cea6..2dc7ffc45 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml @@ -469,7 +469,8 @@ FontSize="14" ItemsSource="{Binding ColorSchemes}" SelectedValue="{Binding Settings.ColorScheme}" - SelectedValuePath="Value" /> + SelectedValuePath="Value" + SelectionChanged="Selector_OnSelectionChanged"/> diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs index 72b2a01ca..93cf7ad18 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs @@ -1,7 +1,8 @@ using System; +using System.Windows.Controls; using System.Windows.Navigation; using Flow.Launcher.SettingPages.ViewModels; -using ModernWpf.Controls; +using Page = ModernWpf.Controls.Page; namespace Flow.Launcher.SettingPages.Views; @@ -22,4 +23,9 @@ public partial class SettingsPaneTheme : Page base.OnNavigatedTo(e); } + + private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + _viewModel.UpdateColorScheme(); + } }