diff --git a/components/FavoriteList.tsx b/components/FavoriteList.tsx index 814da0f..55b3ef9 100644 --- a/components/FavoriteList.tsx +++ b/components/FavoriteList.tsx @@ -8,11 +8,13 @@ import { useNavigation } from "@react-navigation/native"; import { useTrainMenu } from "../stateBox/useTrainMenu"; import { FavoriteListItem } from "./atom/FavoriteListItem"; import { BigButton } from "./atom/BigButton"; +import { useStationList } from "@/stateBox/useStationList"; export const FavoriteList: FC = () => { const { favoriteStation } = useFavoriteStation(); const { webview } = useCurrentTrain(); const { navigate, addListener, goBack, canGoBack } = useNavigation(); const { mapsStationData: stationData } = useTrainMenu(); + const { getInjectJavascriptAddress } = useStationList(); useEffect(() => { const unsubscribe = addListener("tabPress", goToTrainMenu); @@ -38,27 +40,16 @@ export const FavoriteList: FC = () => { {favoriteStation - .filter((d) => d[0].StationMap) .map((currentStation) => { return ( { - const getStationLine = (now) => { - const returnData = Object.keys(stationData).filter((d) => { - const cache = stationData[d].findIndex( - (data) => data.Station_JP == now.Station_JP - ); - return cache != -1; - }); - return returnData[0]; - }; - const lineName = getStationLine(currentStation[0]); - - webview.current?.injectJavaScript( - `MoveDisplayStation('${lineName}_${currentStation[0].MyStation}_${currentStation[0].Station_JP}'); - document.getElementById("disp").insertAdjacentHTML("afterbegin", "
");` + const scriptString = getInjectJavascriptAddress( + currentStation[0].StationNumber ); + if (!scriptString) return; + webview.current?.injectJavaScript(scriptString); goBack(); if (canGoBack()) goBack(); }} diff --git a/components/発車時刻表/LED_Vision_Component/Header.js b/components/発車時刻表/LED_Vision_Component/Header.js index 274b9c8..dece8e8 100644 --- a/components/発車時刻表/LED_Vision_Component/Header.js +++ b/components/発車時刻表/LED_Vision_Component/Header.js @@ -1,48 +1,74 @@ import { View, Text } from "react-native"; import { useCurrentTrain } from "../../../stateBox/useCurrentTrain"; import LottieView from "lottie-react-native"; -import { Ionicons } from "@expo/vector-icons"; +import { Ionicons, AntDesign } from "@expo/vector-icons"; +import { useStationList } from "@/stateBox/useStationList"; +import { useNavigation } from "@react-navigation/native"; -export const Header = () => { - const { currentTrainLoading, setCurrentTrainLoading,getCurrentTrain } = useCurrentTrain(); - return ( - - - - - 次の列車 - - Next Train - - - {currentTrainLoading == "loading" ? ( - - ) : currentTrainLoading == "error" ? ( - { - setCurrentTrainLoading("loading"); - getCurrentTrain(); - }} - /> - ) : null} - +export const Header = ({ station }) => { + const { + currentTrainLoading, + setCurrentTrainLoading, + getCurrentTrain, + inject, + } = useCurrentTrain(); + const { getInjectJavascriptAddress } = useStationList(); + const { navigate } = useNavigation(); + return ( + + + { + navigate("positions", { screen: "Apps" }); + const script = getInjectJavascriptAddress(station.StationNumber); + inject(script); + }} + /> - ); - }; \ No newline at end of file + + + 次の列車 + + Next Train + + + {currentTrainLoading == "loading" ? ( + + ) : currentTrainLoading == "error" ? ( + { + setCurrentTrainLoading("loading"); + getCurrentTrain(); + }} + /> + ) : null} + + + ); +}; diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 14502fd..96d297b 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -222,7 +222,7 @@ export default function LED_vision(props) { marginHorizontal: width * 0.01, }} > -
+
{selectedTrain.map((d) => ( {}, getCurrentTrain: () => {}, + inject: () => {}, }; const CurrentTrainContext = createContext(initialState);