import React, {useState, useEffect, useRef} from 'react'; import {View, Animated, Easing} from 'react-native'; import * as Palette from '../../Helpers/palette'; import Icon from '../Core/Icon'; import Color from 'color'; import Ripple from '../Core/Ripple'; const FormControl = ({ type = 'checkbox', color = Palette.blue500, size = 16, disabled = false, }: { type?: 'checkbox' | 'radio'; color?: string; size?: number; disabled?: boolean; }) => { const [selected, setSelected] = useState(false); const selectAnimation = useRef(new Animated.Value(selected ? size : 0)) .current; useEffect(() => { Animated.timing(selectAnimation, { toValue: selected ? size : 0, duration: 100, easing: Easing.cubic, }).start(); }, [selected]); return ( setSelected(!selected) : undefined} style={{padding: 10}}> {type === 'checkbox' && selected && ( )} ); }; export default FormControl;