diff --git a/client/native-shell/shell.css b/client/native-shell/shell.css index 2e64792af..71e55501e 100644 --- a/client/native-shell/shell.css +++ b/client/native-shell/shell.css @@ -204,11 +204,32 @@ --sea: #cfe3ef; --text-face: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; --display-face: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; - /* The insets of the device, from the web view or, on iOS, from the native side. */ - --safe-top: max(env(safe-area-inset-top, 0px), var(--trek-native-safe-top, 0px)); - --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--trek-native-safe-bottom, 0px)); - --safe-start: max(env(safe-area-inset-left, 0px), var(--trek-native-safe-left, 0px)); - --safe-end: max(env(safe-area-inset-right, 0px), var(--trek-native-safe-right, 0px)); + /* The insets of the device, from the web view or from the native side. On + * Android a web view can report env() as 0 while the page reaches under the + * status and navigation bars; Capacitor's SystemBars writes the real insets + * to --safe-area-inset-* instead (0 where it lays the web view out between + * the bars). iOS measures its own (TrekBridgeViewController publishSafeArea). + * In a browser the variables are unset: env() alone. */ + --safe-top: max( + env(safe-area-inset-top, 0px), + var(--safe-area-inset-top, 0px), + var(--trek-native-safe-top, 0px) + ); + --safe-bottom: max( + env(safe-area-inset-bottom, 0px), + var(--safe-area-inset-bottom, 0px), + var(--trek-native-safe-bottom, 0px) + ); + --safe-start: max( + env(safe-area-inset-left, 0px), + var(--safe-area-inset-left, 0px), + var(--trek-native-safe-left, 0px) + ); + --safe-end: max( + env(safe-area-inset-right, 0px), + var(--safe-area-inset-right, 0px), + var(--trek-native-safe-right, 0px) + ); color-scheme: light; -webkit-text-size-adjust: 100%; } diff --git a/client/tests/unit/native/nativeShell.test.ts b/client/tests/unit/native/nativeShell.test.ts index fcb824655..1fa9b7b9f 100644 --- a/client/tests/unit/native/nativeShell.test.ts +++ b/client/tests/unit/native/nativeShell.test.ts @@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest'; import { directionOf, pickLocale, translator } from '../../../native-shell/i18n'; -// FE-NATIVE-SHELL-001 to FE-NATIVE-SHELL-006 +// FE-NATIVE-SHELL-001 to FE-NATIVE-SHELL-007 // // The app's own first screens (client/native-shell): which language and reading // direction they start in, and the layout rules in shell.css that no component @@ -97,4 +97,19 @@ describe('native shell', () => { /margin-left|margin-right|padding-left|padding-right|text-align:\s*left|[^-]left:\s|[^-]right:\s/ ); }); + + it("FE-NATIVE-SHELL-007: every edge clears the system bars from Android's injected insets too, and the foot keeps clear of the navigation bar", () => { + const root = find(':root') + .map((r) => r.body) + .join(''); + const side = (name: string, edge: string) => + new RegExp( + `--${name}:\\s*max\\(\\s*env\\(safe-area-inset-${edge}, 0px\\),\\s*var\\(--safe-area-inset-${edge}, 0px\\),\\s*var\\(--trek-native-safe-${edge}, 0px\\)\\s*\\)` + ); + expect(root).toMatch(side('safe-top', 'top')); + expect(root).toMatch(side('safe-bottom', 'bottom')); + expect(root).toMatch(side('safe-start', 'left')); + expect(root).toMatch(side('safe-end', 'right')); + expect(find('.dock')[0]?.body).toMatch(/padding-block:[^;]*var\(--safe-bottom\)/); + }); });