From ea1b75e6391d4b50adf2e1f4f587cf233c7025ca Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 22 Nov 2026 19:36:31 +0100 Subject: [PATCH] fix(mobile): keep every screen clear of the iPhone Duo's status capsule The capsule in a top corner was handled screen by screen: the m-corner-* classes and --m-corner-clear put bars beside it and lifted content below it, so every layer that did not opt in sat under it, and testers found it on almost every page. It now counts as safe area in mobile.css. Upright the top inset reaches below the capsule and the sides keep their full width; on a wide window its side is given up over the whole height instead. The per-screen handling and corner.css are gone. Control rows a screen places itself and layers that fill the window keep to the side insets through m-safe-row and m-safe-trail, and the trip's pane keeps its content off the capsule's side on a wide window. On every other device the insets come out as before. --- client/src/mobile/MobileShell.tsx | 1 - client/src/mobile/components/MImageViewer.tsx | 2 +- client/src/mobile/components/MSectionNav.tsx | 2 +- client/src/mobile/components/MSheet.tsx | 10 +- client/src/mobile/corner.css | 31 ----- client/src/mobile/mobile.css | 124 +++++++---------- client/src/mobile/screens/atlas/MAtlas.tsx | 2 +- .../src/mobile/screens/atlas/MAtlasSearch.tsx | 2 +- .../screens/collections/MCollections.tsx | 2 +- .../mobile/screens/dashboard/MUserMenu.tsx | 2 +- .../mobile/screens/journey/MJourneyDetail.tsx | 8 +- client/src/mobile/screens/trip/MTripShell.tsx | 29 ++-- .../mobile/screens/trip/MTripShellParts.tsx | 2 +- .../trip/assistant/MAssistantScreen.tsx | 8 +- .../src/mobile/screens/trip/map/MMapArea.tsx | 2 +- .../screens/trip/places/MPlacesBrowser.tsx | 2 +- .../screens/trip/plan/MPlanTimeline.tsx | 2 +- .../screens/trip/roadtrip/MRoadtripTab.tsx | 4 +- .../mobile/screens/trip/tabs/MCollabChat.tsx | 2 +- .../mobile/screens/trip/tabs/MCollabTab.tsx | 2 +- .../mobile/screens/trip/tabs/MFilesTab.tsx | 4 +- .../screens/trip/tabs/MTripTabPanel.tsx | 4 +- .../mobile/screens/trip/tabs/tabChrome.tsx | 4 +- client/src/mobile/screens/vacay/MVacay.tsx | 6 +- client/tests/unit/mobile/MSheet.test.tsx | 2 +- client/tests/unit/mobile/shellChrome.test.tsx | 129 +++++++----------- .../unit/mobile/trip/MRoadtripTab.test.tsx | 4 +- 27 files changed, 156 insertions(+), 236 deletions(-) delete mode 100644 client/src/mobile/corner.css diff --git a/client/src/mobile/MobileShell.tsx b/client/src/mobile/MobileShell.tsx index 6198cbdf9..27dbfa8f6 100644 --- a/client/src/mobile/MobileShell.tsx +++ b/client/src/mobile/MobileShell.tsx @@ -14,7 +14,6 @@ import { useNativeCapabilities } from '../native/capabilities' import { isNativeIos } from '../native/platform' import { useWindowFold } from '../native/windowFold' import './mobile.css' -import './corner.css' interface MobileShellProps { isPhone: boolean diff --git a/client/src/mobile/components/MImageViewer.tsx b/client/src/mobile/components/MImageViewer.tsx index 9e366a37c..676d25020 100644 --- a/client/src/mobile/components/MImageViewer.tsx +++ b/client/src/mobile/components/MImageViewer.tsx @@ -48,7 +48,7 @@ export default function MImageViewer({ type="button" onClick={onClose} aria-label={t('collab.chat.closeImage')} - className="m-corner-beside absolute end-4 top-[calc(var(--m-safe-top,12px)+4px)] z-10 flex h-10 w-10 items-center justify-center rounded-full bg-[color:var(--m-viewer-btn)] text-[color:var(--m-viewer-ink)]" + className="m-safe-row absolute end-4 top-[calc(var(--m-safe-top,12px)+4px)] z-10 flex h-10 w-10 items-center justify-center rounded-full bg-[color:var(--m-viewer-btn)] text-[color:var(--m-viewer-ink)]" > diff --git a/client/src/mobile/components/MSectionNav.tsx b/client/src/mobile/components/MSectionNav.tsx index 93d3ab51e..14eec1646 100644 --- a/client/src/mobile/components/MSectionNav.tsx +++ b/client/src/mobile/components/MSectionNav.tsx @@ -89,7 +89,7 @@ export function MSectionList({ * width on both screens. */ export const SECTION_SCREEN = - 'm-corner-flow px-4 pb-[calc(var(--bottom-nav-h,84px)+16px)] pt-[var(--m-safe-top,12px)] wide:mx-auto wide:max-w-[1040px] wide:px-6 split:grid split:max-w-[1240px] split:grid-cols-[260px_minmax(0,1fr)] split:items-start split:gap-8'; + 'px-4 pb-[calc(var(--bottom-nav-h,84px)+16px)] pt-[var(--m-safe-top,12px)] wide:mx-auto wide:max-w-[1040px] wide:px-6 split:grid split:max-w-[1240px] split:grid-cols-[260px_minmax(0,1fr)] split:items-start split:gap-8'; interface MSectionNavProps { title: string; diff --git a/client/src/mobile/components/MSheet.tsx b/client/src/mobile/components/MSheet.tsx index 7d33da0eb..8666e11f2 100644 --- a/client/src/mobile/components/MSheet.tsx +++ b/client/src/mobile/components/MSheet.tsx @@ -86,11 +86,11 @@ type MSheetWideAnchor = 'center' | 'rail-foot' * docked sheet just above the dock; neither lies across the dock. */ const REGION: Record = { - card: 'inset-x-[14px] top-[max(var(--m-safe-top,12px),var(--m-corner-clear,0px))] bottom-[calc(var(--bottom-nav-h,84px)+12px)] justify-center', + card: 'inset-x-[14px] top-[var(--m-safe-top,12px)] bottom-[calc(var(--bottom-nav-h,84px)+12px)] justify-center', // On a phone on its side the gap it keeps at the top would leave it a strip // of a few rows, so there it may rise nearly to the top. bottom: - 'inset-x-4 top-[max(calc(var(--m-safe-top,12px)+56px),var(--m-corner-clear,0px))] bottom-[calc(var(--bottom-nav-h,84px)+16px)] justify-end short:top-[calc(var(--m-safe-top,12px)+8px)]', + 'inset-x-4 top-[calc(var(--m-safe-top,12px)+56px)] bottom-[calc(var(--bottom-nav-h,84px)+16px)] justify-end short:top-[calc(var(--m-safe-top,12px)+8px)]', drawer: 'start-0 top-0 bottom-0 w-[78%] max-w-[320px]', } @@ -109,15 +109,15 @@ const WIDE_REGION: Record = { // A form on a window as short as a phone on its side: a sheet the window's // full height, over the dock, as wide as a form reads well and no wider. const SHORT_FORM_REGION = - 'short:inset-x-4 short:top-[max(env(safe-area-inset-top,0px),8px)] short:bottom-0 short:items-center short:justify-stretch' + 'short:inset-x-4 short:top-[max(var(--m-safe-t,0px),8px)] short:bottom-0 short:items-center short:justify-stretch' const SHORT_FORM_BOX = 'short:max-w-[640px] short:flex-1' /** The region the sheet stands in, on a phone and on a wide window. */ function regionClass(variant: MSheetVariant, anchor: MSheetWideAnchor = 'center', form = false): string { const base = 'pointer-events-none absolute flex flex-col' if (variant === 'drawer') return `${base} ${REGION.drawer}` - // m-corner-side: on a wide window the sheet keeps off a corner element's side (a Duo's status capsule). - return `${base} m-corner-side ${REGION[variant]} ${WIDE_REGION[anchor]}${form ? ` ${SHORT_FORM_REGION}` : ''}` + // m-safe-trail: on a wide window the sheet keeps off the trailing side's safe area (a Duo's status capsule). + return `${base} m-safe-trail ${REGION[variant]} ${WIDE_REGION[anchor]}${form ? ` ${SHORT_FORM_REGION}` : ''}` } /** The sheet's own box inside the region: its width, and the arrow when it has one. */ diff --git a/client/src/mobile/corner.css b/client/src/mobile/corner.css deleted file mode 100644 index 92373e4d9..000000000 --- a/client/src/mobile/corner.css +++ /dev/null @@ -1,31 +0,0 @@ -/* ── An element in a top corner (an iPhone Duo's status capsule) ────────────── - Beside mobile.css, which holds the variables these read (--m-corner-*). - For the screens that place their own controls rather than sit in .m-page - (the trip, its map). Every variable is 0 without such an element, so these - change nothing on any other device. - m-corner-beside: a control row in the corner's height ends before it. - m-corner-side: a layer that fills the page ends before the corner's side on - a wide window (--m-corner-side-*, 0 upright, where content starts below the - corner through --m-corner-clear instead). - The element sits where the hardware puts it, whatever the reading - direction, so right to left swaps the two sides back. */ -.m-corner-beside { - margin-inline: var(--m-corner-l-gap, 0px) var(--m-corner-r-gap, 0px); -} -html[dir='rtl'] .m-corner-beside { - margin-inline: var(--m-corner-r-gap, 0px) var(--m-corner-l-gap, 0px); -} -.m-corner-side { - margin-inline: var(--m-corner-side-l, 0px) var(--m-corner-side-r, 0px); -} -html[dir='rtl'] .m-corner-side { - margin-inline: var(--m-corner-side-r, 0px) var(--m-corner-side-l, 0px); -} -/* m-corner-beside-in: m-corner-beside for a row inside .m-page, upright only - (on a wide window the page itself already ends before the corner). */ -.m-corner-beside-in { - margin-inline: var(--m-corner-in-l, 0px) var(--m-corner-in-r, 0px); -} -html[dir='rtl'] .m-corner-beside-in { - margin-inline: var(--m-corner-in-r, 0px) var(--m-corner-in-l, 0px); -} diff --git a/client/src/mobile/mobile.css b/client/src/mobile/mobile.css index b0d39995a..0437d70e3 100644 --- a/client/src/mobile/mobile.css +++ b/client/src/mobile/mobile.css @@ -66,43 +66,26 @@ * publishSafeArea) is a floor under env(): where a release lays the web view * out below the status bar, WebKit reports 0 while a camera in a corner still * reaches into the page. In a browser the variables are unset: env() alone. */ - --m-safe-t: max(env(safe-area-inset-top, 0px), var(--trek-native-safe-top, 0px)); - --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); + --m-raw-t: max(env(safe-area-inset-top, 0px), var(--trek-native-safe-top, 0px)); + --m-raw-l: max(env(safe-area-inset-left, 0px), var(--trek-native-safe-left, 0px)); + --m-raw-r: max(env(safe-area-inset-right, 0px), var(--trek-native-safe-right, 0px)); /* 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 + * cornerElement), counts as safe area like a notch, so every screen keeps + * clear of it without knowing it is there. Upright the top inset reaches + * below it and the sides keep their full width (iOS reports the element as + * a side inset too, which is taken back out); on a wide window its side is + * given up over the whole height instead (below), where a band across the + * top would cost a quarter of the height. 0 on every other device. */ + --m-safe-t: max(var(--m-raw-t), var(--trek-native-corner-bottom, 0px)); + --m-safe-l: max(0px, var(--m-raw-l) - var(--trek-native-corner-left, 0px)); + --m-safe-r: max(0px, var(--m-raw-r) - var(--trek-native-corner-right, 0px)); + --m-safe-top: calc(var(--m-safe-t) + 12px); + /* A side inset plus a little air, for a bar beside it: a bar that ends + * exactly at the inset reads as touching what is there. 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 corner element alone, with the same air, for the screens that place - * their own controls (the trip, the map): a control row in the corner's - * height ends this far from the screen's side (m-corner-beside). Physical - * sides, as the element is: right to left does not move it. */ - --m-corner-l-gap: calc(var(--trek-native-corner-left, 0px) + min(var(--trek-native-corner-left, 0px), 8px)); - --m-corner-r-gap: calc(var(--trek-native-corner-right, 0px) + min(var(--trek-native-corner-right, 0px), 8px)); - /* Where the content of a screen that places its own scroll body begins at - * the latest, so its first row is not under the corner element: just below - * it (m-corner-below). Upright that is the cheaper way round; on a wide - * window the page gives up the corner's side instead (below). 0 elsewhere. */ - --m-corner-clear: calc(var(--m-corner-b) + min(var(--m-corner-b), 10px)); - --m-corner-side-l: 0px; - --m-corner-side-r: 0px; - /* The same air for a control row inside .m-page, which on a wide window has - * already given up the corner's side (m-corner-beside-in). */ - --m-corner-in-l: var(--m-corner-l-gap); - --m-corner-in-r: var(--m-corner-r-gap); + --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)); /* 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; @@ -115,21 +98,15 @@ * reads the same values as the shell. */ html:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-root { --bottom-nav-h: env(safe-area-inset-bottom, 0px); - --m-rail-w: calc(var(--m-bar-l) + 100px); + --m-rail-w: calc(var(--m-safe-l) + 100px); /* A wide window gives up the corner element's side over the whole height, - * as an iPhone on its side does for its camera: on an unfolded Duo lifting - * every page below the status capsule cost a quarter of the height. The - * rail already takes the leading side, so only the trailing side's corner - * counts here. */ - --m-corner-clear: 0px; - --m-corner-side-r: var(--m-corner-r-gap); - --m-corner-in-l: 0px; - --m-corner-in-r: 0px; + * as an iPhone on its side does for its camera, and keeps the top as it is. */ + --m-safe-t: var(--m-raw-t); + --m-safe-l: max(var(--m-raw-l), var(--trek-native-corner-left, 0px)); + --m-safe-r: max(var(--m-raw-r), var(--trek-native-corner-right, 0px)); } html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-root { - --m-rail-w: calc(var(--m-bar-r) + 100px); - --m-corner-side-l: var(--m-corner-l-gap); - --m-corner-side-r: 0px; + --m-rail-w: calc(var(--m-safe-r) + 100px); } .dark .m-root { @@ -649,40 +626,43 @@ html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m- html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-span-x { inset-inline-end: var(--m-safe-l-gap, 0px); } +/* A control row or button a screen places by itself (m-safe-row: the trip's + top row, the map's controls, a viewer's close button, a dropdown) keeps + clear of the sides' safe area like the bars above: both sides on a phone, + the trailing side on a wide window, where the rail holds the leading one. + A layer that fills the window (m-safe-trail: a sheet, the assistant, the + trip's pane and map) does the same on a wide window only; on a phone its + own insets keep it off the sides. On an unfolded Duo that trailing side is + the status capsule's. */ +html:not(:has(.m-shell[data-size='wide'], .m-shell[data-size='split'])) .m-safe-row { + margin-inline: var(--m-safe-l-gap, 0px) var(--m-safe-r-gap, 0px); +} +html[dir='rtl']:not(:has(.m-shell[data-size='wide'], .m-shell[data-size='split'])) .m-safe-row { + margin-inline: var(--m-safe-r-gap, 0px) var(--m-safe-l-gap, 0px); +} +html:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) :is(.m-safe-row, .m-safe-trail) { + margin-inline-end: var(--m-safe-r-gap, 0px); +} +html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) :is(.m-safe-row, .m-safe-trail) { + margin-inline-end: var(--m-safe-l-gap, 0px); +} /* The page itself keeps clear of the sides' safe area, as iOS asks of every - 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. */ + app. Margins, so the rail's wide:ps on the same element stays; fixed layers + are the window's and keep their own rules. On a wide window the rail takes + the leading inset, so the page starts at the rail and ends before the + trailing inset. */ .m-page { - margin-inline: var(--m-page-l, 0px) var(--m-page-r, 0px); - padding-top: max(0px, calc(var(--m-corner-clear, 0px) + 2px - var(--m-safe-top, 12px) - 70px)); + margin-inline: var(--m-safe-l, 0px) var(--m-safe-r, 0px); } html[dir='rtl'] .m-page { - margin-inline: var(--m-page-r, 0px) var(--m-page-l, 0px); + margin-inline: var(--m-safe-r, 0px) var(--m-safe-l, 0px); } -/* The lift above counts on a floating top bar over the page. A screen whose - first row is part of the page (m-corner-flow: settings, administration, - collections) is lifted until that row starts below the corner element; one - that keeps clear of it by itself (m-corner-own: a map under its own bars, a - calendar under its own header) is not lifted at all. */ -.m-page:has(.m-corner-flow) { - padding-top: max(0px, calc(var(--m-corner-clear, 0px) - var(--m-safe-top, 12px))); -} -.m-page:has(.m-corner-own) { - padding-top: 0; -} -/* On a wide window the page starts at the top and ends before the corner - element instead (--m-corner-side-*, 0 without one). */ html:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-page { margin-inline-start: 0; - margin-inline-end: max(var(--m-page-r, 0px), var(--m-corner-side-r, 0px)); + margin-inline-end: var(--m-safe-r-gap, 0px); } html[dir='rtl']:has(.m-shell[data-size='wide'], .m-shell[data-size='split']) .m-page { - margin-inline-end: max(var(--m-page-l, 0px), var(--m-corner-side-l, 0px)); + margin-inline-end: var(--m-safe-l-gap, 0px); } /* A screen whose background is a map reaches under the rail: the map runs to the window's edge and the rail floats over it like the top controls do. Its @@ -786,7 +766,7 @@ html:has(.m-shell) [data-desktop-navbar] { html:has(.m-shell) [data-plugin-page] { --plugin-page-h: calc(100dvh - var(--bottom-nav-h, 0px)); box-sizing: border-box; - padding-top: env(safe-area-inset-top, 0px); + padding-top: var(--m-safe-t, env(safe-area-inset-top, 0px)); padding-inline-start: var(--m-rail-w, 0px); } html:has(.m-shell) .leaflet-control-zoom { diff --git a/client/src/mobile/screens/atlas/MAtlas.tsx b/client/src/mobile/screens/atlas/MAtlas.tsx index 95fef29ae..0db3037c4 100644 --- a/client/src/mobile/screens/atlas/MAtlas.tsx +++ b/client/src/mobile/screens/atlas/MAtlas.tsx @@ -122,7 +122,7 @@ export default function MAtlas() { return ( // h-dvh, not h-full: the shell stopped providing a definite height (#1809) // and a map on a percentage of an auto-height parent collapses to zero. -
+
{/* Region hover tooltip — positioned imperatively by useAtlas. */}
o.label.toLowerCase().includes(q)).slice(0, 6) : suggestions - const scrimCls = 'm-fade-in fixed inset-0 z-[70] flex flex-col bg-[rgba(16,16,19,.28)] px-[18px] pt-[max(calc(var(--m-safe-top,12px)+12px),var(--m-corner-clear,0px))] backdrop-blur-[22px] backdrop-saturate-[1.6] wide:pt-[calc(var(--m-safe-top,12px)+72px)] wide:[&>*]:mx-auto wide:[&>*]:w-full wide:[&>*]:max-w-[640px]' // theme-lint-disable — fixed scrim value from the design + const scrimCls = 'm-fade-in fixed inset-0 z-[70] flex flex-col bg-[rgba(16,16,19,.28)] px-[18px] pt-[calc(var(--m-safe-top,12px)+12px)] backdrop-blur-[22px] backdrop-saturate-[1.6] wide:pt-[calc(var(--m-safe-top,12px)+72px)] wide:[&>*]:mx-auto wide:[&>*]:w-full wide:[&>*]:max-w-[640px]' // theme-lint-disable — fixed scrim value from the design return (
{split && (