Skip to content

Commit 36e15d3

Browse files
committed
Refactor: move CopyStyle to ThemeHelper class
Moved the CopyStyle method from Theme to a new static ThemeHelper class for better code organization and reusability. Updated all references in Theme to use ThemeHelper.CopyStyle. Added ThemeHelper.cs and necessary using directives.
1 parent ed14c45 commit 36e15d3

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ private void ApplyPreviewBackground(Color? bgColor = null)
798798
Application.Current.Resources["WindowBorderStyle"] is Style originalStyle)
799799
{
800800
// Copy the original style, including the base style if it exists
801-
CopyStyle(originalStyle, previewStyle);
801+
ThemeHelper.CopyStyle(originalStyle, previewStyle);
802802
}
803803

804804
// Apply background color (remove transparency in color)
@@ -817,21 +817,6 @@ private void ApplyPreviewBackground(Color? bgColor = null)
817817
Application.Current.Resources["PreviewWindowBorderStyle"] = previewStyle;
818818
}
819819

820-
private void CopyStyle(Style originalStyle, Style targetStyle)
821-
{
822-
// If the style is based on another style, copy the base style first
823-
if (originalStyle.BasedOn != null)
824-
{
825-
CopyStyle(originalStyle.BasedOn, targetStyle);
826-
}
827-
828-
// Copy the setters from the original style
829-
foreach (var setter in originalStyle.Setters.OfType<Setter>())
830-
{
831-
targetStyle.Setters.Add(new Setter(setter.Property, setter.Value));
832-
}
833-
}
834-
835820
private void ColorizeWindow(string theme, BackdropTypes backdropType)
836821
{
837822
var dict = GetThemeResourceDictionary(theme);

Flow.Launcher.Core/Resource/ThemeHelper.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1-
using System.Windows.Media;
1+
using System.Linq;
2+
using System.Windows;
3+
using System.Windows.Media;
24

35
namespace Flow.Launcher.Core.Resource;
46

57
public static class ThemeHelper
68
{
9+
public static void CopyStyle(Style originalStyle, Style targetStyle)
10+
{
11+
// If the style is based on another style, copy the base style first
12+
if (originalStyle.BasedOn != null)
13+
{
14+
CopyStyle(originalStyle.BasedOn, targetStyle);
15+
}
16+
17+
// Copy the setters from the original style
18+
foreach (var setter in originalStyle.Setters.OfType<Setter>())
19+
{
20+
targetStyle.Setters.Add(new Setter(setter.Property, setter.Value));
21+
}
22+
}
23+
724
public static SolidColorBrush GetFreezeSolidColorBrush(Color color)
825
{
926
var brush = new SolidColorBrush(color);

0 commit comments

Comments
 (0)