import React, { useState, useEffect, useRef } from 'react'; import {View,Text,TouchableOpacity } from 'react-native'; import {WebView} from 'react-native-webview'; import StatusbarDetect from '../StatusbarDetect'; import AsyncStorage from '@react-native-async-storage/async-storage'; import MapView,{ Marker, Geojson, PROVIDER_GOOGLE } from 'react-native-maps'; import { FontAwesome, Fontisto, Foundation, Ionicons, MaterialCommunityIcons } from '@expo/vector-icons'; var Status = StatusbarDetect(); export default function trainMenu({route:{params: {webview}}, navigation:{ navigate }}){ const [stationData,setStationData] = useState(undefined); const mapRef = useRef(); useEffect(()=>{ const HeaderConfig = {headers:{'referer':'https://train.jr-shikoku.co.jp/sp.html'}} Promise.all([ fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan', HeaderConfig).then(response => response.json()), fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima',HeaderConfig).then(response => response.json()), fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2',HeaderConfig).then(response => response.json()), fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan',HeaderConfig).then(response => response.json()), fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2',HeaderConfig).then(response => response.json()), fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku',HeaderConfig).then(response => response.json()), fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima',HeaderConfig).then(response => response.json()), fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto',HeaderConfig).then(response => response.json()) ]).then(values =>{ let stationList = {}; [stationList.yosan, stationList.uwajima, stationList.uwajima2, stationList.dosan, stationList.dosan2, stationList.koutoku, stationList.tokushima, stationList.naruto] = values; setStationData(stationList); }) },[]); return( {stationData && Object.keys(stationData).map(d=> stationData[d].map((D,index)=>{ if(!D.StationMap)return null; const latlng = D.StationMap.replace("https://www.google.co.jp/maps/place/","").split(","); if(latlng.length == 0)return null; return( { webview.current?.injectJavaScript("MoveDisplayStation('"+d+"_"+D.MyStation+"_"+D.Station_JP+"')"); navigate('Apps'); }}> ) }) ) } navigate('howto')}>使い方 Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box")}>お気に入り Linking.openURL("https://www.jr-shikoku.co.jp/e5489/")}>予約 {AsyncStorage.setItem('status', "2022/04/14");navigate('Apps');}}> 閉じる ) } const UsefulBox = (props) =>{ const { icon, backgroundColor, flex, onPressButton, children } = props; return( {children} ) }