import React from 'react'; import { View, Text, TouchableOpacity } from 'react-native'; import Icon from 'react-native-vector-icons/Ionicons'; import { useTheme } from '@theme'; import { getStyles } from './checkboxWithLabel.styles'; import { CheckboxWithLabelProps } from './checkboxWithLabel.props'; export const CheckboxWithLabel: React.FC = ({ label, options, selectedValues, onValueChange, singleSelect = false, }) => { const { theme: colors } = useTheme(); const styles = getStyles(colors); const handlePress = (id: string) => { if (singleSelect) { // Single select mode - only one can be selected onValueChange([id]); } else { // Multiple select mode - can check all if (selectedValues.includes(id)) { // Remove from selection onValueChange(selectedValues.filter(val => val !== id)); } else { // Add to selection onValueChange([...selectedValues, id]); } } }; const isSelected = (id: string) => selectedValues.includes(id); return ( {label && {label}} {options.map((option) => ( handlePress(option.id)} activeOpacity={0.7} > {isSelected(option.id) && ( )} {option.label} ))} ); };