Skip to content

Adopt shared-ui safe-area handling; WindowInsets-backed nav insets - #1008

Merged
microbit-matt-hillsdon merged 2 commits into
mainfrom
safe-area-nav-apps
Sep 2, 2026
Merged

Adopt shared-ui safe-area handling; WindowInsets-backed nav insets#1008
microbit-matt-hillsdon merged 2 commits into
mainfrom
safe-area-nav-apps

Conversation

@microbit-matt-hillsdon

@microbit-matt-hillsdon microbit-matt-hillsdon commented Aug 22, 2026

Copy link
Copy Markdown

The drawer's top-inset spacer becomes a capped negative margin now the shared Drawer reserves the inset itself. The nav-bar-side heuristic hook is deleted in favour of shared-ui's safeAreaNavSource contract, and var() fallbacks switch from 0px to the raw env() insets per that contract.

On Android, the new SafeAreaNavPlugin reports the navigation-bar portion of the window insets in CSS pixels, fed from MainActivity's existing insets listener — real WindowInsets types instead of the size heuristic, so content can flow under a camera cutout while staying clear of the nav bar. It reports zeros on the pre-140 WebView emulation path, where the native padding already applies. In every context without the plugin — the website, ?flag=android simulation, iOS (whose landscape insets are symmetric, making the distinction moot) — the env() fallbacks give the conservative behaviour.

Fixes #988

@github-actions

Copy link
Copy Markdown

Preview build will be at
https://review-createai.microbit.org/safe-area-nav-apps/

@microbit-matt-hillsdon

Copy link
Copy Markdown
Author

Reminder to self: Needs UI linking and testing on Android/iOS, especially Android with navbar — both portrait and landscape. Check the drawer too. Can be sim only.

The drawer's top-inset spacer becomes a capped negative margin now the
shared Drawer reserves the inset itself. The nav-bar-side heuristic hook
is deleted in favour of shared-ui's safeAreaNavSource contract, and the
hand-spelt env()/var() padding expressions become the new shared-ui
safeArea* spacing tokens, which bake the fallbacks in.

On Android, the new SafeAreaNavPlugin reports the navigation-bar portion
of the window insets in CSS pixels, fed from MainActivity's existing
insets listener — real WindowInsets types instead of the size heuristic,
so content can flow under a camera cutout while staying clear of the nav
bar. It reports zeros on the pre-140 WebView emulation path, where the
native padding already applies. In every context without the plugin —
the website, ?flag=android simulation, iOS (whose landscape insets are
symmetric, making the distinction moot) — the env() fallbacks give the
conservative behaviour.

Requires unreleased @microbit/ui (SharedUIProvider safeAreaNavSource and
the safeArea* tokens). The Java is not yet compiled or device-tested.
@microbit-matt-hillsdon

Copy link
Copy Markdown
Author

@microbit-grace this depends on microbit-foundation/ui#108 please could you test them together on Android?

@microbit-grace

microbit-grace commented Sep 2, 2026

Copy link
Copy Markdown

Tested on Android, looks good!

pic-7d5bcd2b-899a-47aa-a854-1e5d870b488c pic-94a24030-28a7-48ea-91a5-46fa1be2697e

@microbit-matt-hillsdon
microbit-matt-hillsdon marked this pull request as ready for review September 2, 2026 10:37
@microbit-matt-hillsdon
microbit-matt-hillsdon merged commit d85b5fa into main Sep 2, 2026
3 checks passed
@microbit-matt-hillsdon
microbit-matt-hillsdon deleted the safe-area-nav-apps branch September 2, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android buttons overlap nav / menu drawer

2 participants