diff --git a/Top.js b/Top.js
index b320f59..1d36df5 100644
--- a/Top.js
+++ b/Top.js
@@ -15,9 +15,8 @@ import { optionData } from "./lib/stackOption.js";
import { useCurrentTrain } from "./stateBox/useCurrentTrain.js";
const Stack = createStackNavigator();
export const Top = ({ navigation }) => {
- const webview = useRef();
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
- const { getCurrentTrain } = useCurrentTrain();
+ const { webview, getCurrentTrain } = useCurrentTrain();
//地図用
const [mapsStationData, setMapsStationData] = useState(undefined);
diff --git a/components/ActionSheetComponents/EachTrainInfo/LongHeader.js b/components/ActionSheetComponents/EachTrainInfo/LongHeader.js
index 95f23f9..0410b53 100644
--- a/components/ActionSheetComponents/EachTrainInfo/LongHeader.js
+++ b/components/ActionSheetComponents/EachTrainInfo/LongHeader.js
@@ -7,6 +7,7 @@ export const LongHeader = ({
currentPosition,
nearTrainIDList,
openTrainInfo,
+ navigate,
}) => {
return (
);
diff --git a/components/ActionSheetComponents/EachTrainInfo/ShortHeader.js b/components/ActionSheetComponents/EachTrainInfo/ShortHeader.js
index a289e24..1f68b85 100644
--- a/components/ActionSheetComponents/EachTrainInfo/ShortHeader.js
+++ b/components/ActionSheetComponents/EachTrainInfo/ShortHeader.js
@@ -7,6 +7,7 @@ export const ShortHeader = ({
currentPosition,
nearTrainIDList,
openTrainInfo,
+ navigate,
}) => {
return (
);
diff --git a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js
index fdb5426..978bd78 100644
--- a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js
+++ b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js
@@ -1,7 +1,10 @@
-import React from "react";
+import React, { useState, useEffect } from "react";
import { View, TouchableOpacity, useWindowDimensions } from "react-native";
import { StateBox } from "./StateBox";
import { useDeviceOrientationChange } from "../../../stateBox/useDeviceOrientationChange";
+import { getStationList2 } from "../../../lib/getStationList2";
+import { useCurrentTrain } from "../../../stateBox/useCurrentTrain";
+import { SheetManager } from "react-native-actions-sheet";
export const TrainDataView = ({
currentTrainData,
@@ -9,10 +12,16 @@ export const TrainDataView = ({
nearTrainIDList,
openTrainInfo,
mode = 0,
+ navigate,
}) => {
const { width, height } = useWindowDimensions();
const { isLandscape } = useDeviceOrientationChange();
-
+ const { webview, getCurrentTrain } = useCurrentTrain();
+ const [mapsStationData, setMapsStationData] = useState(undefined);
+ useEffect(() => {
+ getStationList2().then(setMapsStationData);
+ }, []);
+ const onLine = !!currentPosition?.toString().length;
return (
-
+ {
+ const test = [];
+ Object.keys(mapsStationData).forEach((d) => {
+ mapsStationData[d].forEach((x) => {
+ if (x.StationNumber == currentPosition[0])
+ test.push({ line: d, station: x });
+ });
+ });
+ if (!test.length) return;
+ webview.current?.injectJavaScript(
+ `MoveDisplayStation('${test[0].line}_${test[0].station.MyStation}_${test[0].station.Station_JP}')`
+ );
+ navigate("Apps");
+ SheetManager.hide("EachTrainInfo");
+ }}
+ >
+
+
+
)
}
@@ -335,6 +336,7 @@ export const EachTrainInfoCore = ({
currentPosition={currentPosition}
nearTrainIDList={nearTrainIDList}
openTrainInfo={openTrainInfo}
+ navigate={navigate}
/>
)
}
diff --git a/stateBox/useCurrentTrain.js b/stateBox/useCurrentTrain.js
index 944b37c..9e181d8 100644
--- a/stateBox/useCurrentTrain.js
+++ b/stateBox/useCurrentTrain.js
@@ -1,8 +1,15 @@
-import React, { createContext, useContext, useState, useEffect } from "react";
+import React, {
+ createContext,
+ useContext,
+ useState,
+ useEffect,
+ useRef,
+} from "react";
import { HeaderConfig } from "../lib/HeaderConfig";
import useInterval from "../lib/useInterval";
const initialState = {
+ webview: {},
currentTrain: [],
setCurrentTrain: () => {},
currentTrainLoading: "loading",
@@ -40,9 +47,12 @@ export const CurrentTrainProvider = ({ children }) => {
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
+
+ const webview = useRef();
return (