From 3d3e45c05f3791ffacacbfe997da9ef61c6b4cb4 Mon Sep 17 00:00:00 2001 From: Fernando Bunn Date: Wed, 11 Dec 2024 10:54:56 -0300 Subject: [PATCH] Remove landscape support for iPhone https://app.asana.com/0/1204167627774280/1208947094200047/f --- DuckDuckGo/MainViewController.swift | 3 ++- ...ndedPageSheetContainerViewController.swift | 26 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index d142c865e7..db55cc9565 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -1719,7 +1719,8 @@ class MainViewController: UIViewController { let roundedPageSheet = RoundedPageSheetContainerViewController( contentViewController: aiChatViewController, logoImage: logoImage, - title: title) + title: title, + allowedOrientation: .portrait) present(roundedPageSheet, animated: true, completion: nil) } diff --git a/DuckDuckGo/RoundedPageContainer/RoundedPageSheetContainerViewController.swift b/DuckDuckGo/RoundedPageContainer/RoundedPageSheetContainerViewController.swift index 880f474802..a9cb54dc7e 100644 --- a/DuckDuckGo/RoundedPageContainer/RoundedPageSheetContainerViewController.swift +++ b/DuckDuckGo/RoundedPageContainer/RoundedPageSheetContainerViewController.swift @@ -23,6 +23,7 @@ final class RoundedPageSheetContainerViewController: UIViewController { let contentViewController: UIViewController private let logoImage: UIImage? private let titleText: String + private let allowedOrientation: UIInterfaceOrientationMask private lazy var titleBarView: TitleBarView = { let titleBarView = TitleBarView(logoImage: logoImage, title: titleText) { [weak self] in @@ -31,13 +32,13 @@ final class RoundedPageSheetContainerViewController: UIViewController { return titleBarView }() - init(contentViewController: UIViewController, logoImage: UIImage?, title: String) { + init(contentViewController: UIViewController, logoImage: UIImage?, title: String, allowedOrientation: UIInterfaceOrientationMask = .all) { self.contentViewController = contentViewController self.logoImage = logoImage self.titleText = title + self.allowedOrientation = allowedOrientation super.init(nibName: nil, bundle: nil) modalPresentationStyle = .custom - transitioningDelegate = self } @@ -45,6 +46,18 @@ final class RoundedPageSheetContainerViewController: UIViewController { fatalError("init(coder:) has not been implemented") } + override var shouldAutorotate: Bool { + return false + } + + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + return allowedOrientation + } + + override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { + return UIInterfaceOrientation.portrait + } + override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .black @@ -53,15 +66,6 @@ final class RoundedPageSheetContainerViewController: UIViewController { setupContentViewController() } - override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { - super.viewWillTransition(to: size, with: coordinator) - - coordinator.animate(alongsideTransition: { _ in - // Update layout or constraints here - }, completion: nil) - } - - private func setupTitleBar() { view.addSubview(titleBarView) titleBarView.translatesAutoresizingMaskIntoConstraints = false