import React, { useRef, useState } from "react"; import { Animated, Easing, Pressable, View } from "react-native"; import { Text } from "@/components/common/Text"; import { scaleSize } from "@/utils/scaleSize"; interface TVSaveAccountToggleProps { value: boolean; onValueChange: (value: boolean) => void; label: string; hasTVPreferredFocus?: boolean; disabled?: boolean; } export const TVSaveAccountToggle: React.FC = ({ value, onValueChange, label, hasTVPreferredFocus, disabled = false, }) => { const [isFocused, setIsFocused] = useState(false); const scale = useRef(new Animated.Value(1)).current; const glowOpacity = useRef(new Animated.Value(0)).current; const animateFocus = (focused: boolean) => { Animated.parallel([ Animated.timing(scale, { toValue: focused ? 1.02 : 1, duration: 150, easing: Easing.out(Easing.quad), useNativeDriver: true, }), Animated.timing(glowOpacity, { toValue: focused ? 0.6 : 0, duration: 150, easing: Easing.out(Easing.quad), useNativeDriver: true, }), ]).start(); }; const handleFocus = () => { setIsFocused(true); animateFocus(true); }; const handleBlur = () => { setIsFocused(false); animateFocus(false); }; return ( onValueChange(!value)} onFocus={handleFocus} onBlur={handleBlur} hasTVPreferredFocus={hasTVPreferredFocus && !disabled} disabled={disabled} focusable={!disabled} > {label} ); };