Re-add updating color scheme right after it changed

This commit is contained in:
Yusyuriv 2024-05-17 03:41:45 +06:00
parent a0f4386794
commit 914219324a
No known key found for this signature in database
GPG key ID: A91C52E6F73148E0
3 changed files with 23 additions and 2 deletions

View file

@ -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;

View file

@ -469,7 +469,8 @@
FontSize="14"
ItemsSource="{Binding ColorSchemes}"
SelectedValue="{Binding Settings.ColorScheme}"
SelectedValuePath="Value" />
SelectedValuePath="Value"
SelectionChanged="Selector_OnSelectionChanged"/>
</cc:Card>
<!-- Theme folder -->

View file

@ -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();
}
}