Fixed an issue where theme changes stopped updating nav styling
This commit is contained in:
parent
6d57523ede
commit
3a9ada581d
|
@ -497,6 +497,9 @@ final class ConversationVC: BaseVC, SessionUtilRespondingViewController, Convers
|
|||
|
||||
startObservingChanges()
|
||||
|
||||
/// If the view is removed and readded to the view hierarchy then `viewWillDisappear` will be called but `viewDidDisappear`
|
||||
/// **won't**, as a result `viewIsDisappearing` would never get set to `false` - do so here to handle this case
|
||||
viewIsDisappearing = false
|
||||
viewIsAppearing = true
|
||||
}
|
||||
|
||||
|
|
|
@ -95,11 +95,7 @@ public class TopBannerController: UIViewController {
|
|||
view.addSubview(contentStackView)
|
||||
|
||||
contentStackView.addArrangedSubview(bannerContainer)
|
||||
|
||||
child.willMove(toParent: self)
|
||||
addChild(child)
|
||||
contentStackView.addArrangedSubview(child.view)
|
||||
child.didMove(toParent: self)
|
||||
attachChild()
|
||||
|
||||
bannerContainer.addSubview(bannerLabel)
|
||||
bannerContainer.addSubview(closeButton)
|
||||
|
@ -155,6 +151,13 @@ public class TopBannerController: UIViewController {
|
|||
|
||||
// MARK: - Functions
|
||||
|
||||
public func attachChild() {
|
||||
child.willMove(toParent: self)
|
||||
addChild(child)
|
||||
contentStackView.addArrangedSubview(child.view)
|
||||
child.didMove(toParent: self)
|
||||
}
|
||||
|
||||
public static func show(warning: Warning, inWindowFor view: UIView? = nil) {
|
||||
guard Thread.isMainThread else {
|
||||
DispatchQueue.main.async {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||||
//
|
||||
// stringlint:disable
|
||||
|
||||
import UIKit
|
||||
import GRDB
|
||||
|
@ -203,7 +205,7 @@ public enum ThemeManager {
|
|||
func updateIfNeeded(viewController: UIViewController?) {
|
||||
guard let viewController: UIViewController = viewController else { return }
|
||||
guard
|
||||
let navController: UINavigationController = ((viewController as? UINavigationController) ?? viewController.navigationController),
|
||||
let navController: UINavigationController = retrieveNavigationController(from: viewController),
|
||||
let superview: UIView = navController.view.superview,
|
||||
!navController.isNavigationBarHidden
|
||||
else {
|
||||
|
@ -218,9 +220,19 @@ public enum ThemeManager {
|
|||
applyNavigationStylingIfNeeded(to: viewController)
|
||||
|
||||
// Re-attach to the UI
|
||||
navController.view.removeFromSuperview()
|
||||
superview.addSubview(navController.view)
|
||||
let wasFirstResponder: Bool = (navController.topViewController?.isFirstResponder == true)
|
||||
|
||||
switch navController.parent {
|
||||
case let topBannerController as TopBannerController:
|
||||
navController.view.removeFromSuperview()
|
||||
topBannerController.attachChild()
|
||||
|
||||
default:
|
||||
navController.view.removeFromSuperview()
|
||||
superview.addSubview(navController.view)
|
||||
}
|
||||
navController.topViewController?.setNeedsStatusBarAppearanceUpdate()
|
||||
if wasFirstResponder { navController.topViewController?.becomeFirstResponder() }
|
||||
|
||||
// Recurse through the rest of the UI
|
||||
updateIfNeeded(viewController:
|
||||
|
@ -263,6 +275,16 @@ public enum ThemeManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static func retrieveNavigationController(from viewController: UIViewController) -> UINavigationController? {
|
||||
switch viewController {
|
||||
case let navController as UINavigationController: return navController
|
||||
case let topBannerController as TopBannerController:
|
||||
return (topBannerController.children.first as? UINavigationController)
|
||||
|
||||
default: return viewController.navigationController
|
||||
}
|
||||
}
|
||||
|
||||
public static func applyWindowStyling() {
|
||||
guard Thread.isMainThread else {
|
||||
return DispatchQueue.main.async { applyWindowStyling() }
|
||||
|
|
Loading…
Reference in New Issue