import { usePreferences } from '@/profile/preferences'; import * as Haptics from 'expo-haptics'; import { useCallback } from 'react'; export function useHaptics() { const { hapticFeedback } = usePreferences(); const impact = useCallback( (style: Haptics.ImpactFeedbackStyle = Haptics.ImpactFeedbackStyle.Light) => { if (hapticFeedback) Haptics.impactAsync(style); }, [hapticFeedback] ); const notification = useCallback( (type: Haptics.NotificationFeedbackType) => { if (hapticFeedback) Haptics.notificationAsync(type); }, [hapticFeedback] ); const selection = useCallback(() => { if (hapticFeedback) Haptics.selectionAsync(); }, [hapticFeedback]); return { impact, notification, selection, ImpactStyle: Haptics.ImpactFeedbackStyle, NotificationType: Haptics.NotificationFeedbackType, }; }