import React, { FC, useState } from "react"; import { View, Text, TouchableOpacity } from "react-native"; import { useInterval } from "../../lib/useInterval"; import lineColorList from "../../assets/originData/lineColorList"; type StationProps = { DispNum: string; JrHpUrl: string; MyStation: string; StationMap: string; StationNumber: string | null; StationTimeTable: string; Station_EN: string; Station_JP: string; jslodApi: string; lat: number; lng: number; }; type StationNumberProps = { currentStation: StationProps[]; active: boolean; onPress: () => void; }; export const StationNumber: FC = (props) => { const { currentStation, active, onPress } = props; const [animation, setAnimation] = useState(0); const data = currentStation.filter((d) => (d.StationNumber ? true : false)); useInterval(() => { if (!data) return; setAnimation(animation + 1 < data.length ? animation + 1 : 0); }, 2000); const lineID = data[animation].StationNumber.slice(0, 1); const lineName = data[animation].StationNumber.slice(1); const size = active ? 24 : 18; return ( {active && ( )} {lineID + "\n" + lineName} ); };