mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use enum instead of constants & Use vm property
This commit is contained in:
parent
c7a2deeecd
commit
caa5a4825d
7 changed files with 23 additions and 25 deletions
|
|
@ -457,7 +457,7 @@ namespace Flow.Launcher.Core.Resource
|
|||
// ✅ 설정의 ColorScheme을 우선 사용
|
||||
int themeValue = (int)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1);
|
||||
bool isSystemDark = themeValue == 0;
|
||||
bool useDarkMode = Mode == "Dark" || (Mode == "Auto" && _settings.ColorScheme == "System" && isSystemDark) || (_settings.ColorScheme == "Dark");
|
||||
bool useDarkMode = Mode == "Dark" || (Mode == "Auto" && _settings.ColorScheme == ColorSchemes.System && isSystemDark) || (_settings.ColorScheme == ColorSchemes.Dark);
|
||||
|
||||
Color selectedBG = useDarkMode ? DarkBG : LightBG;
|
||||
ApplyPreviewBackground(selectedBG);
|
||||
|
|
|
|||
|
|
@ -40,10 +40,6 @@ namespace Flow.Launcher.Infrastructure
|
|||
|
||||
public const string DefaultTheme = "Win11Light";
|
||||
|
||||
public const string Light = "Light";
|
||||
public const string Dark = "Dark";
|
||||
public const string System = "System";
|
||||
|
||||
public const string Themes = "Themes";
|
||||
public const string Settings = "Settings";
|
||||
public const string Logs = "Logs";
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
private string _theme = Constant.DefaultTheme;
|
||||
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
|
||||
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
|
||||
public string ColorScheme { get; set; } = "System";
|
||||
public ColorSchemes ColorScheme { get; set; } = ColorSchemes.System;
|
||||
public bool ShowOpenResultHotkey { get; set; } = true;
|
||||
public double WindowSize { get; set; } = 580;
|
||||
public string PreviewHotkey { get; set; } = $"F1";
|
||||
|
|
|
|||
|
|
@ -998,11 +998,11 @@ namespace Flow.Launcher
|
|||
|
||||
public void InitializeColorScheme()
|
||||
{
|
||||
if (_settings.ColorScheme == Constant.Light)
|
||||
if (_settings.ColorScheme == ColorSchemes.Light)
|
||||
{
|
||||
ModernWpf.ThemeManager.Current.ApplicationTheme = ModernWpf.ApplicationTheme.Light;
|
||||
}
|
||||
else if (_settings.ColorScheme == Constant.Dark)
|
||||
else if (_settings.ColorScheme == ColorSchemes.Dark)
|
||||
{
|
||||
ModernWpf.ThemeManager.Current.ApplicationTheme = ModernWpf.ApplicationTheme.Dark;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ using Flow.Launcher.ViewModel;
|
|||
using ModernWpf;
|
||||
using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager;
|
||||
using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager;
|
||||
using static Flow.Launcher.Core.Resource.Theme;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace Flow.Launcher.SettingPages.ViewModels;
|
||||
|
||||
|
|
@ -38,8 +36,11 @@ public partial class SettingsPaneThemeViewModel : BaseModel
|
|||
ThemeManager.Instance.ChangeTheme(value.FileNameWithoutExtension);
|
||||
|
||||
if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect == false)
|
||||
{
|
||||
DropShadowEffect = true;
|
||||
OnPropertyChanged(nameof(IsDropShadowEnabled));
|
||||
}
|
||||
|
||||
ThemeManager.Instance.RefreshFrame();
|
||||
//ThemeManager.Instance.SetBlurForWindow();
|
||||
}
|
||||
|
|
@ -107,6 +108,16 @@ public partial class SettingsPaneThemeViewModel : BaseModel
|
|||
public class ColorSchemeData : DropdownDataGeneric<ColorSchemes> { }
|
||||
|
||||
public List<ColorSchemeData> ColorSchemes { get; } = DropdownDataGeneric<ColorSchemes>.GetValues<ColorSchemeData>("ColorScheme");
|
||||
public ColorSchemes ColorScheme
|
||||
{
|
||||
get => Settings.ColorScheme;
|
||||
set
|
||||
{
|
||||
UpdateColorScheme();
|
||||
|
||||
Settings.ColorScheme = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> TimeFormatList { get; } = new()
|
||||
{
|
||||
|
|
@ -463,13 +474,13 @@ public partial class SettingsPaneThemeViewModel : BaseModel
|
|||
App.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
|
||||
}
|
||||
|
||||
public void UpdateColorScheme()
|
||||
private void UpdateColorScheme()
|
||||
{
|
||||
ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = Settings.ColorScheme switch
|
||||
{
|
||||
Constant.Light => ApplicationTheme.Light,
|
||||
Constant.Dark => ApplicationTheme.Dark,
|
||||
Constant.System => null,
|
||||
Infrastructure.UserSettings.ColorSchemes.Light => ApplicationTheme.Light,
|
||||
Infrastructure.UserSettings.ColorSchemes.Dark => ApplicationTheme.Dark,
|
||||
Infrastructure.UserSettings.ColorSchemes.System => null,
|
||||
_ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme
|
||||
};
|
||||
ThemeManager.Instance.RefreshFrame();
|
||||
|
|
|
|||
|
|
@ -688,9 +688,8 @@
|
|||
DisplayMemberPath="Display"
|
||||
FontSize="14"
|
||||
ItemsSource="{Binding ColorSchemes}"
|
||||
SelectedValue="{Binding Settings.ColorScheme}"
|
||||
SelectedValuePath="Value"
|
||||
SelectionChanged="Selector_OnSelectionChanged" />
|
||||
SelectedValue="{Binding ColorScheme, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
</cc:Card>
|
||||
|
||||
<!-- Theme folder -->
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Navigation;
|
||||
using Flow.Launcher.SettingPages.ViewModels;
|
||||
using Page = ModernWpf.Controls.Page;
|
||||
|
|
@ -25,9 +22,4 @@ public partial class SettingsPaneTheme : Page
|
|||
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
_viewModel.UpdateColorScheme();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue