From 67d2bf6c98f192e4a308383dd08032dbbb972cbf Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 5 Jul 2025 10:49:30 +0000 Subject: [PATCH] =?UTF-8?q?LED=E3=81=AE=E6=9E=A0=E3=81=AB=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=83=85=E5=A0=B1=E3=82=B8=E3=83=A3=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FavoriteList.tsx | 21 +--- .../LED_Vision_Component/Header.js | 112 +++++++++++------- components/発車時刻表/LED_vidion.js | 2 +- stateBox/useCurrentTrain.js | 1 + 4 files changed, 77 insertions(+), 59 deletions(-) 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);