Add safeAreaInsets support to all example apps (#202)
Apply host-provided safe area insets as padding on main containers across all examples. This ensures content doesn't render under system UI elements like phone notches. React apps use `useState` + `onhostcontextchanged` handler with initial fetch via `getHostContext()` in `useEffect`. Vanilla JS apps apply padding in the handler and invoke it after `connect()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
97990b6b28
commit
79670b4dcd
1 changed files with 267 additions and 48 deletions
|
|
@ -47,7 +47,22 @@
|
|||
}
|
||||
};
|
||||
|
||||
function handleHostContextChanged(ctx) {
|
||||
if (ctx.safeAreaInsets) {
|
||||
document.body.style.paddingTop = `${ctx.safeAreaInsets.top}px`;
|
||||
document.body.style.paddingRight = `${ctx.safeAreaInsets.right}px`;
|
||||
document.body.style.paddingBottom = `${ctx.safeAreaInsets.bottom}px`;
|
||||
document.body.style.paddingLeft = `${ctx.safeAreaInsets.left}px`;
|
||||
}
|
||||
}
|
||||
|
||||
app.onhostcontextchanged = handleHostContextChanged;
|
||||
|
||||
await app.connect();
|
||||
const ctx = app.getHostContext();
|
||||
if (ctx) {
|
||||
handleHostContextChanged(ctx);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in a new issue