import { SerializableValue } from '@bit-ui-libs/common'; import { StyleProp, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native'; import { tw } from '../../core/tailwind'; import { RadioButtonContext, RadioButtonContextType } from './RadioButtonGroup'; interface RadioButtonProps { disabled?: boolean; onPress?: () => void; label: string; name: SerializableValue; style?: StyleProp; labelStyle?: StyleProp; } export function RadioButton(props: RadioButtonProps) { const { disabled, onPress, label, name, style, labelStyle } = props; return ( {(context?: RadioButtonContextType) => { const checked = context?.name === name; return ( { context?.onValueChange(name); onPress?.(); }} disabled={disabled} style={[tw`flex-row items-center`, style]} > {checked ? ( ) : null} {label} ); }} ); }