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 { Icon } from "../icons"; import { BodySmall, H6 } from "../typography"; export type ListItemNavAlert = WithTestID<{ value: string | ReactNode; description?: string | ReactNode; withoutIcon?: boolean; onPress: (event: GestureResponderEvent) => void; }> & Pick< ComponentProps, "accessibilityLabel" | "accessibilityHint" >; export const ListItemNavAlert = ({ value, description, withoutIcon = false, onPress, accessibilityLabel, accessibilityHint, testID }: ListItemNavAlert) => { const theme = useIOTheme(); const { onPressIn, onPressOut, scaleAnimatedStyle, backgroundAnimatedStyle } = useListItemAnimation(); const { dynamicFontScale, spacingScaleMultiplier } = useIOFontDynamicScale(); const componentValueToAccessibility = typeof value === "string" ? value : ""; const componentDescriptionToAccessibility = typeof description === "string" ? description : ""; const listItemAccessibilityLabel = accessibilityLabel ?? `${componentValueToAccessibility}; ${componentDescriptionToAccessibility}`; // TODO: Remove this when legacy look is deprecated https://pagopa.atlassian.net/browse/IOPLT-153 const listItemNavAlertContent = ( <> {/* Let developer using a custom component (e.g: skeleton) */} {typeof value === "string" ? (
{value}
) : ( value )} {description && ( <> {typeof description === "string" ? ( {description} ) : ( description )} )} ); const iconColor = theme["interactiveElem-default"]; return ( {!withoutIcon && ( )} {listItemNavAlertContent} ); };