Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

tray/ios: edge-to-edge, and no host chrome over a slideshow

nyblnet26b8a174a58f
diff --git a/tray/README.md b/tray/README.md
index ba61e267..168b21f2 100644
--- a/tray/README.md
+++ b/tray/README.md
@@ -83,6 +83,15 @@ of this bridge did exactly that and prompted on every single save.
launch would wipe that storage on every open. The trade is that moving or
renaming a file gives it a new origin and orphans its local state — which is a
cache and a backstop, never the document itself.
+- **The page reaches every physical edge.** `contentInsetAdjustmentBehavior` is
+ set to `.never`; left at its default UIKit insets the scroll view by the safe
+ area, which in landscape left visible bands down the left, right and bottom of
+ a slideshow. The document owns its margins; the host adds none.
+- **The host shows nothing while the page presents.** `webView.fullscreenState`
+ is observed, and entering fullscreen hides both the nav bar and the floating
+ exit — a control sitting over a slideshow is exactly the chrome presenting is
+ meant to shed. (Contrary to one analysis, `fullscreenState` IS usable here,
+ because element fullscreen genuinely works — see below.)
- **Element fullscreen is enabled** (`preferences.isElementFullscreenEnabled`).
iPhone Safari has never offered element fullscreen to web pages, which is why
Bento's present mode falls back to filling its view in a browser — but
diff --git a/tray/ios/EditorViewController.swift b/tray/ios/EditorViewController.swift
index e175271a..7b5180a4 100644
--- a/tray/ios/EditorViewController.swift
+++ b/tray/ios/EditorViewController.swift
@@ -45,6 +45,8 @@ final class EditorViewController: UIViewController, WKScriptMessageHandler, WKUR
/// not overwrite it. Comparing filenames instead would fail: Bento derives
/// its suggested name from the deck TITLE, so it rarely matches.
private var openDocumentVended = false
+ private var isPresentingFullscreen = false
+ private var fullscreenObs: NSKeyValueObservation?
private var pendingExportName: String?
/// Stable per-document host: a truncated SHA-256 of the file's path. Hex
@@ -98,6 +100,11 @@ final class EditorViewController: UIViewController, WKScriptMessageHandler, WKUR
/// first and simply did not fire for a modally-presented navigation
/// controller — the bar stayed put in landscape.
private func syncChrome() {
+ if isPresentingFullscreen {
+ navigationController?.setNavigationBarHidden(true, animated: false)
+ floatingExit.isHidden = true
+ return
+ }
let short = traitCollection.verticalSizeClass == .compact
navigationController?.setNavigationBarHidden(short, animated: false)
floatingExit.isHidden = !short
@@ -109,6 +116,18 @@ final class EditorViewController: UIViewController, WKScriptMessageHandler, WKUR
syncChrome()
}
+ /// While the page is presenting, the host shows NOTHING. Element fullscreen
+ /// puts the deck edge to edge, and a floating control sitting over it is
+ /// exactly the chrome a slideshow is supposed to shed. Restored on exit.
+ private func observeFullscreen() {
+ fullscreenObs = webView.observe(\.fullscreenState, options: [.new]) { [weak self] wv, _ in
+ guard let self else { return }
+ let presenting = wv.fullscreenState == .inFullscreen || wv.fullscreenState == .enteringFullscreen
+ self.isPresentingFullscreen = presenting
+ self.syncChrome()
+ }
+ }
+
override func traitCollectionDidChange(_ previous: UITraitCollection?) {
super.traitCollectionDidChange(previous)
if traitCollection.verticalSizeClass != previous?.verticalSizeClass { syncChrome() }
@@ -138,7 +157,14 @@ final class EditorViewController: UIViewController, WKScriptMessageHandler, WKUR
webView = WKWebView(frame: view.bounds, configuration: cfg)
webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
webView.allowsBackForwardNavigationGestures = false
+ // The page must reach every physical edge. Left at .automatic, UIKit
+ // insets the scroll view by the safe area, so in landscape the deck
+ // stopped short of the left, right and bottom edges — visible as bands
+ // down three sides during a slideshow. The document decides its own
+ // margins; the host must not add any.
+ webView.scrollView.contentInsetAdjustmentBehavior = .never
view.addSubview(webView)
+ observeFullscreen()
webView.load(URLRequest(url: URL(string: "bento-tray://\(originHost)/index.html")!))
view.addSubview(floatingExit)