import React, { ComponentProps, FC } from "react"; import { Image, TouchableOpacity, View } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import type { TrainIconEntry } from "@/lib/trainIconEntries"; type StackVariant = "header" | "list"; type StatusIcon = ComponentProps; type Props = { entries: TrainIconEntry[]; direction?: boolean; hidden?: boolean; onPressEntry?: (entry: TrainIconEntry, index: number) => void; statusIcon?: StatusIcon; variant?: StackVariant; }; const iconSize = { header: { width: 24, height: 30, stackedWidth: 12, stackedHeight: 15, marginRight: 5, stackedMarginLeft: -10, stackedMarginTop: 10, statusSize: 24, }, list: { width: 20, height: 22, stackedWidth: 10, stackedHeight: 12, marginRight: 2, stackedMarginLeft: -8, stackedMarginTop: 8, statusSize: 18, }, } as const; export const TrainIconStack: FC = ({ entries, direction, hidden = false, onPressEntry, statusIcon, variant = "header", }) => { const size = iconSize[variant]; return ( {entries.map((entry, index) => { const trainIcon = direction ? entry.vehicle_info_img : entry.vehicle_info_right_img || entry.vehicle_info_img; if (!trainIcon) return null; const content = ( {statusIcon && hidden && ( )} ); if (!onPressEntry) { return {content}; } return ( onPressEntry(entry, index)} disabled={!entry.vehicle_info_url} > {content} ); })} ); };