import React, { useMemo } from 'react'; import { I18nManager, ActivityIndicator, TouchableOpacity, Switch, StyleSheet, Pressable, PressableProps } from 'react-native'; import { ListItem as RNElementsListItem, Avatar } from 'react-native-elements'; // Replace with actual import paths import { useTheme } from './themes'; // Update the type for the props interface ListItemProps { rightIcon?: any; leftAvatar?: React.Component; containerStyle?: object; Component?: typeof React.Component | typeof PressableWrapper; bottomDivider?: boolean; topDivider?: boolean; testID?: string; onPress?: () => void; onLongPress?: () => void; hideChevron?: boolean; disabled?: boolean; switch?: object; // Define more specific type if needed leftIcon?: any; // Define more specific type if needed title: string; subtitle?: string; subtitleNumberOfLines?: number; rightTitle?: string; rightTitleStyle?: object; isLoading?: boolean; chevron?: boolean; checkmark?: boolean; } export class PressableWrapper extends React.Component { render() { return ; } } export class TouchableOpacityWrapper extends React.Component { render() { return ; } } const ListItem: React.FC = React.memo(props => { const { colors } = useTheme(); const stylesHook = StyleSheet.create({ title: { color: props.disabled ? colors.buttonDisabledTextColor : colors.foregroundColor, fontSize: 16, fontWeight: '500', writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr', }, subtitle: { flexWrap: 'wrap', writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr', color: colors.alternativeTextColor, fontWeight: '400', fontSize: 14, }, rightTitleContainer: { flex: 1, }, containerStyle: { backgroundColor: colors.background, }, }); const memoizedSwitchProps = useMemo(() => { return props.switch ? { ...props.switch } : undefined; }, [props.switch]); return ( {props.leftIcon && } {props.leftAvatar && props.leftAvatar} {props.title} {props.subtitle && ( {props.subtitle} )} {props.rightTitle && ( {props.rightTitle} )} {props.isLoading ? ( ) : ( <> {props.chevron && } {props.rightIcon && } {props.switch && } {props.checkmark && } )} ); }); export default ListItem;