Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

tray/ios: give the editor its height back in landscape

nyblnet542b65b0a9d5
diff --git a/tray/README.md b/tray/README.md
index f944f700..27365bbb 100644
--- a/tray/README.md
+++ b/tray/README.md
@@ -176,6 +176,18 @@ file outside the container.
The nav bar does NOT intrude on a slideshow, because presenting takes real
element fullscreen — see below. It is chrome for editing only.
+It also **auto-hides in landscape** (`hidesBarsWhenVerticallyCompact`). A phone
+in landscape is only ~390pt tall, so 44pt is over a tenth of the height, on the
+very axis a 16:9 canvas needs most. When the bar is away, a small floating
+chevron stands in, pinned to the **safe-area inset** — on a notched iPhone held
+sideways that gutter is dead space no content can occupy, so the exit costs
+nothing there.
+
+UNVERIFIED: the landscape path has not been exercised. `simctl` cannot rotate a
+device, and it captures the display buffer without the rotation transform, so
+its dimensions do not report orientation either. Rotate by hand (⌘← in
+Simulator) to confirm.
+
### Platform notes worth keeping
`didImportDocumentAt` is **never called for the creation flow** on iOS 26. The
diff --git a/tray/ios/DocumentBrowserViewController.swift b/tray/ios/DocumentBrowserViewController.swift
index c3ec5b69..5402a1ca 100644
--- a/tray/ios/DocumentBrowserViewController.swift
+++ b/tray/ios/DocumentBrowserViewController.swift
@@ -98,6 +98,11 @@ final class DocumentBrowserViewController: UIDocumentBrowserViewController,
editor.title = url.deletingPathExtension().deletingPathExtension().lastPathComponent
let nav = UINavigationController(rootViewController: editor)
nav.modalPresentationStyle = .fullScreen
+ // Landscape on a phone is SHORT — ~390pt — so a 44pt bar is over a
+ // tenth of the height, on the axis a 16:9 canvas needs most. UIKit
+ // has this exact case built in; the editor supplies a floating exit
+ // for when the bar is away.
+ nav.hidesBarsWhenVerticallyCompact = true
editor.onDone = { [weak self, weak nav] in
// close() flushes and relinquishes file coordination; without it
// the document stayed open for the life of the app. The scope is
diff --git a/tray/ios/EditorViewController.swift b/tray/ios/EditorViewController.swift
index 47f33658..452127dd 100644
--- a/tray/ios/EditorViewController.swift
+++ b/tray/ios/EditorViewController.swift
@@ -66,6 +66,33 @@ final class EditorViewController: UIViewController, WKScriptMessageHandler, WKUR
}
@objc private func doneTapped() { onDone?() }
+
+ /// Fallback exit for when the nav bar is hidden (landscape). Lives in the
+ /// SAFE AREA inset — on a notched iPhone held sideways that gutter is dead
+ /// space no content can occupy, so this costs nothing at all, unlike the
+ /// 44pt the bar spends.
+ private lazy var floatingExit: UIButton = {
+ let b = UIButton(type: .system)
+ var cfg = UIButton.Configuration.filled()
+ cfg.image = UIImage(systemName: "chevron.left")
+ cfg.cornerStyle = .capsule
+ cfg.baseBackgroundColor = UIColor.systemBackground.withAlphaComponent(0.7)
+ cfg.baseForegroundColor = .label
+ cfg.contentInsets = .init(top: 8, leading: 10, bottom: 8, trailing: 10)
+ b.configuration = cfg
+ b.accessibilityLabel = NSLocalizedString("Documents", comment: "back to the file browser")
+ b.addTarget(self, action: #selector(doneTapped), for: .touchUpInside)
+ b.isHidden = true
+ return b
+ }()
+
+ /// Keep exactly ONE exit affordance on screen. The bar auto-hides when the
+ /// vertical size class is compact (iPhone landscape), and the floating
+ /// control stands in for it there.
+ override func viewDidLayoutSubviews() {
+ super.viewDidLayoutSubviews()
+ floatingExit.isHidden = !(navigationController?.isNavigationBarHidden ?? false)
+ }
required init?(coder: NSCoder) { fatalError("not used") }
override func viewDidLoad() {