Skip to content

Commit 6ce5639

Browse files
committed
Clean up
1 parent c7c262d commit 6ce5639

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

YoutubeDownloader/App.axaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@
1414
</Application.DataTemplates>
1515

1616
<Application.Styles>
17-
<!-- Hack: this brush is missing on initialization for some reason -->
18-
<Style>
19-
<Style.Resources>
20-
<ResourceDictionary>
21-
<SolidColorBrush x:Key="MaterialPaperBrush" Color="#FF303030" />
22-
</ResourceDictionary>
23-
</Style.Resources>
24-
</Style>
25-
26-
<materialStyles:MaterialThemeBase />
17+
<!-- This theme is used as a stub to pre-load default resources, the actual colors are set through code -->
18+
<materialStyles:MaterialTheme
19+
BaseTheme="Light"
20+
PrimaryColor="Grey"
21+
SecondaryColor="DeepOrange" />
2722
<materialIcons:MaterialIconStyles />
2823
<dialogHostAvalonia:DialogHostStyles />
2924

YoutubeDownloader/App.axaml.cs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,30 +105,35 @@ private void InitializeTheme()
105105
_ => PlatformSettings?.GetColorValues().ThemeVariant
106106
};
107107

108-
if (actualTheme == PlatformThemeVariant.Light)
108+
this.LocateMaterialTheme<MaterialThemeBase>().CurrentTheme = actualTheme switch
109109
{
110-
this.LocateMaterialTheme<MaterialThemeBase>().CurrentTheme = Theme.Create(
111-
Theme.Light,
112-
Color.Parse("#343838"),
113-
Color.Parse("#F9A825")
114-
);
115-
116-
Resources["SuccessBrush"] = new SolidColorBrush(Colors.DarkGreen);
117-
Resources["CanceledBrush"] = new SolidColorBrush(Colors.DarkOrange);
118-
Resources["FailedBrush"] = new SolidColorBrush(Colors.DarkRed);
119-
}
120-
else
110+
PlatformThemeVariant.Light
111+
=> Theme.Create(Theme.Light, Color.Parse("#343838"), Color.Parse("#F9A825")),
112+
PlatformThemeVariant.Dark
113+
=> Theme.Create(Theme.Dark, Color.Parse("#E8E8E8"), Color.Parse("#F9A825")),
114+
_ => throw new InvalidOperationException($"Unknown theme '{actualTheme}'.")
115+
};
116+
117+
Resources["SuccessBrush"] = actualTheme switch
118+
{
119+
PlatformThemeVariant.Light => new SolidColorBrush(Colors.DarkGreen),
120+
PlatformThemeVariant.Dark => new SolidColorBrush(Colors.LightGreen),
121+
_ => throw new InvalidOperationException($"Unknown theme '{actualTheme}'.")
122+
};
123+
124+
Resources["CanceledBrush"] = actualTheme switch
121125
{
122-
this.LocateMaterialTheme<MaterialThemeBase>().CurrentTheme = Theme.Create(
123-
Theme.Dark,
124-
Color.Parse("#E8E8E8"),
125-
Color.Parse("#F9A825")
126-
);
127-
128-
Resources["SuccessBrush"] = new SolidColorBrush(Colors.LightGreen);
129-
Resources["CanceledBrush"] = new SolidColorBrush(Colors.Orange);
130-
Resources["FailedBrush"] = new SolidColorBrush(Colors.OrangeRed);
131-
}
126+
PlatformThemeVariant.Light => new SolidColorBrush(Colors.DarkOrange),
127+
PlatformThemeVariant.Dark => new SolidColorBrush(Colors.Orange),
128+
_ => throw new InvalidOperationException($"Unknown theme '{actualTheme}'.")
129+
};
130+
131+
Resources["FailedBrush"] = actualTheme switch
132+
{
133+
PlatformThemeVariant.Light => new SolidColorBrush(Colors.DarkRed),
134+
PlatformThemeVariant.Dark => new SolidColorBrush(Colors.OrangeRed),
135+
_ => throw new InvalidOperationException($"Unknown theme '{actualTheme}'.")
136+
};
132137
}
133138

134139
public override void OnFrameworkInitializationCompleted()

0 commit comments

Comments
 (0)