import { Ionicons } from "@expo/vector-icons"; import type { PropsWithChildren, ReactNode } from "react"; import { TouchableOpacity, View, type ViewProps } from "react-native"; import { Text } from "../common/Text"; interface Props extends ViewProps { title?: string | null | undefined; subtitle?: string | null | undefined; subtitleColor?: "default" | "red"; value?: string | null | undefined; children?: ReactNode; iconAfter?: ReactNode; icon?: keyof typeof Ionicons.glyphMap; showArrow?: boolean; textColor?: "default" | "blue" | "red"; onPress?: () => void; disabled?: boolean; disabledByAdmin?: boolean; } export const ListItem: React.FC> = ({ title, subtitle, value, iconAfter, children, showArrow = false, icon, textColor = "default", onPress, disabled = false, disabledByAdmin = false, ...viewProps }) => { const effectiveSubtitle = disabledByAdmin ? "Disabled by admin" : subtitle; const isDisabled = disabled || disabledByAdmin; if (onPress) return ( {children} ); return ( {children} ); }; const ListItemContent = ({ title, subtitle, subtitleColor, textColor, icon, value, showArrow, iconAfter, children, }: Props) => { return ( <> {icon && ( )} {title} {subtitle && ( {subtitle} )} {value && ( {value} )} {children && {children}} {showArrow && ( )} {iconAfter} ); };