From aa46a2002d14399acc644edfd3117f787914504d Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 4 Oct 2022 15:54:57 +0100 Subject: [PATCH] Fix navigation bars inside of VectorHostingController. --- CHANGES.md | 1 + .../Common/SwiftUI/VectorHostingController.swift | 16 ++++++++-------- .../Coordinator/AnalyticsPromptCoordinator.swift | 3 ++- .../OnboardingCelebrationCoordinator.swift | 1 + .../OnboardingCongratulationsCoordinator.swift | 1 + .../OnboardingSplashScreenCoordinator.swift | 1 + 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 427842bc0b..7091d0f365 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ - Fix crash when scrolling chat list ([#6749](https://github.com/vector-im/element-ios/issues/6749)) - App Layout: Unable to send message after filtering for room ([#6755](https://github.com/vector-im/element-ios/issues/6755)) - Fix code block background colour ([#6778](https://github.com/vector-im/element-ios/issues/6778)) +- Fix navigation bars visibility on iOS 16. ([#6799](https://github.com/vector-im/element-ios/pull/6799)) 🧱 Build diff --git a/Riot/Modules/Common/SwiftUI/VectorHostingController.swift b/Riot/Modules/Common/SwiftUI/VectorHostingController.swift index 9b6860fb7c..98faba5c03 100644 --- a/Riot/Modules/Common/SwiftUI/VectorHostingController.swift +++ b/Riot/Modules/Common/SwiftUI/VectorHostingController.swift @@ -73,14 +73,6 @@ class VectorHostingController: UIHostingController { bottomSheetPreferences?.setup(viewController: self) } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - - if isNavigationBarHidden { - self.navigationController?.isNavigationBarHidden = true - } - } - override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) @@ -93,6 +85,14 @@ class VectorHostingController: UIHostingController { } } + override func viewWillLayoutSubviews() { + super.viewWillLayoutSubviews() + + if let navigationController = navigationController, navigationController.isNavigationBarHidden != isNavigationBarHidden { + navigationController.isNavigationBarHidden = isNavigationBarHidden + } + } + override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() diff --git a/RiotSwiftUI/Modules/AnalyticsPrompt/Coordinator/AnalyticsPromptCoordinator.swift b/RiotSwiftUI/Modules/AnalyticsPrompt/Coordinator/AnalyticsPromptCoordinator.swift index fb79b8df8e..b4d9daf800 100644 --- a/RiotSwiftUI/Modules/AnalyticsPrompt/Coordinator/AnalyticsPromptCoordinator.swift +++ b/RiotSwiftUI/Modules/AnalyticsPrompt/Coordinator/AnalyticsPromptCoordinator.swift @@ -27,7 +27,7 @@ final class AnalyticsPromptCoordinator: Coordinator, Presentable { // MARK: Private private let parameters: AnalyticsPromptCoordinatorParameters - private let analyticsPromptHostingController: UIViewController + private let analyticsPromptHostingController: VectorHostingController private var _analyticsPromptViewModel: Any? fileprivate var analyticsPromptViewModel: AnalyticsPromptViewModel { @@ -59,6 +59,7 @@ final class AnalyticsPromptCoordinator: Coordinator, Presentable { let view = AnalyticsPrompt(viewModel: viewModel.context) _analyticsPromptViewModel = viewModel analyticsPromptHostingController = VectorHostingController(rootView: view) + analyticsPromptHostingController.isNavigationBarHidden = true } // MARK: - Public diff --git a/RiotSwiftUI/Modules/Onboarding/Celebration/Coordinator/OnboardingCelebrationCoordinator.swift b/RiotSwiftUI/Modules/Onboarding/Celebration/Coordinator/OnboardingCelebrationCoordinator.swift index 9f0ea9273f..9db9439dfb 100644 --- a/RiotSwiftUI/Modules/Onboarding/Celebration/Coordinator/OnboardingCelebrationCoordinator.swift +++ b/RiotSwiftUI/Modules/Onboarding/Celebration/Coordinator/OnboardingCelebrationCoordinator.swift @@ -45,6 +45,7 @@ final class OnboardingCelebrationCoordinator: Coordinator, Presentable { onboardingCelebrationViewModel = viewModel onboardingCelebrationHostingController = VectorHostingController(rootView: view) onboardingCelebrationHostingController.enableNavigationBarScrollEdgeAppearance = true + onboardingCelebrationHostingController.isNavigationBarHidden = true } // MARK: - Public diff --git a/RiotSwiftUI/Modules/Onboarding/Congratulations/Coordinator/OnboardingCongratulationsCoordinator.swift b/RiotSwiftUI/Modules/Onboarding/Congratulations/Coordinator/OnboardingCongratulationsCoordinator.swift index 57cd09d5cb..d2f23340ea 100644 --- a/RiotSwiftUI/Modules/Onboarding/Congratulations/Coordinator/OnboardingCongratulationsCoordinator.swift +++ b/RiotSwiftUI/Modules/Onboarding/Congratulations/Coordinator/OnboardingCongratulationsCoordinator.swift @@ -58,6 +58,7 @@ final class OnboardingCongratulationsCoordinator: Coordinator, Presentable { onboardingCongratulationsViewModel = viewModel onboardingCongratulationsHostingController = VectorHostingController(rootView: view) onboardingCongratulationsHostingController.statusBarStyle = .lightContent + onboardingCongratulationsHostingController.isNavigationBarHidden = true } // MARK: - Public diff --git a/RiotSwiftUI/Modules/Onboarding/SplashScreen/Coordinator/OnboardingSplashScreenCoordinator.swift b/RiotSwiftUI/Modules/Onboarding/SplashScreen/Coordinator/OnboardingSplashScreenCoordinator.swift index 27c4b3dbc4..669ac19cbc 100644 --- a/RiotSwiftUI/Modules/Onboarding/SplashScreen/Coordinator/OnboardingSplashScreenCoordinator.swift +++ b/RiotSwiftUI/Modules/Onboarding/SplashScreen/Coordinator/OnboardingSplashScreenCoordinator.swift @@ -46,6 +46,7 @@ final class OnboardingSplashScreenCoordinator: OnboardingSplashScreenCoordinator onboardingSplashScreenViewModel = viewModel onboardingSplashScreenHostingController = VectorHostingController(rootView: view) onboardingSplashScreenHostingController.vc_removeBackTitle() + onboardingSplashScreenHostingController.isNavigationBarHidden = true indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: onboardingSplashScreenHostingController) }