import { LinearGradient } from 'expo-linear-gradient'; import { X } from 'lucide-react-native'; import { useCallback } from 'react'; import { Pressable, type StyleProp, StyleSheet, Text, type TextStyle, View, type ViewStyle, } from 'react-native'; import { useTheme } from '@/theme/useTheme'; export type ThemeChipSelectedVariant = 'gradient' | 'accent'; export type ThemeChipProps = { label: string; value?: string; selected?: boolean; selectedVariant?: ThemeChipSelectedVariant; disabled?: boolean; showCross?: boolean; showRemoveIcon?: boolean; onSelect?: (value: string, nextSelected: boolean) => void; style?: StyleProp; textStyle?: StyleProp; testID?: string; accessibilityLabel?: string; }; const CHIP_HEIGHT = 34; export function ThemeChip({ label, value, selected = false, selectedVariant = 'accent', disabled = false, showCross, showRemoveIcon = true, onSelect, style, textStyle, testID, accessibilityLabel, }: ThemeChipProps) { const { colors, gradients, gradientDirection, borderRadius, typography } = useTheme(); const resolvedValue = value ?? label; const isGradient = selected && selectedVariant === 'gradient'; const showSelectedIcon = selected && (showCross ?? showRemoveIcon); const handlePress = useCallback(() => { if (disabled) { return; } onSelect?.(resolvedValue, !selected); }, [disabled, onSelect, resolvedValue, selected]); const containerStyle: ViewStyle = { minHeight: CHIP_HEIGHT, borderRadius: borderRadius.chip, paddingHorizontal: 14, borderWidth: 1, alignSelf: 'flex-start', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, opacity: disabled ? 0.45 : 1, }; const accentSelectedStyle: ViewStyle = { backgroundColor: colors.primarySoft, borderColor: colors.primary, }; const idleStyle: ViewStyle = { backgroundColor: colors.surface, borderColor: '#2A2A3C', }; const textColor = isGradient ? colors.textPrimary : selected ? colors.textOnPrimarySoft : colors.textPrimary; return ( {isGradient ? ( {label} {showSelectedIcon ? : null} ) : ( {label} {showSelectedIcon ? : null} )} ); } export default ThemeChip; const styles = StyleSheet.create({ root: { alignSelf: 'flex-start', }, label: { fontWeight: '600', }, });