Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(mobile): put the top bar beside a Duo's status capsule and the page below it, full width

Maurice0f42b8b8ae86
diff --git a/client/ios/App/App/TrekBridgeViewController.swift b/client/ios/App/App/TrekBridgeViewController.swift
index 7d61fcd21..ccc45e4d3 100644
--- a/client/ios/App/App/TrekBridgeViewController.swift
+++ b/client/ios/App/App/TrekBridgeViewController.swift
@@ -120,18 +120,47 @@ class TrekBridgeViewController: CAPBridgeViewController {
bottom: max(0, safe.bottom - (window.bounds.maxY - frame.maxY)),
right: max(0, safe.right - (window.bounds.maxX - frame.maxX))
)
- if !force, insets == publishedSafeArea { return }
+ let corner = cornerElement(in: frame, window: window)
+ if !force, insets == publishedSafeArea, corner == publishedCorner { return }
publishedSafeArea = insets
+ publishedCorner = corner
let px = { (v: CGFloat) in "'\(Int(v.rounded(.up)))px'" }
let js = "(function(s){"
+ "s.setProperty('--trek-native-safe-top',\(px(insets.top)));"
+ "s.setProperty('--trek-native-safe-left',\(px(insets.left)));"
+ "s.setProperty('--trek-native-safe-right',\(px(insets.right)));"
+ "s.setProperty('--trek-native-safe-bottom',\(px(insets.bottom)));"
+ + "s.setProperty('--trek-native-corner-bottom',\(px(corner.top)));"
+ + "s.setProperty('--trek-native-corner-left',\(px(corner.left)));"
+ + "s.setProperty('--trek-native-corner-right',\(px(corner.right)));"
+ "})(document.documentElement.style)"
webView.evaluateJavaScript(js, completionHandler: nil)
}
+ private var publishedCorner: UIEdgeInsets?
+
+ /// An element in a top corner of the screen, such as the status capsule of
+ /// an iPhone Duo: how far down it reaches (top) and how wide it is on its
+ /// side (left/right), in the web view's coordinates; zero where there is
+ /// none. iOS 26 tells a corner apart from a whole edge: the safe area with
+ /// the corner avoided vertically reaches lower than the one avoiding it
+ /// horizontally, which in turn is wider on the corner's side. The page puts
+ /// its top bar beside the element and starts its content below it, using
+ /// the full width (mobile.css), instead of giving up a strip of the whole
+ /// height.
+ private func cornerElement(in frame: CGRect, window: UIWindow) -> UIEdgeInsets {
+ guard #available(iOS 26.0, *) else { return .zero }
+ let vertical = view.edgeInsets(for: .safeArea(cornerAdaptation: .vertical))
+ let horizontal = view.edgeInsets(for: .safeArea(cornerAdaptation: .horizontal))
+ guard vertical.top > horizontal.top + 1 else { return .zero }
+ return UIEdgeInsets(
+ top: max(0, vertical.top - frame.minY),
+ left: max(0, horizontal.left - vertical.left - frame.minX),
+ bottom: 0,
+ right: max(0, horizontal.right - vertical.right - (window.bounds.maxX - frame.maxX))
+ )
+ }
+
// MARK: - A proxy's sign-in page
/// Over a proxy's sign-in page (Pangolin, authentik, ...) the server's UI is
diff --git a/client/src/mobile/mobile.css b/client/src/mobile/mobile.css
index 5da25aa69..fbbf56b7b 100644
--- a/client/src/mobile/mobile.css
+++ b/client/src/mobile/mobile.css
@@ -70,11 +70,22 @@
--m-safe-l: max(env(safe-area-inset-left, 0px), var(--trek-native-safe-left, 0px));
--m-safe-r: max(env(safe-area-inset-right, 0px), var(--trek-native-safe-right, 0px));
--m-safe-top: calc(var(--m-safe-t) + 12px);
- /* A side inset plus a little air, for the floating bars: next to a Duo's
- * status capsule a bar that ends exactly at the inset reads as touching it.
- * Without an inset the air is 0 too (min() of 0 and 8px). */
- --m-safe-l-gap: calc(var(--m-safe-l) + min(var(--m-safe-l), 8px));
- --m-safe-r-gap: calc(var(--m-safe-r) + min(var(--m-safe-r), 8px));
+ /* An element in a top corner of the screen, such as an iPhone Duo's status
+ * capsule, as the iOS app measures it (TrekBridgeViewController
+ * cornerElement): how far down it reaches and how wide it is on its side.
+ * The floating bars stand beside it; the page keeps the side's full width
+ * and starts below it, instead of giving up a strip of the whole height to
+ * an inset that only exists in the corner. 0 everywhere else. */
+ --m-corner-b: var(--trek-native-corner-bottom, 0px);
+ --m-bar-l: max(var(--m-safe-l), var(--trek-native-corner-left, 0px));
+ --m-bar-r: max(var(--m-safe-r), var(--trek-native-corner-right, 0px));
+ --m-page-l: max(0px, var(--m-safe-l) - var(--trek-native-corner-left, 0px));
+ --m-page-r: max(0px, var(--m-safe-r) - var(--trek-native-corner-right, 0px));
+ /* A bar's side inset plus a little air: next to a Duo's status capsule a
+ * bar that ends exactly at the inset reads as touching it. Without an inset
+ * the air is 0 too (min() of 0 and 8px). */
+ --m-safe-l-gap: calc(var(--m-bar-l) + min(var(--m-bar-l), 8px));
+ --m-safe-r-gap: calc(var(--m-bar-r) + min(var(--m-bar-r), 8px));
/* The navigation rail's share of the leading edge (wide windows only), what
* every full-width fixed bar and the page column start after. */
--m-rail-w: 0px;
@@ -611,15 +622,19 @@ html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-
inset-inline-end: var(--m-safe-l-gap, 0px);
}
/* The page itself keeps clear of the sides' safe area, as iOS asks of every
- app: on a Duo the status capsule stands in the right inset, and cards under
- the top bar ran beneath it (TestFlight feedback). Margins, so the rail's
- wide:ps on the same element stays; fixed layers are the window's and keep
- their own rules. The rail already takes the leading inset on a wide window. */
+ app, and starts below an element in a top corner: on a Duo the status
+ capsule ran over the cards under the top bar (TestFlight feedback). The
+ padding lifts the content only by what the capsule reaches below the top
+ bar's row (about 70px under the top clearance), so with no corner element
+ it is 0. Margins, so the rail's wide:ps on the same element stays; fixed
+ layers are the window's and keep their own rules. The rail already takes
+ the leading inset on a wide window. */
.m-page {
- margin-inline: var(--m-safe-l, 0px) var(--m-safe-r, 0px);
+ margin-inline: var(--m-page-l, 0px) var(--m-page-r, 0px);
+ padding-top: max(0px, calc(var(--m-corner-b, 0px) + 12px - var(--m-safe-top, 12px) - 70px));
}
html[dir='rtl'] .m-page {
- margin-inline: var(--m-safe-r, 0px) var(--m-safe-l, 0px);
+ margin-inline: var(--m-page-r, 0px) var(--m-page-l, 0px);
}
html:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-page {
margin-inline-start: 0;
diff --git a/client/tests/unit/mobile/shellChrome.test.tsx b/client/tests/unit/mobile/shellChrome.test.tsx
index 4a7d81f62..a031795e3 100644
--- a/client/tests/unit/mobile/shellChrome.test.tsx
+++ b/client/tests/unit/mobile/shellChrome.test.tsx
@@ -74,8 +74,8 @@ describe('safe area in the touch shell', () => {
});
it('FE-MOB-CHROME-006: a side inset gets a little air, and none where there is no inset', () => {
- expect(css).toContain('--m-safe-r-gap: calc(var(--m-safe-r) + min(var(--m-safe-r), 8px));');
- expect(css).toContain('--m-safe-l-gap: calc(var(--m-safe-l) + min(var(--m-safe-l), 8px));');
+ expect(css).toContain('--m-safe-r-gap: calc(var(--m-bar-r) + min(var(--m-bar-r), 8px));');
+ expect(css).toContain('--m-safe-l-gap: calc(var(--m-bar-l) + min(var(--m-bar-l), 8px));');
});
it('FE-MOB-CHROME-007: on a wide window the bars end before the trailing inset, by their box, not a margin', () => {
@@ -91,12 +91,26 @@ describe('safe area in the touch shell', () => {
it('FE-MOB-CHROME-008: the page keeps clear of the side insets, the leading one left to the rail on a wide window', () => {
expect(css.split('\n.m-page {')[1]?.split('}')[0] ?? '').toContain(
- 'margin-inline: var(--m-safe-l, 0px) var(--m-safe-r, 0px);'
+ 'margin-inline: var(--m-page-l, 0px) var(--m-page-r, 0px);'
);
expect(css.split("html[dir='rtl'] .m-page {")[1]?.split('}')[0] ?? '').toContain(
- 'margin-inline: var(--m-safe-r, 0px) var(--m-safe-l, 0px);'
+ 'margin-inline: var(--m-page-r, 0px) var(--m-page-l, 0px);'
);
const wide = "html:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-page {";
expect(css.split(wide)[1]?.split('}')[0] ?? '').toContain('margin-inline-start: 0;');
});
+
+ it('FE-MOB-CHROME-009: an element in a top corner moves the bars beside it and the page below it, not a whole strip aside', () => {
+ // The bars avoid the wider of the side inset and the corner element.
+ expect(css).toContain('--m-bar-r: max(var(--m-safe-r), var(--trek-native-corner-right, 0px));');
+ expect(css).toContain('--m-bar-l: max(var(--m-safe-l), var(--trek-native-corner-left, 0px));');
+ // The page gives the corner's width back and starts below the corner instead.
+ expect(css).toContain('--m-page-r: max(0px, var(--m-safe-r) - var(--trek-native-corner-right, 0px));');
+ expect(css).toContain('--m-page-l: max(0px, var(--m-safe-l) - var(--trek-native-corner-left, 0px));');
+ expect(css.split('\n.m-page {')[1]?.split('}')[0] ?? '').toContain(
+ 'padding-top: max(0px, calc(var(--m-corner-b, 0px) + 12px - var(--m-safe-top, 12px) - 70px));'
+ );
+ // Without a corner element (every other device, iOS before 26) nothing moves.
+ expect(css).toContain('--m-corner-b: var(--trek-native-corner-bottom, 0px);');
+ });
});