import type { ReactNode } from 'react'; import { View, Pressable, Animated, type StyleProp, type ViewStyle } from 'react-native'; import { Icon } from '../../components/wui-icon'; import { Image } from '../../components/wui-image'; import { LoadingSpinner } from '../../components/wui-loading-spinner'; import useAnimatedValue from '../../hooks/useAnimatedValue'; import { useTheme } from '../../hooks/useTheme'; import type { IconType } from '../../utils/TypesUtil'; import { IconBox } from '../wui-icon-box'; import styles from './styles'; const AnimatedPressable = Animated.createAnimatedComponent(Pressable); export interface ListItemProps { icon?: IconType; iconVariant?: 'blue' | 'overlay'; variant?: 'image' | 'icon'; imageSrc?: string; imageHeaders?: Record; chevron?: boolean; disabled?: boolean; loading?: boolean; onPress?: () => void; children?: ReactNode; style?: StyleProp; testID?: string; } export function ListItem({ children, icon, variant, imageSrc, imageHeaders, iconVariant = 'blue', chevron, loading, disabled, onPress, style, testID }: ListItemProps) { const Theme = useTheme(); const { animatedValue, setStartValue, setEndValue } = useAnimatedValue( Theme['gray-glass-002'], Theme['gray-glass-010'] ); function visualTemplate() { if (variant === 'image' && imageSrc) { return ( ); } else if (variant === 'icon' && icon) { const iconColor = iconVariant === 'blue' ? 'accent-100' : 'fg-200'; const borderColor = iconVariant === 'blue' ? 'accent-glass-005' : 'gray-glass-005'; return ( ); } return null; } function rightTemplate() { if (loading) { return ; } else if (chevron) { return ; } return null; } return ( {visualTemplate()} {children} {rightTemplate()} ); }