diff --git a/Source/LibationAvalonia/App.axaml.cs b/Source/LibationAvalonia/App.axaml.cs index 8093b885..59fe3f75 100644 --- a/Source/LibationAvalonia/App.axaml.cs +++ b/Source/LibationAvalonia/App.axaml.cs @@ -90,14 +90,10 @@ private async void Setup_Closing(object sender, System.ComponentModel.CancelEven if (setupDialog.Config.LibationSettingsAreValid) { - var theme - = setupDialog.SelectedTheme.Content is nameof(ThemeVariant.Dark) - ? nameof(ThemeVariant.Dark) - : nameof(ThemeVariant.Light); - + string theme = setupDialog.SelectedTheme.Content as string; + setupDialog.Config.SetString(theme, nameof(ThemeVariant)); - await RunMigrationsAsync(setupDialog.Config); LibraryTask = Task.Run(() => DbContexts.GetLibrary_Flat_NoTracking(includeParents: true)); AudibleUtilities.AudibleApiStorage.EnsureAccountsSettingsFileExists(); @@ -208,9 +204,15 @@ static async Task CancelInstallation() private static void ShowMainWindow(IClassicDesktopStyleApplicationLifetime desktop) { - Current.RequestedThemeVariant = Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)) is "Dark" ? ThemeVariant.Dark : ThemeVariant.Light; - - //Reload colors for current theme + Current.RequestedThemeVariant = Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)) switch + { + nameof(ThemeVariant.Dark) => ThemeVariant.Dark, + nameof(ThemeVariant.Light) => ThemeVariant.Light, + // "System" + _ => ThemeVariant.Default + }; + + //Reload colors for current theme LoadStyles(); var mainWindow = new MainWindow(); desktop.MainWindow = MainWindow = mainWindow; diff --git a/Source/LibationAvalonia/Dialogs/SetupDialog.axaml b/Source/LibationAvalonia/Dialogs/SetupDialog.axaml index 2a246e89..7f3f81f0 100644 --- a/Source/LibationAvalonia/Dialogs/SetupDialog.axaml +++ b/Source/LibationAvalonia/Dialogs/SetupDialog.axaml @@ -2,12 +2,14 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:dialogs="clr-namespace:LibationAvalonia.Dialogs" mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="350" x:Class="LibationAvalonia.Dialogs.SetupDialog" WindowStartupLocation="CenterScreen" Width="500" Height="350" Icon="/Assets/libation.ico" - Title="Welcome to Libation"> + Title="Welcome to Libation" + x:DataType="dialogs:SetupDialog"> + diff --git a/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs b/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs index 87d00bd6..c164b449 100644 --- a/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs +++ b/Source/LibationAvalonia/ViewModels/Settings/ImportantSettingsVM.cs @@ -31,10 +31,10 @@ public void LoadSettings(Configuration config) LoggingLevel = config.LogLevel; GridScaleFactor = scaleFactorToLinearRange(config.GridScaleFactor); GridFontScaleFactor = scaleFactorToLinearRange(config.GridFontScaleFactor); - ThemeVariant = initialThemeVariant - = Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)) is nameof(Avalonia.Styling.ThemeVariant.Dark) - ? nameof(Avalonia.Styling.ThemeVariant.Dark) - : nameof(Avalonia.Styling.ThemeVariant.Light); + + ThemeVariant = initialThemeVariant = Configuration.Instance.GetString(propertyName: nameof(ThemeVariant)); + if (string.IsNullOrWhiteSpace(initialThemeVariant)) + ThemeVariant = initialThemeVariant = "System"; } public void SaveSettings(Configuration config) @@ -83,7 +83,7 @@ public void ApplyDisplaySettings() public string GridScaleFactorText { get; } = Configuration.GetDescription(nameof(Configuration.GridScaleFactor)); public string GridFontScaleFactorText { get; } = Configuration.GetDescription(nameof(Configuration.GridFontScaleFactor)); public string BetaOptInText { get; } = Configuration.GetDescription(nameof(Configuration.BetaOptIn)); - public string[] Themes { get; } = { nameof(Avalonia.Styling.ThemeVariant.Light), nameof(Avalonia.Styling.ThemeVariant.Dark) }; + public string[] Themes { get; } = { "System", nameof(Avalonia.Styling.ThemeVariant.Light), nameof(Avalonia.Styling.ThemeVariant.Dark) }; public string BooksDirectory { get; set; } public bool SavePodcastsToParentFolder { get; set; }