import { Image, ImageSourcePropType, ImageURISource, StyleSheet, View } from "react-native"; import { useIOTheme } from "../../context"; import { IOListItemVisualParams, IOSelectionListItemVisualParams, IOSpacer, IOVisualCostants } from "../../core"; import { useIOFontDynamicScale } from "../../utils/accessibility"; import { WithTestID } from "../../utils/types"; import { Badge } from "../badge"; import { IOIcons, Icon } from "../icons"; import { HStack, VStack } from "../layout"; import { IOSkeleton } from "../skeleton"; import { BodySmall, LabelMini } from "../typography"; import { ModuleStatic } from "./ModuleStatic"; import { PressableModuleBase, PressableModuleBaseProps } from "./PressableModuleBase"; type LoadingProps = { isLoading: true; loadingAccessibilityLabel?: string; }; type ImageProps = | { icon: IOIcons; image?: never } | { icon?: never; image: ImageURISource | ImageSourcePropType }; type BaseProps = { isLoading?: false; title: string; subtitle?: string; badge?: Badge; } & ImageProps & PressableModuleBaseProps; type ModuleNavigationProps = LoadingProps | BaseProps; export const ModuleNavigation = (props: WithTestID) => { const theme = useIOTheme(); const { hugeFontEnabled } = useIOFontDynamicScale(); if (props.isLoading) { return ( ); } const { icon, image, title, subtitle, onPress, badge, ...pressableProps } = props; const iconComponent = icon && !hugeFontEnabled && ( ); const imageComponent = image && ( ); return ( {iconComponent ?? imageComponent} {title} {subtitle && ( {subtitle} )} {badge ? ( ) : onPress ? ( ) : null} ); }; const ModuleNavigationSkeleton = ({ loadingAccessibilityLabel }: Pick) => ( } endBlock={ } /> ); const styles = StyleSheet.create({ image: { width: IOSelectionListItemVisualParams.iconSize, height: IOSelectionListItemVisualParams.iconSize, resizeMode: "contain" } });