import * as React from 'react'; import { StyleProp, TouchableHighlight, View, ViewStyle } from 'react-native'; import { getElement, useColors } from '../../hook'; import { usePaletteContext } from '../../theme'; /** * List Item Component properties. */ type ListItemProps = { /** * Header element. */ header?: React.ReactElement; /** * Left element. */ tail?: React.ReactElement; /** * Left element. */ LeftName?: React.ReactElement; /** * Left element properties. */ LeftNameProps?: LeftNameProps; /** * Right element. */ RightText?: React.ReactElement; /** * Right element properties. */ RightTextProps?: RightTextProps; /** * Right element. */ RightIcon?: | React.ReactElement | React.ComponentType; /** * Right element properties. */ RightIconProps?: RightIconProps; /** * Container style for the list item component. */ containerStyle?: StyleProp; /** * Callback notification when the list item is clicked. */ onClicked?: () => void; /** * Whether to display the divider. */ enableDivider?: boolean; }; /** * Common list Item Component. * * The component is laid out left, center and right. * */ export function ListItem< LeftNameProps = any, RightTextProps = any, RightIconProps = any, >(props: ListItemProps) { const { containerStyle, LeftName, RightText, RightIcon, LeftNameProps, RightTextProps, RightIconProps, onClicked, enableDivider = true, header, tail, } = props; const { colors } = usePaletteContext(); const { getColor } = useColors({ t2: { light: colors.neutral[5], dark: colors.neutral[6], }, }); return ( {getElement(header, {})} {getElement(LeftName, LeftNameProps)} {getElement(RightText, RightTextProps)} {getElement(RightIcon, RightIconProps)} {enableDivider === true ? ( ) : null} {getElement(tail, {})} ); }