import { ComponentProps, ReactNode } from "react"; import { GestureResponderEvent, Pressable, View } from "react-native"; import Animated from "react-native-reanimated"; import { IOListItemStyles, IOListItemVisualParams } from "../../core"; import { useIOTheme } from "../../context"; import { useListItemAnimation } from "../../hooks"; import { useIOFontDynamicScale } from "../../utils/accessibility"; import { WithTestID } from "../../utils/types"; import { IOIcons, Icon } from "../icons"; import { BodySmall, H6 } from "../typography"; export type ListItemInfoCopy = WithTestID<{ label: string; value: string | ReactNode; numberOfLines?: number; onPress: (event: GestureResponderEvent) => void; icon?: IOIcons; }> & Pick< ComponentProps, "accessibilityLabel" | "accessibilityHint" >; export const ListItemInfoCopy = ({ label, value, numberOfLines = 2, onPress, icon, accessibilityLabel, accessibilityHint, testID }: ListItemInfoCopy) => { const theme = useIOTheme(); const { onPressIn, onPressOut, scaleAnimatedStyle, backgroundAnimatedStyle } = useListItemAnimation(); const { dynamicFontScale, spacingScaleMultiplier, hugeFontEnabled } = useIOFontDynamicScale(); const componentValueToAccessibility = typeof value === "string" ? value : ""; const listItemAccessibilityLabel = accessibilityLabel || `${label}; ${componentValueToAccessibility}`; const foregroundColor = theme["interactiveElem-default"]; const listItemInfoCopyContent = ( <> {label} {/* Let developer using a custom component (e.g: skeleton) */} {typeof value === "string" ? (
{value}
) : ( value )} ); return ( {icon && !hugeFontEnabled && ( )} {listItemInfoCopyContent} ); };