Skip to content

Commit 887be64

Browse files
committed
Merge branch '250223FluentTest2' of https://github.com/onesounds/Flow.Launcher into 250223FluentTest2
2 parents 57d206f + c17dcad commit 887be64

File tree

3 files changed

+29
-35
lines changed

3 files changed

+29
-35
lines changed

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
using ModernWpf;
1616
using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager;
1717
using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager;
18-
using static Flow.Launcher.Core.Resource.Theme;
19-
using System.Windows.Interop;
2018

2119
namespace Flow.Launcher.SettingPages.ViewModels;
2220

@@ -38,8 +36,11 @@ public Theme.ThemeData SelectedTheme
3836
ThemeManager.Instance.ChangeTheme(value.FileNameWithoutExtension);
3937

4038
if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect == false)
39+
{
4140
DropShadowEffect = true;
4241
OnPropertyChanged(nameof(IsDropShadowEnabled));
42+
}
43+
4344
ThemeManager.Instance.RefreshFrame();
4445
//ThemeManager.Instance.SetBlurForWindow();
4546
}
@@ -107,6 +108,24 @@ public double ResultSubItemFontSize
107108
public class ColorSchemeData : DropdownDataGeneric<ColorSchemes> { }
108109

109110
public List<ColorSchemeData> ColorSchemes { get; } = DropdownDataGeneric<ColorSchemes>.GetValues<ColorSchemeData>("ColorScheme");
111+
public string ColorScheme
112+
{
113+
get => Settings.ColorScheme;
114+
set
115+
{
116+
ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = value switch
117+
{
118+
Constant.Light => ApplicationTheme.Light,
119+
Constant.Dark => ApplicationTheme.Dark,
120+
Constant.System => null,
121+
_ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme
122+
};
123+
124+
ThemeManager.Instance.RefreshFrame();
125+
126+
Settings.ColorScheme = value;
127+
}
128+
}
110129

111130
public List<string> TimeFormatList { get; } = new()
112131
{
@@ -209,9 +228,8 @@ public void ApplyBackdrop()
209228
public BackdropTypes BackdropType
210229
{
211230
get => Enum.IsDefined(typeof(BackdropTypes), Settings.BackdropType)
212-
? (BackdropTypes)Settings.BackdropType
231+
? Settings.BackdropType
213232
: BackdropTypes.None;
214-
215233
set
216234
{
217235
if (!Enum.IsDefined(typeof(BackdropTypes), value))
@@ -230,9 +248,6 @@ public BackdropTypes BackdropType
230248
}
231249
}
232250

233-
234-
235-
236251
public bool UseSound
237252
{
238253
get => Settings.UseSound;
@@ -457,27 +472,15 @@ public FamilyTypeface SelectedResultSubFontFaces
457472

458473
public string ThemeImage => Constant.QueryTextBoxIconImagePath;
459474

460-
[RelayCommand]
461-
private void OpenThemesFolder()
462-
{
463-
App.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
464-
}
465-
466-
public void UpdateColorScheme()
475+
public SettingsPaneThemeViewModel(Settings settings)
467476
{
468-
ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme = Settings.ColorScheme switch
469-
{
470-
Constant.Light => ApplicationTheme.Light,
471-
Constant.Dark => ApplicationTheme.Dark,
472-
Constant.System => null,
473-
_ => ThemeManagerForColorSchemeSwitch.Current.ApplicationTheme
474-
};
475-
ThemeManager.Instance.RefreshFrame();
477+
Settings = settings;
476478
}
477479

478-
public SettingsPaneThemeViewModel(Settings settings)
480+
[RelayCommand]
481+
private void OpenThemesFolder()
479482
{
480-
Settings = settings;
483+
App.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
481484
}
482485

483486
[RelayCommand]

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,8 @@
688688
DisplayMemberPath="Display"
689689
FontSize="14"
690690
ItemsSource="{Binding ColorSchemes}"
691-
SelectedValue="{Binding Settings.ColorScheme}"
692-
SelectedValuePath="Value"
693-
SelectionChanged="Selector_OnSelectionChanged" />
691+
SelectedValue="{Binding ColorScheme, Mode=TwoWay}"
692+
SelectedValuePath="Value" />
694693
</cc:Card>
695694

696695
<!-- Theme folder -->

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
using System;
2-
using System.Windows;
3-
using System.Windows.Controls;
4-
using System.Windows.Media;
52
using System.Windows.Navigation;
63
using Flow.Launcher.SettingPages.ViewModels;
74
using Page = ModernWpf.Controls.Page;
@@ -25,9 +22,4 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
2522

2623
base.OnNavigatedTo(e);
2724
}
28-
29-
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
30-
{
31-
_viewModel.UpdateColorScheme();
32-
}
3325
}

0 commit comments

Comments
 (0)