Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Fix #3936: Set the correct theme based on PBO on launch (#3937)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Jul 16, 2021
1 parent 14d980c commit 5c51171
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Client/Application/Delegates/AppDelegate.swift
Expand Up @@ -233,15 +233,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati

private var cancellables: Set<AnyCancellable> = []

private func updateTheme() {
guard let window = window,
let themeOverride = DefaultTheme(rawValue: Preferences.General.themeNormalMode.value)?.userInterfaceStyleOverride else {
return
}
private var expectedThemeOverride: UIUserInterfaceStyle {
let themeOverride = DefaultTheme(
rawValue: Preferences.General.themeNormalMode.value
)?.userInterfaceStyleOverride ?? .unspecified
let isPrivateBrowsing = PrivateBrowsingManager.shared.isPrivateBrowsing
let override: UIUserInterfaceStyle = isPrivateBrowsing ? .dark : themeOverride
return isPrivateBrowsing ? .dark : themeOverride
}

private func updateTheme() {
guard let window = window else { return }
UIView.transition(with: window, duration: 0.15, options: [.transitionCrossDissolve], animations: {
window.overrideUserInterfaceStyle = override
window.overrideUserInterfaceStyle = self.expectedThemeOverride
}, completion: nil)
}

Expand Down Expand Up @@ -288,9 +291,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati
}
.store(in: &cancellables)

if let themeOverride = DefaultTheme(rawValue: Preferences.General.themeNormalMode.value)?.userInterfaceStyleOverride {
window?.overrideUserInterfaceStyle = themeOverride
}
window?.overrideUserInterfaceStyle = expectedThemeOverride
window?.tintColor = UIColor {
if $0.userInterfaceStyle == .dark {
return .braveLighterBlurple
Expand Down

0 comments on commit 5c51171

Please sign in to comment.