import React from 'react'; import { Animated, StyleSheet, TouchableOpacity } from 'react-native'; import { Text } from '../Text'; import useTheme from '../../context/theme/useTheme'; import type { RadioButtonProps } from './types'; import { Box } from '../Box'; import createSxStyle from '../../lib/sx'; export const RadioSquare: React.FC = ({ onPress, value, label, isActive, startAdornment, endAdornment, backgroundColors, labelColors, size, sx, borderRadius: borderRadiusProp }) => { const { activeOpacity } = useTheme(); const [animationState] = React.useState({ fadeAnim: new Animated.Value(0) }); const fadeInAnimation = React.useCallback(() => { Animated.timing(animationState.fadeAnim, { toValue: 0, duration: 0, useNativeDriver: true }).start(() => { Animated.timing(animationState.fadeAnim, { toValue: 1, duration: 500, delay: 10, useNativeDriver: true }).start(); }); }, [animationState.fadeAnim]); React.useEffect(() => { if (isActive) { fadeInAnimation(); } }, [fadeInAnimation, isActive]); const onInternalPress = () => { onPress && onPress(value); }; const { height } = styles[size]; return ( {startAdornment} {label} {endAdornment} ); }; const styles = StyleSheet.create({ wrapper: { flexDirection: 'row', alignItems: 'center' }, radio: { justifyContent: 'center', alignItems: 'center' }, small: { height: 20 }, middle: { height: 35 }, large: { height: 45 } });