diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 230a8ab..eebfef7 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -59,7 +59,7 @@ export default function LED_vision(props){ if(trainDiagram){ Object.keys(trainDiagram).forEach( key => { - if(trainDiagram[key].match(props.stationName.今.name) ){ + if(trainDiagram[key].match(props.station.Station_JP) ){ returnData[key] = trainDiagram[key]; } }); @@ -79,7 +79,7 @@ export default function LED_vision(props){ if(data.match("着")){ returnData.lastStation = data.split(",着,")[0]; } - if(data.match(props.stationName.今.name)){ + if(data.match(props.station.Station_JP)){ if(data.match(",発,")){ returnData.time = data.split(",発,")[1]; } diff --git a/components/駅名表/Sign.js b/components/駅名表/Sign.js new file mode 100644 index 0000000..dbd204c --- /dev/null +++ b/components/駅名表/Sign.js @@ -0,0 +1,88 @@ +import React, { Component, useRef, useState, useEffect } from 'react'; +import {StatusBar,View,LayoutAnimation,ScrollView,Linking,Text,TouchableOpacity } from 'react-native'; +import {widthPercentageToDP as wp, heightPercentageToDP as hp} from 'react-native-responsive-screen'; + + +export default function Sign(props){ + const {currentStation, originalStationList, oP} = props; + const getPreNextStation = (now) =>{ + const lineList = ["予讃線", "松宇線", "伊予灘線", "土讃線", "窪川線", "高徳線", "徳島線", "鳴門線"]; + let returnData; + lineList.forEach(d=>{ + let cache = originalStationList[d].findIndex( data => data.StationNumber == now.StationNumber); + if(cache != -1){ + returnData = [originalStationList[d][cache-1],originalStationList[d][cache+1]] + } + + }) + return returnData; + } + return( + !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)} */onPress={oP}> + + JR + {currentStation.map((d,index,array)=> + { + if(array.length == 1) return 20; + else if(index == 0) return 5; + else if(index == 1) return 35; + else return 20; + })()+"%",right:'10%',width:wp("10%"),height:wp("10%"),borderColor:"#2E94BB",borderWidth:parseInt("2%"),borderRadius:parseInt("100%")}} > + + {d.StationNumber} + + + )} + + + + {/* {stationName.今.LineName} */} + {currentStation[0].Station_JP} + {currentStation[0].Station_EN} + + + + + + {(()=>{return currentStation.map(currentStation =>{ + let [preStation, nexStation] = getPreNextStation(currentStation) + return( + + + {preStation && + [, + + + {preStation.StationNumber} + + , + + {preStation.Station_JP} + {preStation.Station_EN} + ]} + + + + {nexStation && + [ + {nexStation.Station_JP} + {nexStation.Station_EN} + , + + + {nexStation.StationNumber} + + , + ]} + + + ) + })[0] + + })()} + + + + + ) +} \ No newline at end of file diff --git a/menu.js b/menu.js index 4405db0..f419402 100644 --- a/menu.js +++ b/menu.js @@ -24,6 +24,7 @@ import 内子線 from './assets/四国旅客鉄道内子線.json'; import 徳島線 from './assets/四国旅客鉄道徳島線.json'; import 鳴門線 from './assets/四国旅客鉄道鳴門線.json' import LED_vision from './components/発車時刻表/LED_vidion'; +import Sign from './components/駅名表/Sign'; @@ -170,18 +171,26 @@ export default function Menu(props) { } const lineList = ["予讃線", "松宇線", "伊予灘線", "土讃線", "窪川線", "高徳線", "徳島線", "鳴門線"]; - console.log(lineList.map(d=>findStationEachLine(originalStationList[d])).find(d=>d.length > 0)) - let returnDataBase = lineList.map(d=>findStationEachLine(originalStationList[d])).find(d=>d.length > 0) + console.log(lineList.map(d=>findStationEachLine(originalStationList[d])).filter(d=>d.length > 0).reduce((pre,current) => {pre.push(...current);return pre},[])); + let returnDataBase = lineList.map(d=>findStationEachLine(originalStationList[d])).filter(d=>d.length > 0).reduce((pre,current) => {pre.push(...current);return pre},[]); + LayoutAnimation.spring() if(returnDataBase.length){ - setCurrentStation(returnDataBase); + let currentStation = currentStation == undefined ? [] : currentStation; + if(currentStation.toString() != returnDataBase.toString()){ + setCurrentStation(returnDataBase); + } } else{ setCurrentStation(undefined); + StationBoardAcSR.current?.hide() } },[location,originalStationList]) - + useEffect(()=>{ + console.log("test") + console.log(currentStation) + },[currentStation]) @@ -209,18 +218,6 @@ export default function Menu(props) { }catch(e){} }) - const getPreNextStation = (now) =>{ - const lineList = ["予讃線", "松宇線", "伊予灘線", "土讃線", "窪川線", "高徳線", "徳島線", "鳴門線"]; - let returnData; - lineList.forEach(d=>{ - let cache = originalStationList[d].findIndex( data => data.StationNumber == now.StationNumber); - if(cache != -1){ - returnData = [originalStationList[d][cache-1],originalStationList[d][cache+1]] - } - - }) - return returnData; - } return ( {Status} @@ -239,82 +236,14 @@ export default function Menu(props) { 新型コロナウイルスに関するお知らせ 列車の運行計画・混雑状況・感染症対策への取り組み - {currentStation ? - !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)} */onPress={() => {StationBoardAcSR.current?.setModalVisible()}}> - - JR - {currentStation.map((d,index,array)=> - { - if(array.length == 1) return 20; - else if(index == 0) return 5; - else if(index == 1) return 35; - else return 20; - })()+"%",right:'10%',width:wp("10%"),height:wp("10%"),borderColor:"#2E94BB",borderWidth:parseInt("2%"),borderRadius:parseInt("100%")}} > - - {d.StationNumber} - - - )} - - - - {/* {stationName.今.LineName} */} - {currentStation[0].Station_JP} - {currentStation[0].Station_EN} - - - - - - {(()=>{ - let [preStation, nexStation] = getPreNextStation(currentStation[0]) - return( - [ - - {preStation && - [, - - - {preStation.StationNumber} - - , - - {preStation.Station_JP} - {preStation.Station_EN} - ]} - , - - - {nexStation && - [ - {nexStation.Station_JP} - {nexStation.Station_EN} - , - - - {nexStation.StationNumber} - - , - ]} - ] - ) - })()} - - - - : null } - {currentStation ? - - : null} + {currentStation && StationBoardAcSR.current?.setModalVisible()} />} + {currentStation && } {JRSTraInfoEXAcSR.current?.setModalVisible()}}> 列車遅延速報EX - {/* {doFetch()}}> - 最新の情報へ更新 - */} {getTime ? getTime.toLocaleTimeString('ja-JP').split(":")[0]+":"+getTime.toLocaleTimeString('ja-JP').split(":")[1]: NaN} {LayoutAnimation.easeInEaseOut(),setLoadingDelayData(true)}}/> @@ -342,11 +271,6 @@ export default function Menu(props) { - {/* - - 準備中... - - */} @@ -497,60 +421,16 @@ export default function Menu(props) { - - {stationName ? stationName.今 ? - !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)} /* onPress={() => {StationBoardAcSR.current?.setModalVisible()}}*/> - - JR - - - {stationName.今.StationNumber} - + {currentStation && + Linking.openURL(currentStation[0].StationTimeTable)} />} + {currentStation && + + {!currentStation[0].JrHpUrl ||} flex={1} onPressButton={()=> Linking.openURL(currentStation[0].JrHpUrl)}>web} + {!currentStation[0].StationTimeTable || } flex={1} onPressButton={()=> Linking.openURL(currentStation[0].StationTimeTable)}>時刻表} + {!currentStation[0].StationMap || } flex={1} onPressButton={()=> Linking.openURL(currentStation[0].StationMap)}>GoogleMap} - - - - {stationName.今.LineName} - {stationName.今.name} - {stationName.今.en} - - - - - {stationName.前 ? : null} - - {stationName.前 ? - - - {stationName.前.StationNumber} - - : null} - - {stationName.前.name} - {stationName.前.en} - - {/* Linking.openURL(stationName.今.StationTimeTable)}> - 時刻表 - */} - - {stationName.次.name} - {stationName.次.en} - - {stationName.次.name != null ? - - - {stationName.次.StationNumber} - - : null} - {stationName.次.name != null ? : null} - - - : null : null} - - } flex={1} onPressButton={()=> !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)}>web - } flex={1} onPressButton={()=> !stationName.今.StationTimeTable || Linking.openURL(stationName.今.StationTimeTable)}>時刻表 - } flex={1} onPressButton={()=> !stationName.今.StationMap || Linking.openURL(stationName.今.StationMap)}>GoogleMap - + } +