import React from 'react'; import {ImageStyle, StyleProp, Text, View, ViewStyle} from 'react-native'; import List from '../list'; import {WithTheme, WithThemeStyles} from '../style'; import {RadioItemPropsType} from './PropsType'; import Radio from './Radio'; import RadioItemStyles, {RadioStyle} from './style'; const ListItem = List.Item; export interface RadioItemNativeProps extends RadioItemPropsType, WithThemeStyles { style?: StyleProp; radioStyle?: StyleProp; } export default class RadioItem extends React.Component { radio: Radio | null | undefined; handleClick = () => { if (this.radio) { this.radio.handleClick(); } }; render() { const {style, radioStyle, defaultChecked, checked, disabled, children, onChange} = this.props; return ( {(styles) => { let contentDom: React.ReactElement | null = null; if (children && React.isValidElement(children)) { contentDom = {children}; } else { const contentStyle = [styles.radioItemContent, disabled ? styles.radioItemContentDisable : {}]; contentDom = ( {this.props.children} ); } const radioEl = ( (this.radio = ref)} style={radioStyle} defaultChecked={defaultChecked} checked={checked} onChange={onChange} disabled={disabled} /> ); return ( {contentDom} ); }} ); } }