Browse Source

fix: adjust safe area padding to match native najm behavior

master
mortezaei 2 weeks ago
parent
commit
94f8934f71
  1. 2
      src/app/candidate-contact/page.tsx
  2. 2
      src/app/finding-match/page.tsx
  3. 2
      src/app/intro/page.tsx
  4. 2
      src/app/new-match/page.tsx
  5. 7
      src/components/ui/sticky-header.tsx

2
src/app/candidate-contact/page.tsx

@ -28,7 +28,7 @@ export default function CandidateContactPage() {
/> />
) : null} ) : null}
<main className="-mx-[17px] flex min-h-screen flex-col px-[17px] pt-[calc(var(--safe-top)+40px)] pb-36">
<main className="-mx-[17px] flex min-h-screen flex-col px-[17px] pt-[max(40px,calc(var(--safe-top)+4px))] pb-36">
<header className="flex items-center justify-between"> <header className="flex items-center justify-between">
<NavigationButton icon="back" /> <NavigationButton icon="back" />
<h1 className="font-faminela">{t.common.appName}</h1> <h1 className="font-faminela">{t.common.appName}</h1>

2
src/app/finding-match/page.tsx

@ -29,7 +29,7 @@ export default function FindingMatchPage() {
<> <>
<PageBackground /> <PageBackground />
<main className="-mx-[17px] flex min-h-screen flex-col px-[23px] pt-[calc(var(--safe-top)+28px)] pb-5 text-center">
<main className="-mx-[17px] flex min-h-screen flex-col px-[23px] pt-[max(28px,calc(var(--safe-top)+4px))] pb-5 text-center">
<header className="-mx-[6px] flex items-center justify-between"> <header className="-mx-[6px] flex items-center justify-between">
<NavigationButton icon="back" /> <NavigationButton icon="back" />
<h1 className="font-faminela">{t.common.appName}</h1> <h1 className="font-faminela">{t.common.appName}</h1>

2
src/app/intro/page.tsx

@ -124,7 +124,7 @@ export default function Intro() {
} }
return ( return (
<div className="pt-[calc(var(--safe-top)+28px)]">
<div className="pt-[max(28px,calc(var(--safe-top)+4px))]">
{isReportSheetOpen && ( {isReportSheetOpen && (
<ReportActionsSheet onClose={() => setIsReportSheetOpen(false)} /> <ReportActionsSheet onClose={() => setIsReportSheetOpen(false)} />
)} )}

2
src/app/new-match/page.tsx

@ -194,7 +194,7 @@ export default function NewMatchPage() {
<> <>
<PageBackground /> <PageBackground />
<main className="-mx-[17px] min-h-screen h-full pb-5 text-center px-4 mt-[calc(var(--safe-top)+40px)]">
<main className="-mx-[17px] min-h-screen h-full pb-5 text-center px-4 mt-[max(40px,calc(var(--safe-top)+4px))]">
<header className="flex items-center justify-between"> <header className="flex items-center justify-between">
<NavigationButton icon="back" /> <NavigationButton icon="back" />
<h1 className="font-faminela">{t.common.appName}</h1> <h1 className="font-faminela">{t.common.appName}</h1>

7
src/components/ui/sticky-header.tsx

@ -3,8 +3,10 @@
import type { ReactNode } from "react"; import type { ReactNode } from "react";
import { useViewPaddings } from "@/hooks/use-view-paddings"; import { useViewPaddings } from "@/hooks/use-view-paddings";
// پدینگ بالای طراحی هدر (معادل pt-7 = 28px). فضای امن دستگاه به این اضافه می‌شود.
// پدینگ بالای طراحی هدر (معادل pt-7 = 28px). روی دستگاه، safe-area + 4px جایگزین
// می‌شود (مثل صفحات بومی najm)، و طراحی اصلی به‌عنوان کف برای مرورگر حفظ می‌شود.
const DESIGN_TOP_PADDING = 28; const DESIGN_TOP_PADDING = 28;
const SAFE_AREA_GAP = 4;
type StickyHeaderProps = { type StickyHeaderProps = {
children: ReactNode; children: ReactNode;
@ -16,10 +18,11 @@ export default function StickyHeader({
className, className,
}: StickyHeaderProps) { }: StickyHeaderProps) {
const { top } = useViewPaddings(); const { top } = useViewPaddings();
const paddingTop = Math.max(DESIGN_TOP_PADDING, top + SAFE_AREA_GAP);
return ( return (
<header <header
style={{ top: `-${top}px`, paddingTop: `${DESIGN_TOP_PADDING + top}px` }}
style={{ top: `-${top}px`, paddingTop: `${paddingTop}px` }}
className={[ className={[
"sticky z-30 rounded-b-[15px] bg-[linear-gradient(135deg,#E03950_0%,#FE6F82_100%)] px-[17px] pb-5", "sticky z-30 rounded-b-[15px] bg-[linear-gradient(135deg,#E03950_0%,#FE6F82_100%)] px-[17px] pb-5",
className, className,

Loading…
Cancel
Save