import React from 'react'; import { Icon, SemanticColor, TypoIncludingEmoji } from '../../foundation'; import { Pressable, View } from 'react-native'; import { InputChipProps } from './Chip'; export function InputChip(props: InputChipProps) { const { disabled, title, selected, onPress, hideXIcon = false, onPressXIcon, showIcon = true } = props; // fixme: [2024.10 update] `hideXIcon`은 사용되지 않습니다. 서비스에서 미사용 확인될 경우 삭제 필요 const _showIcon = showIcon && !hideXIcon; const backgroundColor = (() => { if (selected === true) { return disabled === true ? SemanticColor.bg_off_white : SemanticColor.bg_secondary; } return SemanticColor.bg_primary; })(); const borderColor = (() => { if (selected) { // 정의된 내용에는 border가 없지만 border를 넣지않으면 height가 줄어들기에 border를 넣고 background color와 동일하게 설정 return backgroundColor; } return SemanticColor.border_secondary; })(); const color = disabled ? 'text_quaternary' : 'text_primary'; function handlePress() { if (onPress) { onPress(title); } } return ( {title} {selected && _showIcon && ( { onPressXIcon ? onPressXIcon() : handlePress(); }} style={{ marginLeft: 4 }} hitSlop={8}> )} ); }