Merge pull request #5533 from dave-atx/fix-iphone-duo-layout

Drop the empty navigation bar over articles when the bars move to a side
This commit is contained in:
Brent Simmons authored and GitHub committed 2026-11-04 09:54:44 -08:00
commit ec90003718
1 file changed
+23 -2
+23 -2
View File
@@ -52,6 +52,8 @@ final class ArticleViewController: UIViewController {
return button
}()
private let fullScreenTapZone = UIView()
weak var coordinator: SceneCoordinator!
private let poppableDelegate = PoppableGestureRecognizerDelegate()
@@ -132,13 +134,19 @@ final class ArticleViewController: UIViewController {
navigationItem.scrollEdgeAppearance = appearance
navigationItem.compactAppearance = appearance
let fullScreenTapZone = UIView()
NSLayoutConstraint.activate([
fullScreenTapZone.widthAnchor.constraint(equalToConstant: 150),
fullScreenTapZone.heightAnchor.constraint(equalToConstant: 44)
])
fullScreenTapZone.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTapNavigationBar)))
navigationItem.titleView = fullScreenTapZone
updateFullScreenTapZone()
#if compiler(>=6.4.2)
if #available(iOS 27.1, *) {
registerForTraitChanges(UITraitCollection.systemTraitsAffectingVerticalBarEdge) { (self: Self, _) in
self.updateFullScreenTapZone()
}
}
#endif
articleExtractorButton.addTarget(self, action: #selector(toggleArticleExtractor(_:)), for: .touchUpInside)
let articleExtractorBarButtonItem = UIBarButtonItem(customView: articleExtractorButton)
@@ -347,6 +355,19 @@ final class ArticleViewController: UIViewController {
// MARK: Actions
/// The tap zone lives in the navigation bar’s title view. When the system shows a vertical bar
/// (iPhone Duo), the bar buttons move into it and the tap zone would be the only thing keeping
/// an empty navigation bar across the top of the article, so it is left out.
private func updateFullScreenTapZone() {
#if compiler(>=6.4.2)
if #available(iOS 27.1, *), traitCollection.verticalBarEdge != .unspecified {
navigationItem.titleView = nil
return
}
#endif
navigationItem.titleView = fullScreenTapZone
}
@objc func didTapNavigationBar() {
currentWebViewController?.hideBars()
}