diff --git a/src/components/mobile/GestureHandler.tsx b/src/components/mobile/GestureHandler.tsx index 809f9d88..ac0fb51a 100644 --- a/src/components/mobile/GestureHandler.tsx +++ b/src/components/mobile/GestureHandler.tsx @@ -1,5 +1,6 @@ -import React, { HTMLAttributes } from 'react'; +import React, { HTMLAttributes, useState, useEffect } from 'react'; import { useMobileGestures } from '../../hooks/useMobileGestures'; +import { ToggleLeft, ToggleRight } from 'lucide-react'; interface GestureHandlerProps extends HTMLAttributes { onSwipeLeft?: () => void; @@ -25,7 +26,34 @@ export const GestureHandler: React.FC = ({ children, ...props }) => { - const gestureProps = useMobileGestures({ + const [isIOS, setIsIOS] = useState(false); + const [gesturesEnabled, setGesturesEnabled] = useState(true); + + useEffect(() => { + // Detect iOS devices (iPhone, iPad, iPod) and iPadOS (MacIntel with touch) + const checkIOS = () => { + const userAgent = window.navigator.userAgent.toLowerCase(); + const isIOSDevice = /iphone|ipad|ipod/.test(userAgent) || + (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); + return isIOSDevice; + }; + + const isIOSBrowser = checkIOS(); + setIsIOS(isIOSBrowser); + + // Disable custom gestures by default on iOS to prevent conflicts with native swipe-to-go-back + if (isIOSBrowser) { + setGesturesEnabled(false); + } + }, []); + + const toggleGestures = (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + setGesturesEnabled(prev => !prev); + }; + + const activeGestures = gesturesEnabled ? { onSwipeLeft, onSwipeRight, onSwipeUp, @@ -34,10 +62,27 @@ export const GestureHandler: React.FC = ({ onPinchOut, onTap, swipeThreshold, - }); + } : { swipeThreshold }; + + const gestureProps = useMobileGestures(activeGestures); + + const touchActionStyle = gesturesEnabled ? 'pan-y' : 'auto'; return ( -
+
+ {isIOS && ( +
+ +
+ )} {children}
);