Skip to content

Commit

Permalink
update safe areas logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-teddy committed Sep 12, 2024
1 parent f8d418e commit f002c0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import { getSystemInfo } from "zmp-sdk";
import { ScrollRestoration } from "./scroll-restoration";
import { useHandlePayment } from "hooks";

if (getSystemInfo().platform === "android") {
const androidSafeTop = Math.round(
(window as any).ZaloJavaScriptInterface.getStatusBarHeight() /
window.devicePixelRatio,
);
if (import.meta.env.DEV) {
document.body.style.setProperty("--zaui-safe-area-inset-top", "24px");
} else if (getSystemInfo().platform === "android") {
const statusBarHeight =
window.ZaloJavaScriptInterface?.getStatusBarHeight() ?? 0;
const androidSafeTop = Math.round(statusBarHeight / window.devicePixelRatio);
document.body.style.setProperty(
"--zaui-safe-area-inset-top",
`${androidSafeTop}px`,
`${androidSafeTop}px`
);
}

Expand Down
6 changes: 6 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ declare module "*.svg" {
const content: string;
export default content;
}

declare interface Window {
ZaloJavaScriptInterface?: {
getStatusBarHeight: () => number;
};
}
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
"removeComments": true,
"sourceMap": true,
"resolveJsonModule": true,
"baseUrl": "src"
"baseUrl": "src",
"types": [
"vite/client"
]
},
"exclude": [
"node_modules"
Expand Down

0 comments on commit f002c0e

Please sign in to comment.