From 0bdcda1b2354da91c44c3cd0895282b337889c05 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 6 Jan 2021 19:20:14 -0500 Subject: [PATCH] Fix secondary windows not respecting theme preference --- Tusker/AuxiliarySceneDelegate.swift | 7 +++++++ Tusker/ComposeSceneDelegate.swift | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Tusker/AuxiliarySceneDelegate.swift b/Tusker/AuxiliarySceneDelegate.swift index 32ba48df..25df2b65 100644 --- a/Tusker/AuxiliarySceneDelegate.swift +++ b/Tusker/AuxiliarySceneDelegate.swift @@ -56,6 +56,9 @@ class AuxiliarySceneDelegate: UIResponder, UIWindowSceneDelegate { window = UIWindow(windowScene: windowScene) window!.rootViewController = nav window!.makeKeyAndVisible() + + NotificationCenter.default.addObserver(self, selector: #selector(themePrefChanged), name: .themePreferenceChanged, object: nil) + themePrefChanged() } func sceneWillResignActive(_ scene: UIScene) { @@ -109,4 +112,8 @@ class AuxiliarySceneDelegate: UIResponder, UIWindowSceneDelegate { @objc private func close() { closeWindow() } + + @objc private func themePrefChanged() { + window?.overrideUserInterfaceStyle = Preferences.shared.theme + } } diff --git a/Tusker/ComposeSceneDelegate.swift b/Tusker/ComposeSceneDelegate.swift index f85eb632..3b20561f 100644 --- a/Tusker/ComposeSceneDelegate.swift +++ b/Tusker/ComposeSceneDelegate.swift @@ -42,6 +42,9 @@ class ComposeSceneDelegate: UIResponder, UIWindowSceneDelegate { window = UIWindow(windowScene: windowScene) window!.rootViewController = nav window!.makeKeyAndVisible() + + NotificationCenter.default.addObserver(self, selector: #selector(themePrefChanged), name: .themePreferenceChanged, object: nil) + themePrefChanged() } func sceneWillResignActive(_ scene: UIScene) { @@ -58,6 +61,10 @@ class ComposeSceneDelegate: UIResponder, UIWindowSceneDelegate { return scene.userActivity } + @objc private func themePrefChanged() { + window?.overrideUserInterfaceStyle = Preferences.shared.theme + } + } extension ComposeSceneDelegate: ComposeHostingControllerDelegate {