fix(android): clear the system bars and display cutout (UR-066)

The bottom nav rendered under the Android navigation bar, and full-screen
playback controls spilled into unusable screen edges. It looked device-specific
(Motorola bad, Fairphone fine) but every device was equally unpadded — only the
intrusion differed: a tall opaque 3-button bar swallows the nav, a thin
translucent gesture pill overlaps harmlessly.

None of the app's safe-area handling was ever active, for two independent
reasons:

  1. app.html had no `viewport-fit=cover`, so every `env(safe-area-inset-*)`
     resolved to 0px — the padding in app.css and BottomUi was a no-op.
  2. Android WebView maps only the *display cutout* into `env()`; the status bar
     and navigation bar are never reported. With enableEdgeToEdge() and
     targetSdk 36 (enforced from 35, opt-out ignored from 36) the WebView always
     spans them, so CSS could not learn about them by any route.

WindowInsetsBridge now reads `systemBars() | displayCutout()` and publishes
`--jt-inset-*` CSS custom properties, both pushed on every inset change
(rotation, nav-mode switch, PiP) and pullable via `AndroidInsets.get()` — the
pull is required because the first inset pass lands before the document exists
and a page load wipes the pushed inline style. app.css folds them with `env()`
via `max()` into `--safe-*`, the only thing components may pad from.

Exactly one element owns each edge: the shell takes top/left/right, BottomUi
takes bottom (inside its surface box, so the colour extends behind the gesture
bar), and shellReservesBottomInset hands bottom back to the shell on routes with
no bottom UI. The full-screen players inset their control layers only, leaving
video and artwork edge-to-edge.

The theme's `fitsSystemWindows=true` claimed the opposite of what actually
happened — overridden at runtime, ignored at this target SDK — and is removed.

Also converts six nested `h-screen`/`min-h-screen` boxes to `h-full`: the shell
is `h-screen` *and* inset-padded, so its content box is `100vh - safe-top` and
any nested 100vh box overflows by exactly the inset (the library column would
have clipped its own BottomUi). A test guards against reintroduction.
This commit is contained in:
2026-08-04 14:45:10 +02:00
parent 58f2506966
commit c55ff45692
20 changed files with 790 additions and 33 deletions
+31 -5
View File
@@ -14,6 +14,37 @@
--color-surface-hover: #252525;
}
/* Safe-area insets — the single source of edge padding for the whole app.
*
* TRACES: UR-066 | DR-112
*
* Two independent sources have to be folded together:
*
* - `env(safe-area-inset-*)` — iOS/desktop, and the *display cutout* on
* Android. Requires `viewport-fit=cover` (see src/app.html) or it is 0px.
* - `var(--jt-inset-*)` — real Android `WindowInsets` (status bar, navigation/
* gesture bar, cutout) pushed in from Kotlin, because Android WebView never
* reports the *system bars* through `env()`. See WindowInsetsBridge.kt and
* $lib/utils/safeArea.ts.
*
* `max()` takes whichever is real on this platform; both are 0 on desktop.
* Consumers must use `--safe-*` and never `env()` directly — a bare `env()` is
* silently 0 for the Android system bars, which is what put the bottom nav
* under the navigation bar on 3-button-nav devices.
*
* Applied at the edges that own them: the app shell (top/left/right) and
* BottomUi (bottom, so its surface colour extends behind the gesture bar).
* Deliberately NOT applied to `body` — the shell is `h-screen`, and body
* padding would push 100vh past the viewport, and `position: fixed` overlays
* (the video/audio players) ignore body padding anyway.
*/
:root {
--safe-top: max(env(safe-area-inset-top, 0px), var(--jt-inset-top, 0px));
--safe-right: max(env(safe-area-inset-right, 0px), var(--jt-inset-right, 0px));
--safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--jt-inset-bottom, 0px));
--safe-left: max(env(safe-area-inset-left, 0px), var(--jt-inset-left, 0px));
}
/* Global styles */
html, body {
@apply h-full;
@@ -23,9 +54,4 @@ html, body {
body {
@apply text-white antialiased;
font-family: system-ui, -apple-system, sans-serif;
/* Handle safe areas for mobile devices (status bar, notches, etc.) */
padding-top: env(safe-area-inset-top);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
}