import React, { FC, useState } from "react"; import { View, Text, TouchableOpacity } from "react-native"; import { Pagination } from "react-native-snap-carousel"; 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 StationPaginationProps = { entries: StationProps[][]; activeSlide: number; carouselRef: any; setSelectedCurrentStation: React.Dispatch>; dotButton: boolean; }; export const Paginations: FC = (props) => { const { entries, activeSlide, carouselRef, setSelectedCurrentStation, dotButton, } = props; return ( ) } dotElement={ dotButton && ( ) } /> ); }; type StationNumberMakerProps = { currentStations: StationProps[][]; setSelectedCurrentStation: React.Dispatch>; active?: boolean; index?: number; }; export const StationNumberMaker: FC = (props) => { const { currentStations, active, index, setSelectedCurrentStation } = props; return ( setSelectedCurrentStation(index)} key={currentStations[index][0].StationNumber} /> ); }; 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; const margin = active ? 3 : 6; const border = active ? 2 : 1; return ( <> {active && ( )} {lineID + "\n" + lineName} ); };