import { TouchableOpacity, View } from "react-native"; import { Flex } from "../flex"; import { Icon } from "../icon"; import { Text } from "../text"; import { makeStyles } from "../theme"; import { useDisabledStyles } from "../theme/default-styles"; import FieldErrors from "./field-errors"; type CheckboxProps = { checked: boolean; onChange: (checked: boolean) => void; label?: string; errors?: string[]; disabled?: boolean; }; export function Checkbox({ checked, onChange, label, errors, disabled = false, }: CheckboxProps) { const styles = useStyles(); const disabledStyles = useDisabledStyles(); return ( onChange(!checked)} disabled={disabled}> {checked && ( )} {label && ( {label} )} ); } const useStyles = makeStyles((theme) => ({ iconContainer: { position: "relative", }, iconBackground: { position: "absolute", width: 16, height: 16, top: 4, left: 4, backgroundColor: theme.colors.background("light"), }, iconChecked: { color: theme.colors.get("primary", "background"), }, iconUnchecked: { color: theme.colors.select( theme.colors.get("gray", 4)!, theme.colors.get("gray", 6)! ), }, label: { color: theme.colors.foreground("auto"), }, disabled: { backgroundColor: "transparent" }, }));