Skip to content

Commit

Permalink
Fix navigation bars inside of VectorHostingController.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Oct 4, 2022
1 parent eda5861 commit aa46a20
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions Riot/Modules/Common/SwiftUI/VectorHostingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ class VectorHostingController: UIHostingController<AnyView> {
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)

Expand All @@ -93,6 +85,14 @@ class VectorHostingController: UIHostingController<AnyView> {
}
}

override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()

if let navigationController = navigationController, navigationController.isNavigationBarHidden != isNavigationBarHidden {
navigationController.isNavigationBarHidden = isNavigationBarHidden
}
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class OnboardingCelebrationCoordinator: Coordinator, Presentable {
onboardingCelebrationViewModel = viewModel
onboardingCelebrationHostingController = VectorHostingController(rootView: view)
onboardingCelebrationHostingController.enableNavigationBarScrollEdgeAppearance = true
onboardingCelebrationHostingController.isNavigationBarHidden = true
}

// MARK: - Public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ final class OnboardingCongratulationsCoordinator: Coordinator, Presentable {
onboardingCongratulationsViewModel = viewModel
onboardingCongratulationsHostingController = VectorHostingController(rootView: view)
onboardingCongratulationsHostingController.statusBarStyle = .lightContent
onboardingCongratulationsHostingController.isNavigationBarHidden = true
}

// MARK: - Public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ final class OnboardingSplashScreenCoordinator: OnboardingSplashScreenCoordinator
onboardingSplashScreenViewModel = viewModel
onboardingSplashScreenHostingController = VectorHostingController(rootView: view)
onboardingSplashScreenHostingController.vc_removeBackTitle()
onboardingSplashScreenHostingController.isNavigationBarHidden = true

indicatorPresenter = UserIndicatorTypePresenter(presentingViewController: onboardingSplashScreenHostingController)
}
Expand Down

0 comments on commit aa46a20

Please sign in to comment.