Skip to content

Commit

Permalink
Remove landscape support for iPhone
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunn committed Dec 11, 2024
1 parent b2220e1 commit 3d3e45c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,20 +32,32 @@ 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
}

required init?(coder: NSCoder) {
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
Expand All @@ -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
Expand Down

0 comments on commit 3d3e45c

Please sign in to comment.