import React, { FC } from "react"; import { View, Text, TouchableWithoutFeedback } from "react-native"; import dayjs from "dayjs"; import lineColorList from "../../../assets/originData/lineColorList"; type seTypes = | "発編" | "着編" | "通編" | "頃編" | "発" | "着" | "休編" | "通休編" | string; type currentTrainDataType = { Index: number; num: string; delay: "入線" | number | undefined; Pos: string; PosNum: number; Direction: number; Type: string; Line: string; }; type props = { i: string; index: number; stationList: { StationName: string; StationNumber: string }[][]; points: boolean; currentTrainData?: currentTrainDataType; openStationACFromEachTrainInfo?: (station: string) => void; showThrew: boolean; }; export const EachStopList: FC = ({ i, index, stationList, points, currentTrainData, openStationACFromEachTrainInfo, showThrew, }) => { const [station, se, time] = i.split(",") as [string, seTypes, string]; // 阿波池田,発,6:21 if (!showThrew) { if (se == "通過") return null; if (se == "通編") return null; if (se == "通休編") return null; } const Stations = stationList .map((a) => a.filter((d) => d.StationName == station)) .reduce((newArray, e) => newArray.concat(e), []); /*Array [ Object { "StationName": "佐古", "StationNumber": "T01", }, Object { "StationName": "佐古", "StationNumber": "B01", }, ] */ const StationNumbers = Stations && Stations.filter((d) => d.StationNumber).map((d) => d.StationNumber); const [seString, seType] = (() => { switch (se) { case "発": return ["出発", "normal"]; case "着": return ["到着", "normal"]; case "発編": return ["出発", "community"]; case "着編": return ["到着", "community"]; case "通編": return ["通過", "community"]; case "頃編": return ["頃", "community"]; case "休編": case "通休編": return ["運休", "community"]; default: return [se, "normal"]; } })(); // Array [ "T01", "B01",] // Array [ "T", "B",] // Array [ "01", "01",] const textColor = `#${seType == "community" ? "44f" : "000"}${ se == "通過" || se == "通編" || se == "通休編" ? "5" : "" }`; return ( openStationACFromEachTrainInfo && openStationACFromEachTrainInfo(station) } key={station} > {StationNumbers.map((stn, index) => ( ))} {station} {points && ( 🚊 )} {!!currentTrainData?.delay && currentTrainData?.delay != "入線" && currentTrainData?.delay != 0 && ( {time} )} {seString} ); }; const StationNumbersBox: FC<{ stn: string; se: seTypes }> = (props) => { const { stn, se } = props; const lineColor = lineColorList[stn.charAt(0)]; const hasThrew = (se == "通過" || se == "通編" || se == "通休編") ? "80" : ""; const backgroundColor = `${lineColor}${hasThrew}`; return ( {stn.charAt(0)} {"\n"} {stn.slice(1)} ); }; type StationTimeBoxType = { delay: "入線" | number | undefined; textColor: string; seType: seTypes; se: string; time: string; }; const StationTimeBox: FC = (props) => { const { delay, textColor, seType, se, time } = props; const dates = dayjs() .set("hour", parseInt(time.split(":")[0])) .set("minute", parseInt(time.split(":")[1])) .add(delay == "入線" || delay == undefined ? 0 : delay, "minute"); return ( {se.includes("通") && time == "" ? "レ" : dates.format("HH:mm")} ); };