import type { ReactElement } from 'react'; import React from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; import Icon from '../Icon'; import Typography from '../Typography'; import { StyledPrefixContainer, StyledSuffixContainer, StyledTitleContainer, StyledListItemContainer, } from './StyledBasicListItem'; import type { IconName } from '../Icon'; import { useTheme } from '../../theme'; interface ListItemProps { /** * Name of Icon or component to render on the left side of title. */ prefix?: IconName | React.ReactElement; /** * Name of Icon or component to render on the right side of title. */ suffix?: IconName | React.ReactElement; /** * The title of the component. */ title: string | React.ReactElement; /** * The subtile title of the component. */ subtitle?: string; /** * Whether the component is disabled. Default value is false */ disabled?: boolean; /** * Whether the component is selected. Default value is false */ selected?: boolean; /** * Additional wrapper style. */ style?: StyleProp; /** * Testing id of the component. */ testID?: string; /** * Set the handler to handle press event. */ onPress?: () => void; } const BasicListItem = ({ prefix, suffix, title, subtitle, style, testID, selected = false, disabled = false, onPress, }: ListItemProps): ReactElement => { const theme = useTheme(); return ( <> {prefix && ( {typeof prefix === 'string' ? ( ) : ( prefix )} )} {typeof title === 'string' ? ( {title} ) : ( title )} {subtitle && ( {subtitle} )} {suffix && ( {typeof suffix === 'string' ? ( ) : ( suffix )} )} ); }; export default BasicListItem;