// SwipeToDelete — iOS Mail style swipe-to-reveal-delete. function SwipeToDelete({ onDelete, children }) { const startX = React.useRef(null); const currentX = React.useRef(0); const [offset, setOffset] = React.useState(0); const [swiping, setSwiping] = React.useState(false); const [deleting, setDeleting] = React.useState(false); const DELETE_THRESHOLD = 80; const onTouchStart = (e) => { startX.current = e.touches[0].clientX; currentX.current = offset; setSwiping(true); }; const onTouchMove = (e) => { if (startX.current == null) return; const dx = e.touches[0].clientX - startX.current; setOffset(Math.min(0, Math.max(-120, currentX.current + dx))); }; const onTouchEnd = () => { startX.current = null; setSwiping(false); if (offset < -DELETE_THRESHOLD) { setOffset(-90); } else { setOffset(0); } }; const handleDelete = () => { setDeleting(true); setOffset(-400); setTimeout(() => onDelete && onDelete(), 300); }; if (deleting) return
; // Only show the red delete zone when actually swiped const showDelete = offset < -5; return (