import React from 'react' import { View, Text, StyleSheet, TouchableWithoutFeedback, StyleProp, ViewStyle } from 'react-native'; import Icon from '../Icon' type Props = { value?: string, label?: string, checked?: boolean, onPress?: (value: string) => void, onChange?: (value: boolean) => void, disabled?: boolean, activeIcon?: React.ReactElement<{}>, inactiveIcon?: React.ReactElement<{}>, rightIcon?: boolean, checkedColor?: string, style?: StyleProp; children?: any, iconSize?: number } const Checkbox = ({ onPress, onChange, disabled, activeIcon, inactiveIcon, rightIcon, checkedColor = "#2376b7", iconSize = 20, ...rest }: Props) => { return ( onPress(rest.value || '')) || onChange && (() => onChange(!rest.checked))}> {rightIcon && {rest.children || rest.label}} {!rest.checked ? (inactiveIcon ? inactiveIcon : ) : (activeIcon ? activeIcon : )} {!rightIcon && {rest.children || rest.label}} ) } const styles = StyleSheet.create({ radio: { flexDirection: 'row', alignItems: 'center', minWidth: 80, paddingBottom: 8, }, checkBox: { borderWidth: 2, borderColor: '#333', overflow: 'hidden', }, disabled: { opacity: 0.5, }, ml4: { marginLeft: 4, } }) export default Checkbox