import { Text } from '@/components/ui/text'; import { View } from '@/components/ui/view'; import { useColor } from '@/hooks/useColor'; import { useHaptics } from '@/hooks/useHaptics'; import React from 'react'; import { Switch as RNSwitch, SwitchProps as RNSwitchProps, TextStyle, } from 'react-native'; interface SwitchProps extends RNSwitchProps { label?: string; error?: string; labelStyle?: TextStyle; haptic?: boolean; } export function Switch({ label, error, labelStyle, haptic = true, onValueChange, ...props }: SwitchProps) { const mutedColor = useColor('muted'); const primary = useColor('primary'); const danger = useColor('red'); const feedback = useHaptics(haptic); const handleValueChange = React.useCallback( (value: boolean) => { feedback(value ? 'toggle-on' : 'toggle-off'); onValueChange?.(value); }, [feedback, onValueChange] ); return ( {label && ( {label} )} {error && ( {error} )} ); }