diff --git a/components/ActionSheetComponents/TrainMenuLineSelector.js b/components/ActionSheetComponents/TrainMenuLineSelector.js index 758c4df..5b45c5b 100644 --- a/components/ActionSheetComponents/TrainMenuLineSelector.js +++ b/components/ActionSheetComponents/TrainMenuLineSelector.js @@ -9,6 +9,7 @@ import { import ActionSheet, { SheetManager } from "react-native-actions-sheet"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useTrainMenu } from "../../stateBox/useTrainMenu"; +import { useCurrentTrain } from "../../stateBox/useCurrentTrain"; import lineColorList from "../../assets/originData/lineColorList"; import { stationIDPair } from "../../lib/getStationList2"; import { lineListPair } from "../../lib/getStationList"; @@ -19,6 +20,7 @@ export const TrainMenuLineSelector = () => { setSelectedLine, mapsStationData: stationData, } = useTrainMenu(); + const { webview } = useCurrentTrain(); const actionSheetRef = useRef(null); const insets = useSafeAreaInsets(); const platformIs = Platform.OS == "android"; @@ -52,7 +54,25 @@ export const TrainMenuLineSelector = () => { }} onPress={() => { SheetManager.hide("TrainMenuLineSelector"); - setSelectedLine(selectedLine == d ? undefined : d); + const s = selectedLine == d ? undefined : d; + if(!s) return; + setSelectedLine(s); + Object.keys(stationData).forEach((data, indexBase) => { + stationData[data].forEach((D, index) => { + if (!D.StationMap) return null; + if (s && s != data) return; + const latlng = D.StationMap.replace( + "https://www.google.co.jp/maps/place/", + "" + ).split(","); + if (latlng.length == 0) return null; + if (index == 0 ) { + webview.current + ?.injectJavaScript(`MoveDisplayStation('${data}_${D.MyStation}_${D.Station_JP}'); + document.getElementById("disp").insertAdjacentHTML("afterbegin", "
");`); + } + }); + }); }} >