diff --git a/HellionChat/Themes/ThemeRegistry.cs b/HellionChat/Themes/ThemeRegistry.cs new file mode 100644 index 0000000..efb1768 --- /dev/null +++ b/HellionChat/Themes/ThemeRegistry.cs @@ -0,0 +1,42 @@ +using HellionChat.Themes.Builtin; + +namespace HellionChat.Themes; + +public sealed class ThemeRegistry +{ + public const string DefaultSlug = HellionArctic.Slug; + + private readonly Dictionary _builtIns; + private Theme _active; + + public ThemeRegistry() + { + _builtIns = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + { HellionArctic.Slug, HellionArctic.Build() }, + { Chat2Classic.Slug, Chat2Classic.Build() }, + { EventHorizon.Slug, EventHorizon.Build() }, + { MoonlitBloom.Slug, MoonlitBloom.Build() }, + { MintGrove.Slug, MintGrove.Build() }, + }; + _active = _builtIns[DefaultSlug]; + } + + public Theme Active => _active; + + // Active-Lookup: liefert das angeforderte Theme oder fällt auf Hellion Arctic + // zurück, wenn der Slug unbekannt ist. + public Theme Get(string slug) + { + return _builtIns.TryGetValue(slug, out var theme) + ? theme + : _builtIns[DefaultSlug]; + } + + public IEnumerable AllBuiltIns() => _builtIns.Values; + + public void Switch(string slug) + { + _active = Get(slug); + } +}