mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 22:57:32 +00:00
fix(native): keep the server picker clear of Android's navigation bar
On Android the web view can report env(safe-area-inset-*) as 0 while the app draws edge to edge, so the buttons at the foot of the app's first screens sat under the three-button navigation bar and the logo under the status bar. Capacitor's SystemBars plugin writes the real insets to the page as --safe-area-inset-*; the first screens now read them as one more floor next to env() and the insets iOS measures itself. Where Capacitor lays the web view out between the bars it writes 0, and in a browser the variables are unset, so nothing changes there. Closes #3221
This commit is contained in:
@@ -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%;
|
||||
}
|
||||
|
||||
@@ -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\)/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user