From 2179b767c5716ed7e4bf49861dfe026bfe193492 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Thu, 18 Jun 2026 17:11:35 +0330 Subject: [PATCH] webview header --- src/components/ui/sticky-header.tsx | 7 ++++-- src/lib/view-paddings.ts | 35 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/components/ui/sticky-header.tsx b/src/components/ui/sticky-header.tsx index 7cf3cb0..130e0d3 100644 --- a/src/components/ui/sticky-header.tsx +++ b/src/components/ui/sticky-header.tsx @@ -3,6 +3,9 @@ import type { ReactNode } from "react"; import { useViewPaddings } from "@/hooks/use-view-paddings"; +// پدینگ بالای طراحی هدر (معادل pt-7 = 28px). فضای امن دستگاه به این اضافه می‌شود. +const DESIGN_TOP_PADDING = 28; + type StickyHeaderProps = { children: ReactNode; className?: string; @@ -16,9 +19,9 @@ export default function StickyHeader({ return (
{ + if (!raw || typeof raw !== "object") return; + const data = raw as Record; + // فقط وقتی هنوز initial_config رسمی نرسیده و این payload فضای امن دارد. + if (this.hasInitialConfig) return; + if (!data.safeArea && !data.viewInsets) return; + this.applyInitialConfig(data); + }; + + window.addEventListener("flutterConfig", (event) => { + handle((event as CustomEvent).detail); + }); + + window.addEventListener("message", (event) => { + const data = + typeof event.data === "string" + ? safeParse(event.data) + : event.data; + handle(data); + }); + } + private setupFlutterListener() { const win = window as Window & { addFlutterResponseListener?: (