import React from 'react'; import {ImageStyle, StyleProp, Text, TouchableWithoutFeedback, View, ViewStyle} from 'react-native'; import {WithTheme, WithThemeStyles} from '../style'; import Checkbox from './Checkbox'; import {CheckboxPropsType} from './PropsType'; import AgreeItemstyles, {CheckboxStyle} from './style'; export interface AgreeItemProps extends CheckboxPropsType, WithThemeStyles { checkboxStyle?: StyleProp; reverse?: boolean; style?: StyleProp; } export default class AgreeItem extends React.Component { checkbox: Checkbox | null | undefined; handleClick = () => { if (this.checkbox) { this.checkbox.handleClick(); } }; render() { const {style, checkboxStyle, children, disabled, checked, defaultChecked, onChange} = this.props; return ( {(styles) => { const contentDom = !children ? null : React.isValidElement(children) ? children : {children}; return ( (this.checkbox = ref)} style={[styles.agreeItemCheckbox, checkboxStyle]} disabled={disabled} checked={checked} defaultChecked={defaultChecked} onChange={onChange} /> {contentDom} ); }} ); } }