From e7782f28f38a21992020e735ffbdc980717ccab9 Mon Sep 17 00:00:00 2001 From: Gianni Carlo Date: Tue, 23 May 2023 07:42:28 -0500 Subject: [PATCH] Fix loading initial theme --- BookPlayer/Coordinators/MainCoordinator.swift | 3 ++- BookPlayer/Settings/Themes Screen/ThemeManager.swift | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BookPlayer/Coordinators/MainCoordinator.swift b/BookPlayer/Coordinators/MainCoordinator.swift index 6bd27c1f..7069ecec 100644 --- a/BookPlayer/Coordinators/MainCoordinator.swift +++ b/BookPlayer/Coordinators/MainCoordinator.swift @@ -63,7 +63,8 @@ class MainCoordinator: Coordinator { tabBarController.modalTransitionStyle = .crossDissolve presentingViewController = tabBarController - if let currentTheme = libraryService.getLibraryCurrentTheme() { + if var currentTheme = libraryService.getLibraryCurrentTheme() { + currentTheme.useDarkVariant = ThemeManager.shared.useDarkVariant ThemeManager.shared.currentTheme = currentTheme } diff --git a/BookPlayer/Settings/Themes Screen/ThemeManager.swift b/BookPlayer/Settings/Themes Screen/ThemeManager.swift index f945617e..0914a9b7 100644 --- a/BookPlayer/Settings/Themes Screen/ThemeManager.swift +++ b/BookPlayer/Settings/Themes Screen/ThemeManager.swift @@ -86,7 +86,10 @@ final class ThemeManager: ThemeProvider { guard let sceneDelegate = AppDelegate.shared?.activeSceneDelegate, let window = sceneDelegate.window - else { return } + else { + self.theme.value = newTheme + return + } let newTheme = SimpleTheme(with: newTheme, useDarkVariant: self.useDarkVariant) UIView.transition(with: window,