import { useTheme } from '@utils/styles/ThemeManager' import { StyleConstants } from '@utils/styles/constants' import React from 'react' import { Pressable, View } from 'react-native' import Icon from './Icon' import { ParseEmojis } from './Parse' import CustomText from './Text' import haptics from './haptics' export interface Props { title?: string multiple?: boolean options: { selected: boolean; content: string }[] setOptions: React.Dispatch> disabled?: boolean invalid?: boolean } const Selections: React.FC = ({ title, multiple = false, options, setOptions, disabled = false, invalid = false }) => { const { colors } = useTheme() const isSelected = (index: number) => options[index].selected ? multiple ? 'check-square' : 'check-circle' : multiple ? 'square' : 'circle' return ( {title ? ( ) : null} {options.map((option, index) => ( { if (multiple) { haptics('Light') setOptions( options.map((o, i) => (i === index ? { ...o, selected: !o.selected } : o)) ) } else { if (!option.selected) { haptics('Light') setOptions( options.map((o, i) => { if (i === index) { return { ...o, selected: true } } else { return { ...o, selected: false } } }) ) } } }} > ))} ) } export default Selections