"use client"; import { useEffect, useRef } from "react"; import { cn } from "@/lib/utils"; import { useTouchGesture } from "@/hooks/useTouchGesture"; interface BottomSheetProps { isOpen: boolean; onClose: () => void; title?: string; children: React.ReactNode; className?: string; } /** * iOS-style bottom sheet. * - Slides up from the bottom of the screen * - Swipe down on the drag handle or sheet body to close * - Tap backdrop to close * - Locks body scroll while open */ export function BottomSheet({ isOpen, onClose, title, children, className }: BottomSheetProps) { const sheetRef = useRef(null); const swipeHandlers = useTouchGesture({ onSwipeDown: onClose }); // Lock body scroll while open useEffect(() => { if (isOpen) { document.body.style.overflow = "hidden"; } else { document.body.style.overflow = ""; } return () => { document.body.style.overflow = ""; }; }, [isOpen]); // Close on Escape useEffect(() => { if (!isOpen) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; document.addEventListener("keydown", onKey); return () => document.removeEventListener("keydown", onKey); }, [isOpen, onClose]); return ( <> {/* Backdrop */}