Fix theme not being applied when changed by the system (#1368)

This commit is contained in:
MBucari
2025-11-04 22:07:29 -07:00
parent 683c984246
commit ec32ff77b2

View File

@@ -230,7 +230,8 @@ namespace LibationAvalonia
private static void ShowMainWindow(IClassicDesktopStyleApplicationLifetime desktop)
{
Configuration.Instance.PropertyChanged += ThemeVariant_PropertyChanged;
OpenAndApplyTheme(Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)));
Current.ActualThemeVariantChanged += OnActualThemeVariantChanged;
OnActualThemeVariantChanged(Current, EventArgs.Empty);
var mainWindow = new MainWindow();
desktop.MainWindow = MainWindow = mainWindow;
@@ -243,6 +244,9 @@ namespace LibationAvalonia
private static void ThemeVariant_PropertyChanged(object sender, PropertyChangedEventArgsEx e)
=> OpenAndApplyTheme(e.NewValue as string);
private static void OnActualThemeVariantChanged(object? sender, EventArgs e)
=> OpenAndApplyTheme(Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)));
private static void OpenAndApplyTheme(string? themeVariant)
{
using var themePersister = ChardonnayThemePersister.Create();