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

Fix #3936: Set the correct theme based on PBO on launch #3937

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Client/Application/Delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
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