Skip to content

Commit bbc7b53

Browse files
committed
Remove ThemeManager.Instance
1 parent 10d3f4a commit bbc7b53

File tree

3 files changed

+15
-28
lines changed

3 files changed

+15
-28
lines changed

Flow.Launcher.Core/Resource/ThemeManager.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Flow.Launcher/App.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
112112
HotKeyMapper.Initialize();
113113

114114
// main windows needs initialized before theme change because of blur settings
115-
// TODO: Clean ThemeManager.Instance in future
116-
ThemeManager.Instance.ChangeTheme(_settings.Theme);
115+
Ioc.Default.GetRequiredService<Theme>().ChangeTheme(_settings.Theme);
117116

118117
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
119118

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
using System.Windows.Media;
88
using System.Windows.Media.Imaging;
99
using CommunityToolkit.Mvvm.Input;
10+
using CommunityToolkit.Mvvm.DependencyInjection;
1011
using Flow.Launcher.Core.Resource;
1112
using Flow.Launcher.Helper;
1213
using Flow.Launcher.Infrastructure;
1314
using Flow.Launcher.Infrastructure.UserSettings;
1415
using Flow.Launcher.Plugin;
1516
using Flow.Launcher.ViewModel;
1617
using ModernWpf;
17-
using Flow.Launcher.Core;
18-
using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager;
1918
using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager;
2019

2120
namespace Flow.Launcher.SettingPages.ViewModels;
@@ -24,6 +23,7 @@ public partial class SettingsPaneThemeViewModel : BaseModel
2423
{
2524
private const string DefaultFont = "Segoe UI";
2625
public Settings Settings { get; }
26+
private readonly Theme _theme = Ioc.Default.GetRequiredService<Theme>();
2727

2828
public static string LinkHowToCreateTheme => @"https://flowlauncher.com/docs/#/how-to-create-a-theme";
2929
public static string LinkThemeGallery => "https://github.com/Flow-Launcher/Flow.Launcher/discussions/1438";
@@ -35,9 +35,9 @@ public Theme.ThemeData SelectedTheme
3535
set
3636
{
3737
_selectedTheme = value;
38-
ThemeManager.Instance.ChangeTheme(value.FileNameWithoutExtension);
38+
_theme.ChangeTheme(value.FileNameWithoutExtension);
3939

40-
if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect)
40+
if (_theme.BlurEnabled && Settings.UseDropShadowEffect)
4141
DropShadowEffect = false;
4242
}
4343
}
@@ -47,19 +47,19 @@ public bool DropShadowEffect
4747
get => Settings.UseDropShadowEffect;
4848
set
4949
{
50-
if (ThemeManager.Instance.BlurEnabled && value)
50+
if (_theme.BlurEnabled && value)
5151
{
5252
App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("shadowEffectNotAllowed"));
5353
return;
5454
}
5555

5656
if (value)
5757
{
58-
ThemeManager.Instance.AddDropShadowEffectToCurrentTheme();
58+
_theme.AddDropShadowEffectToCurrentTheme();
5959
}
6060
else
6161
{
62-
ThemeManager.Instance.RemoveDropShadowEffectFromCurrentTheme();
62+
_theme.RemoveDropShadowEffectFromCurrentTheme();
6363
}
6464

6565
Settings.UseDropShadowEffect = value;
@@ -97,7 +97,7 @@ public double ResultSubItemFontSize
9797
}
9898

9999
private List<Theme.ThemeData> _themes;
100-
public List<Theme.ThemeData> Themes => _themes ??= ThemeManager.Instance.LoadAvailableThemes();
100+
public List<Theme.ThemeData> Themes => _themes ??= _theme.LoadAvailableThemes();
101101

102102
public class ColorSchemeData : DropdownDataGeneric<ColorSchemes> { }
103103

@@ -300,7 +300,7 @@ public FontFamily SelectedQueryBoxFont
300300
set
301301
{
302302
Settings.QueryBoxFont = value.ToString();
303-
ThemeManager.Instance.ChangeTheme(Settings.Theme);
303+
_theme.ChangeTheme(Settings.Theme);
304304
}
305305
}
306306

@@ -322,7 +322,7 @@ public FamilyTypeface SelectedQueryBoxFontFaces
322322
Settings.QueryBoxFontStretch = value.Stretch.ToString();
323323
Settings.QueryBoxFontWeight = value.Weight.ToString();
324324
Settings.QueryBoxFontStyle = value.Style.ToString();
325-
ThemeManager.Instance.ChangeTheme(Settings.Theme);
325+
_theme.ChangeTheme(Settings.Theme);
326326
}
327327
}
328328

@@ -344,7 +344,7 @@ public FontFamily SelectedResultFont
344344
set
345345
{
346346
Settings.ResultFont = value.ToString();
347-
ThemeManager.Instance.ChangeTheme(Settings.Theme);
347+
_theme.ChangeTheme(Settings.Theme);
348348
}
349349
}
350350

@@ -366,7 +366,7 @@ public FamilyTypeface SelectedResultFontFaces
366366
Settings.ResultFontStretch = value.Stretch.ToString();
367367
Settings.ResultFontWeight = value.Weight.ToString();
368368
Settings.ResultFontStyle = value.Style.ToString();
369-
ThemeManager.Instance.ChangeTheme(Settings.Theme);
369+
_theme.ChangeTheme(Settings.Theme);
370370
}
371371
}
372372

@@ -390,7 +390,7 @@ public FontFamily SelectedResultSubFont
390390
set
391391
{
392392
Settings.ResultSubFont = value.ToString();
393-
ThemeManager.Instance.ChangeTheme(Settings.Theme);
393+
_theme.ChangeTheme(Settings.Theme);
394394
}
395395
}
396396

@@ -411,7 +411,7 @@ public FamilyTypeface SelectedResultSubFontFaces
411411
Settings.ResultSubFontStretch = value.Stretch.ToString();
412412
Settings.ResultSubFontWeight = value.Weight.ToString();
413413
Settings.ResultSubFontStyle = value.Style.ToString();
414-
ThemeManager.Instance.ChangeTheme(Settings.Theme);
414+
_theme.ChangeTheme(Settings.Theme);
415415
}
416416
}
417417

0 commit comments

Comments
 (0)