From 99dbada0c2a5a1e552f300c107c41911e094fb78 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 31 Aug 2025 13:28:49 +0000 Subject: [PATCH 01/17] =?UTF-8?q?useInterval=E3=82=92=E5=88=9D=E6=9C=9Fsto?= =?UTF-8?q?p=E3=82=82=E5=8F=AF=E8=83=BD=E3=81=AA=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/useInterval.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/useInterval.ts b/lib/useInterval.ts index ff3b3b2..db5e23d 100644 --- a/lib/useInterval.ts +++ b/lib/useInterval.ts @@ -24,6 +24,8 @@ export const useInterval = (fn: Fn, interval: number, autostart = true) => { useEffect(() => { if (autostart) { setState("RUNNING"); + }else{ + setState("STOPPED"); } }, [autostart]); useEffect(() => { From 0c64f7af4528dbc14d5f91f187ece5d3516210d7 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 31 Aug 2025 15:43:25 +0000 Subject: [PATCH 02/17] =?UTF-8?q?=E5=88=97=E8=BB=8A=E8=B5=B0=E8=A1=8C?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E3=81=B8=E3=81=AE=E3=82=B8=E3=83=A3=E3=83=B3?= =?UTF-8?q?=E3=83=97=E6=A9=9F=E8=83=BD=E3=82=92useCurrentTrain=E3=81=B8?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfoCore.js | 116 +++++------------- .../StationTrainPositionButton.tsx | 16 +-- components/Apps/WebView.jsx | 8 +- stateBox/useCurrentTrain.js | 116 ++++++++++++++++++ 4 files changed, 163 insertions(+), 93 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index 710ceee..db31578 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -42,7 +42,8 @@ export const EachTrainInfoCore = ({ from, navigate, }) => { - const { currentTrain } = useCurrentTrain(); + const { currentTrain, getCurrentStationData, getPosition } = + useCurrentTrain(); const { originalStationList, stationList } = useStationList(); const { allTrainDiagram: trainList, allCustomTrainData } = useAllTrainDiagram(); @@ -50,13 +51,10 @@ export const EachTrainInfoCore = ({ const [currentTrainData, setCurrentTrainData] = useState(); useEffect(() => { - if (!currentTrain.length) return; - setCurrentTrainData( - checkDuplicateTrainData( - currentTrain.filter((d) => d.num == data.trainNum), - stationList - ) - ); + const stationData = getCurrentStationData(data.trainNum); + if (stationData) { + setCurrentTrainData(stationData); + } }, [currentTrain, data.trainNum]); useEffect(() => { @@ -100,7 +98,7 @@ export const EachTrainInfoCore = ({ useEffect(() => { const stopStationList = trainData.map((i) => { const [station, se, time] = i.split(","); - if(se == "通編") setHaveThrough(true); + if (se == "通編") setHaveThrough(true); return stationList.map((a) => a.filter((d) => d.StationName == station)); }); const allThroughStationList = stopStationList.map((i, index, array) => { @@ -205,7 +203,10 @@ export const EachTrainInfoCore = ({ setHeadStation([]); setTailStation([]); if (!TD) { - const specialTrainActualIDs = searchSpecialTrain(data.trainNum, trainList); + const specialTrainActualIDs = searchSpecialTrain( + data.trainNum, + trainList + ); setTrueTrainID(specialTrainActualIDs || []); setTrainData([]); return; @@ -247,71 +248,8 @@ export const EachTrainInfoCore = ({ }, [trainData, data]); useEffect(() => { - //currentTrainData.Pos = "鴨川~端岡"; //test - if (!currentTrainData) return; - if (!currentTrainData?.Pos) return; - if (currentTrainData?.Pos.match("~")) { - const pos = currentTrainData?.Pos.replace("(下り)", "") - .replace("(上り)", "") - .replace("(徳島線)", "") - .replace("(高徳線)", "") - .split("~"); - const direction = parseInt(currentTrainData?.Direction) || 0; - if (pos[0] == "児島" && pos[1] == "宇多津") { - setCurrentPosition(["M12", "Y09"]); - return; - } else if (pos[1] == "児島" && pos[0] == "宇多津") { - setCurrentPosition(["Y09", "M12"]); - return; - } else if (pos[0] == "伊予若宮" && pos[1] == "伊予白滝") { - setCurrentPosition(["S18", "S14"]); - return; - } else if (pos[0] == "伊予白滝" && pos[1] == "伊予若宮") { - setCurrentPosition(["S14", "S18"]); - return; - } else if (pos[0] == "伊予大洲" && pos[1] == "伊予若宮") { - setCurrentPosition(["U14", "U14"]); - return; - } else if (pos[0] == "伊予若宮" && pos[1] == "伊予大洲") { - setCurrentPosition(["U14", "U14"]); - return; - } - const currentPosID = Object.keys(originalStationList).map((key) => { - let firstStation = false; - let firstStationID = ""; - let secondStation = false; - let secondStationID = ""; - originalStationList[key].forEach((station) => { - if (station.Station_JP === pos[0]) { - firstStation = true; - firstStationID = station.StationNumber; - } - if (station.Station_JP === pos[1]) { - secondStation = true; - secondStationID = station.StationNumber; - } - }); - if (firstStation && secondStation) { - return [firstStationID, secondStationID]; - } else return false; - }); - const currentPos = currentPosID.filter((d) => d != false)[0]; - if (currentPos) { - setCurrentPosition(direction == 0 ? currentPos.reverse() : currentPos); - } else if (direction == 0) { - setCurrentPosition([ - getStationID(pos[1], stationList), - getStationID(pos[0], stationList), - ]); - } else { - setCurrentPosition([ - getStationID(pos[0], stationList), - getStationID(pos[1], stationList), - ]); - } - } else { - setCurrentPosition([getStationID(currentTrainData?.Pos, stationList)]); - } + const position = getPosition(currentTrainData); + if (position) setCurrentPosition(position); }, [currentTrainData]); useEffect(() => { @@ -393,7 +331,12 @@ export const EachTrainInfoCore = ({ containerProps={{ style: { maxHeight: isLandscape ? height - 94 : (height / 100) * 70, - backgroundColor:getTrainType(customTrainDataDetector(data.trainNum, allCustomTrainData).type).data === "notService" ? "#777777ff" :"white" + backgroundColor: + getTrainType( + customTrainDataDetector(data.trainNum, allCustomTrainData).type + ).data === "notService" + ? "#777777ff" + : "white", }, }} shortHeader={ @@ -424,7 +367,13 @@ export const EachTrainInfoCore = ({ /> } > - {getTrainType(customTrainDataDetector(data.trainNum, allCustomTrainData).type).data === "notService" &&この列車には乗車できません。} + {getTrainType( + customTrainDataDetector(data.trainNum, allCustomTrainData).type + ).data === "notService" && ( + + この列車には乗車できません。 + + )} {headStation.length != 0 && headStation.map((i, index) => showHeadStation.findIndex((d) => d == index) == -1 ? ( @@ -473,10 +422,11 @@ export const EachTrainInfoCore = ({ borderWidth: 1, margin: 10, borderRadius: 5, - alignItems: "center", backgroundColor:"#ffffffc2" + alignItems: "center", + backgroundColor: "#ffffffc2", }} > - + Twitterで検索 @@ -494,12 +444,14 @@ export const EachTrainInfoCore = ({ currentTrainData, openStationACFromEachTrainInfo, showThrew, - key: i + "-stop" }} + key={i + "-stop"} /> ) )} - 時刻が斜体,青色になっている時刻はコミュニティで追加されている独自データです。 + + 時刻が斜体,青色になっている時刻はコミュニティで追加されている独自データです。 + {tailStation.length != 0 && tailStation.map(({ station, dia }, index) => showTailStation.findIndex((d) => d == index) == -1 ? ( @@ -540,7 +492,7 @@ export const EachTrainInfoCore = ({ flexDirection: "row", borderBottomWidth: 1, borderBottomColor: "#f0f0f0", - backgroundColor:"#ffffffc2", + backgroundColor: "#ffffffc2", flex: 1, }} > diff --git a/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx b/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx index dcc0a84..dfe3d5a 100644 --- a/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx +++ b/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx @@ -1,6 +1,5 @@ import { FC } from "react"; import { TouchableOpacity, View, Text, Linking } from "react-native"; -import { useStationList } from "@/stateBox/useStationList"; import { useCurrentTrain } from "@/stateBox/useCurrentTrain"; import AntDesign from "react-native-vector-icons/AntDesign"; type Props = { @@ -10,10 +9,7 @@ type Props = { }; export const StationTrainPositionButton: FC = (props) => { const { stationNumber, onExit, navigate } = props; - const { - inject, - } = useCurrentTrain(); - const { getInjectJavascriptAddress } = useStationList(); + const { setInjectData } = useCurrentTrain(); return ( = (props) => { alignContent: "center", alignItems: "center", margin: 2, - flex: 1 + flex: 1, + }} + onLongPress={() => { + navigate("positions", { screen: "Apps" }); + setInjectData({ type: "station", stationNumber, fixed: true }); + onExit(); }} onPress={() => { navigate("positions", { screen: "Apps" }); - const script = getInjectJavascriptAddress(stationNumber); - inject(script); + setInjectData({ type: "station", stationNumber, fixed: false }); onExit(); }} > diff --git a/components/Apps/WebView.jsx b/components/Apps/WebView.jsx index 9cd2c11..92aceb5 100644 --- a/components/Apps/WebView.jsx +++ b/components/Apps/WebView.jsx @@ -23,7 +23,8 @@ export const AppsWebView = ({ openStationACFromEachTrainInfo }) => { const { navigate } = useNavigation(); const { favoriteStation } = useFavoriteStation(); const { isLandscape } = useDeviceOrientationChange(); - const { originalStationList, stationList, getInjectJavascriptAddress } = useStationList(); + const { originalStationList, stationList, getInjectJavascriptAddress } = + useStationList(); const { setSelectedLine, mapsStationData: stationData, @@ -51,7 +52,6 @@ export const AppsWebView = ({ openStationACFromEachTrainInfo }) => { break; } }; - const onMessage = (event) => { const { data } = event.nativeEvent; /** @@ -137,7 +137,9 @@ export const AppsWebView = ({ openStationACFromEachTrainInfo }) => { if (!stationData) return () => {}; if (!originalStationList) return () => {}; if (favoriteStation.length < 1) return () => {}; - const string = getInjectJavascriptAddress(favoriteStation[0][0].StationNumber); + const string = getInjectJavascriptAddress( + favoriteStation[0][0].StationNumber + ); if (!string) return () => {}; webview?.current.injectJavaScript(string); once = true; diff --git a/stateBox/useCurrentTrain.js b/stateBox/useCurrentTrain.js index d5f7cef..96b3899 100644 --- a/stateBox/useCurrentTrain.js +++ b/stateBox/useCurrentTrain.js @@ -8,6 +8,9 @@ import React, { import { HeaderConfig } from "../lib/HeaderConfig"; import useInterval from "../lib/useInterval"; +import { useStationList } from "./useStationList"; +import { checkDuplicateTrainData } from "@/lib/checkDuplicateTrainData"; +import { getStationID } from "@/lib/eachTrainInfoCoreLib/getStationData"; const initialState = { webview: {}, currentTrain: [], @@ -16,6 +19,11 @@ const initialState = { setCurrentTrainLoading: () => {}, getCurrentTrain: () => {}, inject: (i) => {}, + fixedPosition: null, + setFixedPosition: () => {}, + setInjectData: (e) => {}, + getCurrentStationData: (e) => {}, + getPosition: (e) => {}, }; const CurrentTrainContext = createContext(initialState); @@ -27,6 +35,111 @@ export const useCurrentTrain = () => { export const CurrentTrainProvider = ({ children }) => { const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 } const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading + + const { getInjectJavascriptAddress, stationList, originalStationList } = + useStationList(); + + const [fixedPosition, setFixedPosition] = useState(null); + const [_, setIntervalState] = useInterval( + () => { + if (!webview.current) return; + inject(fixedPosition); + }, + 60000, + false + ); + useEffect(() => { + if (fixedPosition) { + setIntervalState.start(); + } else { + setIntervalState.stop(); + } + }, [fixedPosition]); + const getPosition = (currentTrainData) => { + console.log(currentTrainData); + //currentTrainData.Pos = "鴨川~端岡"; //test + if (!currentTrainData) return; + if (!currentTrainData?.Pos) return; + if (currentTrainData?.Pos.match("~")) { + const pos = currentTrainData?.Pos.replace("(下り)", "") + .replace("(上り)", "") + .replace("(徳島線)", "") + .replace("(高徳線)", "") + .split("~"); + const direction = parseInt(currentTrainData?.Direction) || 0; + if (pos[0] == "児島" && pos[1] == "宇多津") { + return ["M12", "Y09"]; + } else if (pos[1] == "児島" && pos[0] == "宇多津") { + return ["Y09", "M12"]; + } else if (pos[0] == "伊予若宮" && pos[1] == "伊予白滝") { + return ["S18", "S14"]; + } else if (pos[0] == "伊予白滝" && pos[1] == "伊予若宮") { + return ["S14", "S18"]; + } else if (pos[0] == "伊予大洲" && pos[1] == "伊予若宮") { + return ["U14", "U14"]; + } else if (pos[0] == "伊予若宮" && pos[1] == "伊予大洲") { + return ["U14", "U14"]; + } + const currentPosID = Object.keys(originalStationList).map((key) => { + let firstStation = false; + let firstStationID = ""; + let secondStation = false; + let secondStationID = ""; + originalStationList[key].forEach((station) => { + if (station.Station_JP === pos[0]) { + firstStation = true; + firstStationID = station.StationNumber; + } + if (station.Station_JP === pos[1]) { + secondStation = true; + secondStationID = station.StationNumber; + } + }); + if (firstStation && secondStation) { + return [firstStationID, secondStationID]; + } else return false; + }); + const currentPos = currentPosID.filter((d) => d != false)[0]; + if (currentPos) { + return direction == 0 ? currentPos.reverse() : currentPos; + } else if (direction == 0) { + return [ + getStationID(pos[1], stationList), + getStationID(pos[0], stationList), + ]; + } else { + return [ + getStationID(pos[0], stationList), + getStationID(pos[1], stationList), + ]; + } + } else { + return [getStationID(currentTrainData?.Pos, stationList)]; + } + }; + const setInjectData = ({ type, number, fixed }) => { + if (type === "station") { + const script = getInjectJavascriptAddress(number); + inject(script); + if (fixed) { + setFixedPosition(script); + } + } else if (type === "station") { + const script = getInjectJavascriptAddress(number); + inject(script); + if (fixed) { + setFixedPosition(script); + } + } + }; + const getCurrentStationData = (e) => { + //e:trainNumber + if (!currentTrain.length) return; + return checkDuplicateTrainData( + currentTrain.filter((d) => d.num == e), + stationList + ); + }; const getCurrentTrain = () => { fetch("https://n8n.haruk.in/webhook/c501550c-7d1b-4e50-927b-4429fe18931a") .then((response) => response.json()) @@ -88,6 +201,9 @@ export const CurrentTrainProvider = ({ children }) => { setCurrentTrainLoading, getCurrentTrain, inject, + setInjectData, + getCurrentStationData, + getPosition, }} > {children} From b37b40b6a8625c761dfb40b40c48cd1202ece80e Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 31 Aug 2025 16:15:12 +0000 Subject: [PATCH 03/17] =?UTF-8?q?=E5=A4=89=E6=95=B0=E3=81=AE=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9=E3=82=92=E3=83=9F=E3=82=B9=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stateBox/useCurrentTrain.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/stateBox/useCurrentTrain.js b/stateBox/useCurrentTrain.js index 96b3899..81c594a 100644 --- a/stateBox/useCurrentTrain.js +++ b/stateBox/useCurrentTrain.js @@ -39,11 +39,21 @@ export const CurrentTrainProvider = ({ children }) => { const { getInjectJavascriptAddress, stationList, originalStationList } = useStationList(); - const [fixedPosition, setFixedPosition] = useState(null); + const [fixedPosition, setFixedPosition] = useState({ + type: null, + value: null, + }); const [_, setIntervalState] = useInterval( () => { if (!webview.current) return; - inject(fixedPosition); + if (fixedPosition.type == "station") { + alert("stationに移動"); + const script = getInjectJavascriptAddress(fixedPosition.value); + inject(script); + } + else if(fixedPosition.type == "train"){ + + } }, 60000, false @@ -117,15 +127,16 @@ export const CurrentTrainProvider = ({ children }) => { return [getStationID(currentTrainData?.Pos, stationList)]; } }; - const setInjectData = ({ type, number, fixed }) => { + const setInjectData = ({ type, value, fixed }) => { if (type === "station") { - const script = getInjectJavascriptAddress(number); + const script = getInjectJavascriptAddress(value); + console.log(value); inject(script); if (fixed) { - setFixedPosition(script); + setFixedPosition({ type, value: value }); } } else if (type === "station") { - const script = getInjectJavascriptAddress(number); + const script = getInjectJavascriptAddress(value); inject(script); if (fixed) { setFixedPosition(script); From eda1d10c0ce66d5c46e67657389437e5481bcfbb Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 31 Aug 2025 16:15:32 +0000 Subject: [PATCH 04/17] =?UTF-8?q?=E5=A4=89=E6=95=B0=E3=81=AE=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9=E3=82=92=E3=83=9F=E3=82=B9=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationDeteilView/StationTrainPositionButton.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx b/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx index dfe3d5a..5140c67 100644 --- a/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx +++ b/components/ActionSheetComponents/StationDeteilView/StationTrainPositionButton.tsx @@ -23,12 +23,12 @@ export const StationTrainPositionButton: FC = (props) => { }} onLongPress={() => { navigate("positions", { screen: "Apps" }); - setInjectData({ type: "station", stationNumber, fixed: true }); + setInjectData({ type: "station", value:stationNumber, fixed: true }); onExit(); }} onPress={() => { navigate("positions", { screen: "Apps" }); - setInjectData({ type: "station", stationNumber, fixed: false }); + setInjectData({ type: "station", value: stationNumber, fixed: false }); onExit(); }} > From ac11117fd661d45cdf6ddef07d81945edc7c4fcd Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 1 Sep 2025 11:55:40 +0000 Subject: [PATCH 05/17] =?UTF-8?q?=E6=9A=AB=E5=AE=9A=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfo/TrainDataView.tsx | 29 ++++----- components/Apps.js | 13 +++- stateBox/useCurrentTrain.js | 59 ++++++++++++------- 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.tsx b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.tsx index 739ed3f..cacd548 100644 --- a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.tsx +++ b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.tsx @@ -25,7 +25,7 @@ export const TrainDataView = ({ const { width, height } = useWindowDimensions(); const { isLandscape } = useDeviceOrientationChange(); - const { inject } = useCurrentTrain(); + const { setInjectData } = useCurrentTrain(); const { allCustomTrainData } = useAllTrainDiagram(); const [mapsStationData, setMapsStationData] = useState(undefined); @@ -150,27 +150,18 @@ export const TrainDataView = ({ { + if (!onLine) return; + setInjectData({ type:"train", value:currentTrainData?.num, fixed:true}); + navigate("positions", { screen: "Apps" }); + SheetManager.hide("EachTrainInfo"); + }} onPress={() => { if (!onLine) return; - const test = []; - Object.keys(mapsStationData).forEach((d) => { - mapsStationData[d].forEach((x) => { - if (x.StationNumber == currentPosition[0]) - test.push({ line: d, station: x }); - }); - if (currentPosition[0] == "M12") { - test.push({ - line: "seto", - station: { Station_JP: "児島", MyStation: "0" }, - }); - } - }); - if (!test.length) return; + setInjectData({ type: "station", value: currentPosition[0], fixed: false }); + navigate("positions", { screen: "Apps" }); - inject( - `MoveDisplayStation('${test[0].line}_${test[0].station.MyStation}_${test[0].station.Station_JP}');document.getElementById("disp").insertAdjacentHTML("afterbegin", "
");` - ); SheetManager.hide("EachTrainInfo"); }} > diff --git a/components/Apps.js b/components/Apps.js index fb5f985..769b17a 100644 --- a/components/Apps.js +++ b/components/Apps.js @@ -4,6 +4,7 @@ import { Platform, useWindowDimensions, LayoutAnimation, + Text, } from "react-native"; import Constants from "expo-constants"; import * as Updates from "expo-updates"; @@ -30,7 +31,7 @@ var Status = StatusbarDetect(); */ const top = Platform.OS == "ios" ? Constants.statusBarHeight : 0; export default function Apps() { - const { webview } = useCurrentTrain(); + const { webview, fixedPosition, setFixedPosition } = useCurrentTrain(); const { height, width } = useWindowDimensions(); const { navigate } = useNavigation(); const { isLandscape } = useDeviceOrientationChange(); @@ -125,6 +126,16 @@ export default function Apps() { }} /> )} + {fixedPosition.type && ( + { + setFixedPosition({ type: null, value: null }); + }} + > + {fixedPosition.type}: {fixedPosition.value} + + )} + {mapSwitch == "true" ? ( Updates.reloadAsync()} diff --git a/stateBox/useCurrentTrain.js b/stateBox/useCurrentTrain.js index 81c594a..3684382 100644 --- a/stateBox/useCurrentTrain.js +++ b/stateBox/useCurrentTrain.js @@ -47,15 +47,25 @@ export const CurrentTrainProvider = ({ children }) => { () => { if (!webview.current) return; if (fixedPosition.type == "station") { - alert("stationに移動"); const script = getInjectJavascriptAddress(fixedPosition.value); inject(script); - } - else if(fixedPosition.type == "train"){ + } else if (fixedPosition.type == "train") { + const currentTrain = getCurrentStationData(fixedPosition.value); + const values = getPosition(currentTrain); + if (!values) return; + if (values[0] == "M12" || values[1] == "M12") { + const script = getInjectJavascriptAddress("M12"); + inject(script); + return; + } + const script = getInjectJavascriptAddress( + values[values.length == 2 ? currentTrain.Direction : 0] + ); + inject(script); } }, - 60000, + 5000, //60000, false ); useEffect(() => { @@ -66,7 +76,6 @@ export const CurrentTrainProvider = ({ children }) => { } }, [fixedPosition]); const getPosition = (currentTrainData) => { - console.log(currentTrainData); //currentTrainData.Pos = "鴨川~端岡"; //test if (!currentTrainData) return; if (!currentTrainData?.Pos) return; @@ -127,22 +136,6 @@ export const CurrentTrainProvider = ({ children }) => { return [getStationID(currentTrainData?.Pos, stationList)]; } }; - const setInjectData = ({ type, value, fixed }) => { - if (type === "station") { - const script = getInjectJavascriptAddress(value); - console.log(value); - inject(script); - if (fixed) { - setFixedPosition({ type, value: value }); - } - } else if (type === "station") { - const script = getInjectJavascriptAddress(value); - inject(script); - if (fixed) { - setFixedPosition(script); - } - } - }; const getCurrentStationData = (e) => { //e:trainNumber if (!currentTrain.length) return; @@ -151,6 +144,28 @@ export const CurrentTrainProvider = ({ children }) => { stationList ); }; + const setInjectData = ({ type, value, fixed }) => { + if (type === "station") { + const script = getInjectJavascriptAddress(value); + console.log(value); + inject(script); + } else if (type === "train") { + const currentTrain = getCurrentStationData(value); + const values = getPosition(currentTrain); + if (!values) return; + let script; + if (values[0] == "M12" || values[1] == "M12") { + script = getInjectJavascriptAddress("M12"); + } else { + const valuesIndex = values.length == 2 ? currentTrain.Direction : 0; + script = getInjectJavascriptAddress(values[valuesIndex]); + } + inject(script); + } + if (fixed) { + setFixedPosition({ type, value }); + } + }; const getCurrentTrain = () => { fetch("https://n8n.haruk.in/webhook/c501550c-7d1b-4e50-927b-4429fe18931a") .then((response) => response.json()) @@ -215,6 +230,8 @@ export const CurrentTrainProvider = ({ children }) => { setInjectData, getCurrentStationData, getPosition, + fixedPosition, + setFixedPosition, }} > {children} From 620be8b58e7b06af7ee1cc26b53354c937fe24c2 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 1 Sep 2025 15:28:05 +0000 Subject: [PATCH 06/17] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E5=85=A8=E4=BD=93=E7=9A=84=E3=81=AB=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Apps.js | 9 +- components/Apps/FixedPositionBox.tsx | 269 ++++++++++++++++++++++++++ components/Apps/MapsButton.tsx | 1 + components/Apps/ReloadButton.tsx | 1 + components/Menu/StationPagination.tsx | 15 +- lib/getStringConfig.ts | 2 +- stateBox/useCurrentTrain.js | 2 +- stateBox/useStationList.tsx | 22 ++- 8 files changed, 293 insertions(+), 28 deletions(-) create mode 100644 components/Apps/FixedPositionBox.tsx diff --git a/components/Apps.js b/components/Apps.js index 769b17a..f49720d 100644 --- a/components/Apps.js +++ b/components/Apps.js @@ -24,6 +24,7 @@ import { MapsButton } from "./Apps/MapsButton"; import { ReloadButton } from "./Apps/ReloadButton"; import { LandscapeBackButton } from "./Apps/LandscapeBackButton"; import { useStationList } from "../stateBox/useStationList"; +import { FixedPositionBox } from "./Apps/FixedPositionBox"; /* import StatusbarDetect from '../StatusbarDetect'; var Status = StatusbarDetect(); */ @@ -127,13 +128,7 @@ export default function Apps() { /> )} {fixedPosition.type && ( - { - setFixedPosition({ type: null, value: null }); - }} - > - {fixedPosition.type}: {fixedPosition.value} - + )} {mapSwitch == "true" ? ( diff --git a/components/Apps/FixedPositionBox.tsx b/components/Apps/FixedPositionBox.tsx new file mode 100644 index 0000000..703a3a6 --- /dev/null +++ b/components/Apps/FixedPositionBox.tsx @@ -0,0 +1,269 @@ +import lineColorList from "@/assets/originData/lineColorList"; +import { getStationID } from "@/lib/eachTrainInfoCoreLib/getStationData"; +import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; +import { useCurrentTrain } from "@/stateBox/useCurrentTrain"; +import { useStationList, StationProps } from "@/stateBox/useStationList"; +import { useEffect, useState } from "react"; +import { Text, TouchableOpacity, View, Image, Platform } from "react-native"; +import { customTrainDataDetector } from "../custom-train-data"; +import { getStringConfig, typeID } from "@/lib/getStringConfig"; +import { getTrainType } from "@/lib/getTrainType"; +import Constants from "expo-constants"; + +export const FixedPositionBox = () => { + const { fixedPosition, setFixedPosition } = useCurrentTrain(); + + return ( + + + {fixedPosition.type === "station" && ( + + )} + {fixedPosition.type === "train" && ( + + )} + + + ); +}; + +export const FixedStation = ({ stationID }) => { + const { fixedPosition, setFixedPosition } = useCurrentTrain(); + const { getStationDataFromId } = useStationList(); + const [station, setStation] = useState([]); + useEffect(() => { + const data = getStationDataFromId(stationID); + setStation(data); + }, [stationID]); + console.log(station); + const lineColor = + station.length > 0 + ? lineColorList[station[0]?.StationNumber.slice(0, 1)] + : "white"; + return ( + { + setFixedPosition({ type: null, value: null }); + }} + > + + + {station.map((s) => { + if (s.StationNumber === null) return null; + return ( + + + {s.StationNumber?.slice(0, 1)} + + + {s.StationNumber?.slice(1)} + + + ); + })} + + + {station[0]?.Station_JP} + + + + 駅情報固定中 + + + + + + 次:15:00 快速マリン 岡山 + + + + ); +}; + +export const FixedTrain = ({ trainID }) => { + const { fixedPosition, setFixedPosition, currentTrain } = useCurrentTrain(); + const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram(); + + const getTrainDataFromCurrentTrain = (trainNum: string) => { + const customTrainData = customTrainDataDetector( + trainNum, + allCustomTrainData + ); + switch (customTrainData.type) { + case "Normal": + case "OneMan": + const currentTrainData = currentTrain.filter((a) => a.num == trainNum); + if (currentTrainData.length == 0) return customTrainData; + else if (currentTrainData[0].Type.includes("rapid:")) { + const typeText = currentTrainData[0].Type.split(":"); + const returnData = { + type: "Rapid", + trainName: typeText[1].replace("\r", ""), + trainIcon: null, + trainNumDistance: null, + info: "", + }; + return returnData; + } + return customTrainData; + default: + return customTrainData; + } + }; + const [train, setTrain] = useState<{ + Index: string; + num: string; + delay: string; + Pos: string; + PosNum: string; + Direction: number; + Type: string; + Line: string; + }>(null); + const [customData, setCustomData] = useState<{ + ToData: string; + TrainNumber: string; + id: string; + img: string; + isWanman: boolean; + trainName: string; + trainNumDistance: number; + type: typeID; + viaData: string; + info?: string; + uwasa?: string; + }>(getTrainDataFromCurrentTrain(trainID)); + useEffect(() => { + setCustomData(getTrainDataFromCurrentTrain(trainID)); + }, [currentTrain, trainID]); + useEffect(() => { + currentTrain.forEach((d) => { + if (d.num == trainID) setTrain(d); + }); + }, [trainID, currentTrain]); + + const [ToData, setToData] = useState(""); + useEffect(() => { + if (customData.ToData && customData.ToData != "") { + setToData(customData.ToData); + } else { + const base = allTrainDiagram[trainID]; + if (!base) return; + const data = base.split("#"); + setToData(data[data.length - 2].split(",")[0]); + } + }, [customData, train]); + const [stringConfig, setStringConfig] = useState([, ,]); + useEffect(() => { + const x = getStringConfig(customData.type, customData.TrainNumber); + setStringConfig(x); + }, [customData]); + return ( + { + setFixedPosition({ type: null, value: null }); + }} + > + + + + + + {stringConfig[0]} + + {ToData}行 + + + + + 列車情報追跡中 + 次は どこですか + + + + ); +}; diff --git a/components/Apps/MapsButton.tsx b/components/Apps/MapsButton.tsx index 66e7501..60cc2ac 100644 --- a/components/Apps/MapsButton.tsx +++ b/components/Apps/MapsButton.tsx @@ -37,6 +37,7 @@ export const MapsButton: FC = ({ onPress }) => { alignSelf: "center", alignItems: "center", display: mapSwitch == "true" ? "flex" : "none", + zIndex: 1000, }, text: { textAlign: "center", diff --git a/components/Apps/ReloadButton.tsx b/components/Apps/ReloadButton.tsx index 05655c4..16a5dad 100644 --- a/components/Apps/ReloadButton.tsx +++ b/components/Apps/ReloadButton.tsx @@ -38,6 +38,7 @@ export const ReloadButton:FC = ({ onPress, right }) => { alignSelf: "center", alignItems: "center", display: mapSwitch, + zIndex: 1000, }, text: { textAlign: "center", diff --git a/components/Menu/StationPagination.tsx b/components/Menu/StationPagination.tsx index dbbbd2c..8eee662 100644 --- a/components/Menu/StationPagination.tsx +++ b/components/Menu/StationPagination.tsx @@ -3,20 +3,7 @@ import { View, Text, TouchableOpacity } from "react-native"; import { useInterval } from "../../lib/useInterval"; import lineColorList from "../../assets/originData/lineColorList"; - -type StationProps = { - DispNum: string; - JrHpUrl: string; - MyStation: string; - StationMap: string; - StationNumber: string | null; - StationTimeTable: string; - Station_EN: string; - Station_JP: string; - jslodApi: string; - lat: number; - lng: number; -}; +import { StationProps } from "@/stateBox/useStationList"; type StationNumberProps = { currentStation: StationProps[]; active: boolean; diff --git a/lib/getStringConfig.ts b/lib/getStringConfig.ts index 327c533..54f84a9 100644 --- a/lib/getStringConfig.ts +++ b/lib/getStringConfig.ts @@ -1,4 +1,4 @@ -type typeID = +export type typeID = | "Normal" | "OneMan" | "Rapid" diff --git a/stateBox/useCurrentTrain.js b/stateBox/useCurrentTrain.js index 3684382..ac1152b 100644 --- a/stateBox/useCurrentTrain.js +++ b/stateBox/useCurrentTrain.js @@ -20,7 +20,7 @@ const initialState = { getCurrentTrain: () => {}, inject: (i) => {}, fixedPosition: null, - setFixedPosition: () => {}, + setFixedPosition: (e) => {}, setInjectData: (e) => {}, getCurrentStationData: (e) => {}, getPosition: (e) => {}, diff --git a/stateBox/useStationList.tsx b/stateBox/useStationList.tsx index 73219b2..c08e7a2 100644 --- a/stateBox/useStationList.tsx +++ b/stateBox/useStationList.tsx @@ -10,12 +10,24 @@ import { getStationList, lineList_LineWebID, } from "../lib/getStationList"; - +export type StationProps = { + DispNum: string; + JrHpUrl: string; + MyStation: string; + StationMap: string; + StationNumber: string | null; + StationTimeTable: string; + Station_EN: string; + Station_JP: string; + jslodApi: string; + lat: number; + lng: number; +}; type initialStateType = { - originalStationList: any[][]; - setOriginalStationList: React.Dispatch>; - getStationDataFromName: (id: string) => any[]; - getStationDataFromId: (id: string) => any[]; + originalStationList: StationProps[][]; + setOriginalStationList: React.Dispatch>; + getStationDataFromName: (id: string) => StationProps[]; + getStationDataFromId: (id: string) => StationProps[]; getStationDataFromNameBase: (name: string) => any[]; stationList: any[]; getInjectJavascriptAddress: (StationNumber: string) => string; From 74054b107d2046c723cb1dd37a4ad1ffc5bc13b0 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 7 Sep 2025 09:09:06 +0000 Subject: [PATCH 07/17] =?UTF-8?q?=E5=88=97=E8=BB=8A=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E3=81=AE=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Apps/FixedPositionBox.tsx | 249 +++++++++++++++++++---- components/駅名表/Sign.js | 4 +- components/駅名表/StationNumberMaker.tsx | 42 ++-- lib/getTrainType.ts | 4 +- stateBox/useTrainMenu.js | 2 +- 5 files changed, 238 insertions(+), 63 deletions(-) diff --git a/components/Apps/FixedPositionBox.tsx b/components/Apps/FixedPositionBox.tsx index 703a3a6..1568d96 100644 --- a/components/Apps/FixedPositionBox.tsx +++ b/components/Apps/FixedPositionBox.tsx @@ -9,6 +9,8 @@ import { customTrainDataDetector } from "../custom-train-data"; import { getStringConfig, typeID } from "@/lib/getStringConfig"; import { getTrainType } from "@/lib/getTrainType"; import Constants from "expo-constants"; +import { trainPosition } from "@/lib/trainPositionTextArray"; +import { StationNumberMaker } from "../駅名表/StationNumberMaker"; export const FixedPositionBox = () => { const { fixedPosition, setFixedPosition } = useCurrentTrain(); @@ -19,20 +21,18 @@ export const FixedPositionBox = () => { position: "absolute", top: Platform.OS == "ios" ? Constants.statusBarHeight : 0, borderRadius: 5, - zIndex: 500, + zIndex: 1500, width: "100%", height: 50, flexDirection: "row", }} > - {fixedPosition.type === "station" && ( )} {fixedPosition.type === "train" && ( )} - ); }; @@ -161,14 +161,14 @@ export const FixedTrain = ({ trainID }) => { } }; const [train, setTrain] = useState<{ - Index: string; - num: string; - delay: string; - Pos: string; - PosNum: string; - Direction: number; - Type: string; - Line: string; + Pos?: string; + Direction?: number; + Index?: number; + Line?: string; + PosNum?: number; + Type?: string; + delay?: string | number; + num?: string; }>(null); const [customData, setCustomData] = useState<{ ToData: string; @@ -208,62 +208,221 @@ export const FixedTrain = ({ trainID }) => { const x = getStringConfig(customData.type, customData.TrainNumber); setStringConfig(x); }, [customData]); + + const { getStationDataFromName } = useStationList(); + const [station, setStation] = useState([]); + useEffect(() => { + const data = getStationDataFromName(ToData); + setStation(data); + }, [ToData]); + const lineColor = + station.length > 0 + ? lineColorList[station[0]?.StationNumber.slice(0, 1)] + : "black"; + let firstText = ""; + let secondText = ""; + let marginText = ""; + let externalText = ""; + const { isBetween, Pos: PosData } = trainPosition(train); + if (isBetween === true) { + const { from, to } = PosData; + firstText = from; + secondText = to; + marginText = "→"; + } else { + const { Pos } = PosData; + if (Pos !== "") { + firstText = Pos; + } + } return ( { setFixedPosition({ type: null, value: null }); }} > - - - + + - + - {stringConfig[0]} - - {ToData}行 + + {stringConfig[0]} + + {customData.trainName && ( + 6 ? 9 : 14, + color: "white", + maxWidth: 70, + textAlignVertical: "center", + }} + > + {customData.trainName} + + )} + + + + + + + + {ToData}行 + + + - - 列車情報追跡中 - 次は どこですか + > + + 次は 新居浜 + + + + + + + + + 現在地: + + + {marginText == "→" ? firstText + marginText + secondText : firstText} + + ); }; diff --git a/components/駅名表/Sign.js b/components/駅名表/Sign.js index f7a3929..2424a7c 100644 --- a/components/駅名表/Sign.js +++ b/components/駅名表/Sign.js @@ -197,9 +197,7 @@ export default function Sign(props) { source={require("../../assets/StationSign.json")} /> )} - + diff --git a/components/駅名表/StationNumberMaker.tsx b/components/駅名表/StationNumberMaker.tsx index bd38e40..b5466ae 100644 --- a/components/駅名表/StationNumberMaker.tsx +++ b/components/駅名表/StationNumberMaker.tsx @@ -1,10 +1,16 @@ -import React from "react"; +import React, { FC } from "react"; import { Text, View } from "react-native"; import { useWindowDimensions } from "react-native"; import lineColorList from "../../assets/originData/lineColorList"; +import { StationProps } from "@/stateBox/useStationList"; -export const StationNumberMaker = (props) => { - const { currentStation, isMatsuyama } = props; +type props = { + currentStation: StationProps[]; + useEach?: boolean; + singleSize?: number; +}; +export const StationNumberMaker: FC = (props) => { + const { currentStation, useEach = false, singleSize } = props; const { width } = useWindowDimensions(); const getTop = (array: number[], index: number) => { if (array.length == 1) return 20; @@ -12,7 +18,7 @@ export const StationNumberMaker = (props) => { else if (index == 1) return 35; else return 20; }; - return currentStation + return <>{currentStation .filter((d) => (d.StationNumber ? true : false)) .map((d, index, array) => { const lineID = d.StationNumber.slice(0, 1); @@ -20,29 +26,41 @@ export const StationNumberMaker = (props) => { return ( {lineID + "\n" + lineName} @@ -50,5 +68,5 @@ export const StationNumberMaker = (props) => { ); - }); + })} }; diff --git a/lib/getTrainType.ts b/lib/getTrainType.ts index 99450f9..cdc53e3 100644 --- a/lib/getTrainType.ts +++ b/lib/getTrainType.ts @@ -51,7 +51,7 @@ export const getTrainType: getTrainType = (nameString, whiteMode) => { }; case "Rapid": case "OneManRapid": - return { color: whiteMode ? "#00b8d8cc" : "aqua", name: "快速", data: "rapid" }; + return { color: whiteMode ? "#00a0bdff" : "aqua", name: "快速", data: "rapid" }; case "LTDEXP": return { color: "red", name: "特急", data: "express" }; case "NightLTDEXP": @@ -66,7 +66,7 @@ export const getTrainType: getTrainType = (nameString, whiteMode) => { case "Party": return { color: "#ff7300ff", name: "団体臨時", data: "normal" }; case "Freight": - return { color: "#00869ecc", name: "貨物", data: "notService" }; + return { color: "#007488ff", name: "貨物", data: "notService" }; case "Forwarding": return { color: "#727272cc", name: "回送", data: "notService" }; case "FreightForwarding": diff --git a/stateBox/useTrainMenu.js b/stateBox/useTrainMenu.js index f169fc0..347a8c7 100644 --- a/stateBox/useTrainMenu.js +++ b/stateBox/useTrainMenu.js @@ -94,7 +94,7 @@ export const TrainMenuProvider = ({ children }) => { //列車アイコンスイッチ ASCore({ k: "iconSwitch", s: setIconSetting, d: "true", u: true }); //地図スイッチ - ASCore({ k: "mapSwitch", s: setMapSwitch, d: "false", u: true }); + ASCore({ k: "mapSwitch", s: setMapSwitch, d: "true", u: true }); //駅メニュースイッチ ASCore({ k: "stationSwitch", s: setStationMenu, d: "true", u: true }); //列車メニュースイッチ From 7b9cbf963e31fc243187e80a8ecfbc9f8a0b3cec Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 7 Sep 2025 09:51:26 +0000 Subject: [PATCH 08/17] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE?= =?UTF-8?q?=E6=95=B4=E7=90=86=E3=81=A8=E3=83=87=E3=83=BC=E3=82=BF=E3=81=AE?= =?UTF-8?q?=E4=BE=9B=E7=B5=A6=E5=85=83=E3=81=AE=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Apps/FixedPositionBox.tsx | 56 +++++++++++++++------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/components/Apps/FixedPositionBox.tsx b/components/Apps/FixedPositionBox.tsx index 1568d96..1bd30fa 100644 --- a/components/Apps/FixedPositionBox.tsx +++ b/components/Apps/FixedPositionBox.tsx @@ -131,7 +131,7 @@ export const FixedStation = ({ stationID }) => { }; export const FixedTrain = ({ trainID }) => { - const { fixedPosition, setFixedPosition, currentTrain } = useCurrentTrain(); + const { fixedPosition, setFixedPosition, currentTrain,getCurrentStationData } = useCurrentTrain(); const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram(); const getTrainDataFromCurrentTrain = (trainNum: string) => { @@ -187,9 +187,10 @@ export const FixedTrain = ({ trainID }) => { setCustomData(getTrainDataFromCurrentTrain(trainID)); }, [currentTrain, trainID]); useEffect(() => { - currentTrain.forEach((d) => { - if (d.num == trainID) setTrain(d); - }); + const stationData = getCurrentStationData(trainID); + if (stationData) { + setTrain(stationData); + } }, [trainID, currentTrain]); const [ToData, setToData] = useState(""); @@ -219,22 +220,6 @@ export const FixedTrain = ({ trainID }) => { station.length > 0 ? lineColorList[station[0]?.StationNumber.slice(0, 1)] : "black"; - let firstText = ""; - let secondText = ""; - let marginText = ""; - let externalText = ""; - const { isBetween, Pos: PosData } = trainPosition(train); - if (isBetween === true) { - const { from, to } = PosData; - firstText = from; - secondText = to; - marginText = "→"; - } else { - const { Pos } = PosData; - if (Pos !== "") { - firstText = Pos; - } - } return ( { > - + + + + ); +}; + +const CurrentPositionBox = ({train,lineColor})=>{ + let firstText = ""; + let secondText = ""; + let marginText = ""; + let externalText = ""; + const { isBetween, Pos: PosData } = trainPosition(train); + if (isBetween === true) { + const { from, to } = PosData; + firstText = from; + secondText = to; + marginText = "→"; + } else { + const { Pos } = PosData; + if (Pos !== "") { + firstText = Pos; + } + } + return { {marginText == "→" ? firstText + marginText + secondText : firstText} - - - ); -}; + ; +} \ No newline at end of file From 5d9a7e185f6f96619b59bb2ccfed37792eb0f356 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 7 Sep 2025 14:29:54 +0000 Subject: [PATCH 09/17] =?UTF-8?q?=E5=B7=A6=E5=81=B4=E3=81=AE=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E4=B8=80=E9=80=9A=E3=82=8A=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Apps/FixedPositionBox.tsx | 246 ++++++++++++++++++++------- 1 file changed, 189 insertions(+), 57 deletions(-) diff --git a/components/Apps/FixedPositionBox.tsx b/components/Apps/FixedPositionBox.tsx index 1bd30fa..679363a 100644 --- a/components/Apps/FixedPositionBox.tsx +++ b/components/Apps/FixedPositionBox.tsx @@ -11,6 +11,8 @@ import { getTrainType } from "@/lib/getTrainType"; import Constants from "expo-constants"; import { trainPosition } from "@/lib/trainPositionTextArray"; import { StationNumberMaker } from "../駅名表/StationNumberMaker"; +import { lineListPair, stationIDPair } from "@/lib/getStationList"; +import { findReversalPoints } from "@/lib/eachTrainInfoCoreLib/findReversalPoints"; export const FixedPositionBox = () => { const { fixedPosition, setFixedPosition } = useCurrentTrain(); @@ -131,7 +133,13 @@ export const FixedStation = ({ stationID }) => { }; export const FixedTrain = ({ trainID }) => { - const { fixedPosition, setFixedPosition, currentTrain,getCurrentStationData } = useCurrentTrain(); + const { + fixedPosition, + setFixedPosition, + currentTrain, + getCurrentStationData, + getPosition, + } = useCurrentTrain(); const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram(); const getTrainDataFromCurrentTrain = (trainNum: string) => { @@ -193,24 +201,133 @@ export const FixedTrain = ({ trainID }) => { } }, [trainID, currentTrain]); + const { getStationDataFromName, stationList, originalStationList } = + useStationList(); + + const [trainDataWidhThrough, setTrainDataWithThrough] = useState( + [] + ); + + useEffect(() => { + const trainData = allTrainDiagram[trainID]?.split("#"); + if (!trainData) return; + //let haveThrough = false; + // + const stopStationList = trainData.map((i) => { + const [station, se, time] = i.split(","); + //if (se == "通編") setHaveThrough(true); + return stationList.map((a) => a.filter((d) => d.StationName == station)); + }); + const allThroughStationList = stopStationList.map((i, index, array) => { + let allThroughStation = []; + if (index == array.length - 1) return; + + const firstItem = array[index]; + const secondItem = array[index + 1]; + let betweenStationLine = ""; + let baseStationNumberFirst = ""; + let baseStationNumberSecond = ""; + Object.keys(stationIDPair).forEach((d, index2, array) => { + if (!d) return; + const haveFirst = firstItem[index2]; + const haveSecond = secondItem[index2]; + if (haveFirst.length && haveSecond.length) { + betweenStationLine = d; + baseStationNumberFirst = haveFirst[0].StationNumber; + baseStationNumberSecond = haveSecond[0].StationNumber; + } + }); + if (!betweenStationLine) return; + let reverse = false; + originalStationList[ + lineListPair[stationIDPair[betweenStationLine]] + ].forEach((d) => { + if ( + d.StationNumber > baseStationNumberFirst && + d.StationNumber < baseStationNumberSecond + ) { + allThroughStation.push(`${d.Station_JP},通過,`); + //setHaveThrough(true); + reverse = false; + } else { + if ( + d.StationNumber < baseStationNumberFirst && + d.StationNumber > baseStationNumberSecond + ) { + allThroughStation.push(`${d.Station_JP},通過,`); + //setHaveThrough(true); + reverse = true; + } + } + }); + if (reverse) allThroughStation.reverse(); + return allThroughStation; + }); + let mainArray = [...trainData]; + let indexs = 0; + trainData.forEach((d, index, array) => { + indexs = indexs + 1; + if (!allThroughStationList[index]) return; + if (allThroughStationList[index].length == 0) return; + mainArray.splice(indexs, 0, ...allThroughStationList[index]); + indexs = indexs + allThroughStationList[index].length; + }); + setTrainDataWithThrough(mainArray); + }, [allTrainDiagram, stationList, trainID]); + const stopStationIDList = trainDataWidhThrough.map((i) => { + const [station, se, time] = i.split(","); + const Stations = stationList.map((a) => + a.filter((d) => d.StationName == station) + ); + const StationNumbers = + Stations && + Stations.reduce((newArray, e) => { + return newArray.concat(e); + }, []).map((d) => d.StationNumber); + return StationNumbers; + }); + const [currentPosition, setCurrentPosition] = useState([]); + + useEffect(() => { + const position = getPosition(train); + if (position) setCurrentPosition(position); + }, [train]); + + const [nextStationData, setNextStationData] = useState([]); + useEffect(() => { + const points = findReversalPoints(currentPosition, stopStationIDList); + if (!points) return; + if (points.length == 0) return; + let searchCount = points.findIndex((d) => d == true); + for (searchCount; searchCount < points.length; searchCount++) { + const nextPos = trainDataWidhThrough[searchCount]; + if (nextPos) { + const [station, se, time] = nextPos.split(","); + if (se.includes("通")) continue; + else { + setNextStationData(getStationDataFromName(station)); + break; + } + } + } + }, [currentPosition, trainDataWidhThrough]); const [ToData, setToData] = useState(""); useEffect(() => { if (customData.ToData && customData.ToData != "") { setToData(customData.ToData); } else { - const base = allTrainDiagram[trainID]; - if (!base) return; - const data = base.split("#"); - setToData(data[data.length - 2].split(",")[0]); + if (trainDataWidhThrough.length == 0) return; + setToData( + trainDataWidhThrough[trainDataWidhThrough.length - 2].split(",")[0] + ); } - }, [customData, train]); + }, [customData, trainDataWidhThrough]); const [stringConfig, setStringConfig] = useState([, ,]); useEffect(() => { const x = getStringConfig(customData.type, customData.TrainNumber); setStringConfig(x); }, [customData]); - const { getStationDataFromName } = useStationList(); const [station, setStation] = useState([]); useEffect(() => { const data = getStationDataFromName(ToData); @@ -271,7 +388,7 @@ export const FixedTrain = ({ trainID }) => { style={{ fontSize: customData?.trainName?.length > 6 ? 9 : 14, color: "white", - maxWidth: 70, + maxWidth: 65, textAlignVertical: "center", }} > @@ -343,13 +460,28 @@ export const FixedTrain = ({ trainID }) => { > + 次は + + + - 次は 新居浜 + {nextStationData[0]?.Station_JP || "不明"} { borderBottomWidth: 0, borderLeftWidth: 0, borderRightWidth: 10, - flex: 1, }} > - - + ); }; -const CurrentPositionBox = ({train,lineColor})=>{ - let firstText = ""; +const CurrentPositionBox = ({ train, lineColor }) => { + let firstText = ""; let secondText = ""; let marginText = ""; let externalText = ""; @@ -391,44 +521,46 @@ const CurrentPositionBox = ({train,lineColor})=>{ firstText = Pos; } } - return - - - - - - 現在地: - - - {marginText == "→" ? firstText + marginText + secondText : firstText} - - ; -} \ No newline at end of file + return ( + + + + + + + 現在地: + + + {marginText == "→" ? firstText + marginText + secondText : firstText} + + + ); +}; From 869731eedfe3912c9b28ee3909cefeb07b416730 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 7 Sep 2025 14:54:34 +0000 Subject: [PATCH 10/17] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Apps/FixedPositionBox.tsx | 541 +----------------- .../Apps/FixedPositionBox/FixedStationBox.tsx | 98 ++++ .../Apps/FixedPositionBox/FixedTrainBox.tsx | 450 +++++++++++++++ 3 files changed, 551 insertions(+), 538 deletions(-) create mode 100644 components/Apps/FixedPositionBox/FixedStationBox.tsx create mode 100644 components/Apps/FixedPositionBox/FixedTrainBox.tsx diff --git a/components/Apps/FixedPositionBox.tsx b/components/Apps/FixedPositionBox.tsx index 679363a..0e45f49 100644 --- a/components/Apps/FixedPositionBox.tsx +++ b/components/Apps/FixedPositionBox.tsx @@ -1,18 +1,8 @@ -import lineColorList from "@/assets/originData/lineColorList"; -import { getStationID } from "@/lib/eachTrainInfoCoreLib/getStationData"; -import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; import { useCurrentTrain } from "@/stateBox/useCurrentTrain"; -import { useStationList, StationProps } from "@/stateBox/useStationList"; -import { useEffect, useState } from "react"; -import { Text, TouchableOpacity, View, Image, Platform } from "react-native"; -import { customTrainDataDetector } from "../custom-train-data"; -import { getStringConfig, typeID } from "@/lib/getStringConfig"; -import { getTrainType } from "@/lib/getTrainType"; +import { View, Platform } from "react-native"; import Constants from "expo-constants"; -import { trainPosition } from "@/lib/trainPositionTextArray"; -import { StationNumberMaker } from "../駅名表/StationNumberMaker"; -import { lineListPair, stationIDPair } from "@/lib/getStationList"; -import { findReversalPoints } from "@/lib/eachTrainInfoCoreLib/findReversalPoints"; +import { FixedTrain } from "./FixedPositionBox/FixedTrainBox"; +import { FixedStation } from "./FixedPositionBox/FixedStationBox"; export const FixedPositionBox = () => { const { fixedPosition, setFixedPosition } = useCurrentTrain(); @@ -39,528 +29,3 @@ export const FixedPositionBox = () => { ); }; -export const FixedStation = ({ stationID }) => { - const { fixedPosition, setFixedPosition } = useCurrentTrain(); - const { getStationDataFromId } = useStationList(); - const [station, setStation] = useState([]); - useEffect(() => { - const data = getStationDataFromId(stationID); - setStation(data); - }, [stationID]); - console.log(station); - const lineColor = - station.length > 0 - ? lineColorList[station[0]?.StationNumber.slice(0, 1)] - : "white"; - return ( - { - setFixedPosition({ type: null, value: null }); - }} - > - - - {station.map((s) => { - if (s.StationNumber === null) return null; - return ( - - - {s.StationNumber?.slice(0, 1)} - - - {s.StationNumber?.slice(1)} - - - ); - })} - - - {station[0]?.Station_JP} - - - - 駅情報固定中 - - - - - - 次:15:00 快速マリン 岡山 - - - - ); -}; - -export const FixedTrain = ({ trainID }) => { - const { - fixedPosition, - setFixedPosition, - currentTrain, - getCurrentStationData, - getPosition, - } = useCurrentTrain(); - const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram(); - - const getTrainDataFromCurrentTrain = (trainNum: string) => { - const customTrainData = customTrainDataDetector( - trainNum, - allCustomTrainData - ); - switch (customTrainData.type) { - case "Normal": - case "OneMan": - const currentTrainData = currentTrain.filter((a) => a.num == trainNum); - if (currentTrainData.length == 0) return customTrainData; - else if (currentTrainData[0].Type.includes("rapid:")) { - const typeText = currentTrainData[0].Type.split(":"); - const returnData = { - type: "Rapid", - trainName: typeText[1].replace("\r", ""), - trainIcon: null, - trainNumDistance: null, - info: "", - }; - return returnData; - } - return customTrainData; - default: - return customTrainData; - } - }; - const [train, setTrain] = useState<{ - Pos?: string; - Direction?: number; - Index?: number; - Line?: string; - PosNum?: number; - Type?: string; - delay?: string | number; - num?: string; - }>(null); - const [customData, setCustomData] = useState<{ - ToData: string; - TrainNumber: string; - id: string; - img: string; - isWanman: boolean; - trainName: string; - trainNumDistance: number; - type: typeID; - viaData: string; - info?: string; - uwasa?: string; - }>(getTrainDataFromCurrentTrain(trainID)); - useEffect(() => { - setCustomData(getTrainDataFromCurrentTrain(trainID)); - }, [currentTrain, trainID]); - useEffect(() => { - const stationData = getCurrentStationData(trainID); - if (stationData) { - setTrain(stationData); - } - }, [trainID, currentTrain]); - - const { getStationDataFromName, stationList, originalStationList } = - useStationList(); - - const [trainDataWidhThrough, setTrainDataWithThrough] = useState( - [] - ); - - useEffect(() => { - const trainData = allTrainDiagram[trainID]?.split("#"); - if (!trainData) return; - //let haveThrough = false; - // - const stopStationList = trainData.map((i) => { - const [station, se, time] = i.split(","); - //if (se == "通編") setHaveThrough(true); - return stationList.map((a) => a.filter((d) => d.StationName == station)); - }); - const allThroughStationList = stopStationList.map((i, index, array) => { - let allThroughStation = []; - if (index == array.length - 1) return; - - const firstItem = array[index]; - const secondItem = array[index + 1]; - let betweenStationLine = ""; - let baseStationNumberFirst = ""; - let baseStationNumberSecond = ""; - Object.keys(stationIDPair).forEach((d, index2, array) => { - if (!d) return; - const haveFirst = firstItem[index2]; - const haveSecond = secondItem[index2]; - if (haveFirst.length && haveSecond.length) { - betweenStationLine = d; - baseStationNumberFirst = haveFirst[0].StationNumber; - baseStationNumberSecond = haveSecond[0].StationNumber; - } - }); - if (!betweenStationLine) return; - let reverse = false; - originalStationList[ - lineListPair[stationIDPair[betweenStationLine]] - ].forEach((d) => { - if ( - d.StationNumber > baseStationNumberFirst && - d.StationNumber < baseStationNumberSecond - ) { - allThroughStation.push(`${d.Station_JP},通過,`); - //setHaveThrough(true); - reverse = false; - } else { - if ( - d.StationNumber < baseStationNumberFirst && - d.StationNumber > baseStationNumberSecond - ) { - allThroughStation.push(`${d.Station_JP},通過,`); - //setHaveThrough(true); - reverse = true; - } - } - }); - if (reverse) allThroughStation.reverse(); - return allThroughStation; - }); - let mainArray = [...trainData]; - let indexs = 0; - trainData.forEach((d, index, array) => { - indexs = indexs + 1; - if (!allThroughStationList[index]) return; - if (allThroughStationList[index].length == 0) return; - mainArray.splice(indexs, 0, ...allThroughStationList[index]); - indexs = indexs + allThroughStationList[index].length; - }); - setTrainDataWithThrough(mainArray); - }, [allTrainDiagram, stationList, trainID]); - const stopStationIDList = trainDataWidhThrough.map((i) => { - const [station, se, time] = i.split(","); - const Stations = stationList.map((a) => - a.filter((d) => d.StationName == station) - ); - const StationNumbers = - Stations && - Stations.reduce((newArray, e) => { - return newArray.concat(e); - }, []).map((d) => d.StationNumber); - return StationNumbers; - }); - const [currentPosition, setCurrentPosition] = useState([]); - - useEffect(() => { - const position = getPosition(train); - if (position) setCurrentPosition(position); - }, [train]); - - const [nextStationData, setNextStationData] = useState([]); - useEffect(() => { - const points = findReversalPoints(currentPosition, stopStationIDList); - if (!points) return; - if (points.length == 0) return; - let searchCount = points.findIndex((d) => d == true); - for (searchCount; searchCount < points.length; searchCount++) { - const nextPos = trainDataWidhThrough[searchCount]; - if (nextPos) { - const [station, se, time] = nextPos.split(","); - if (se.includes("通")) continue; - else { - setNextStationData(getStationDataFromName(station)); - break; - } - } - } - }, [currentPosition, trainDataWidhThrough]); - const [ToData, setToData] = useState(""); - useEffect(() => { - if (customData.ToData && customData.ToData != "") { - setToData(customData.ToData); - } else { - if (trainDataWidhThrough.length == 0) return; - setToData( - trainDataWidhThrough[trainDataWidhThrough.length - 2].split(",")[0] - ); - } - }, [customData, trainDataWidhThrough]); - const [stringConfig, setStringConfig] = useState([, ,]); - useEffect(() => { - const x = getStringConfig(customData.type, customData.TrainNumber); - setStringConfig(x); - }, [customData]); - - const [station, setStation] = useState([]); - useEffect(() => { - const data = getStationDataFromName(ToData); - setStation(data); - }, [ToData]); - const lineColor = - station.length > 0 - ? lineColorList[station[0]?.StationNumber.slice(0, 1)] - : "black"; - return ( - { - setFixedPosition({ type: null, value: null }); - }} - > - - - - - - - {stringConfig[0]} - - {customData.trainName && ( - 6 ? 9 : 14, - color: "white", - maxWidth: 65, - textAlignVertical: "center", - }} - > - {customData.trainName} - - )} - - - - - - - - {ToData}行 - - - - - - - - 次は - - - - {nextStationData[0]?.Station_JP || "不明"} - - - - - - - ); -}; - -const CurrentPositionBox = ({ train, lineColor }) => { - let firstText = ""; - let secondText = ""; - let marginText = ""; - let externalText = ""; - const { isBetween, Pos: PosData } = trainPosition(train); - if (isBetween === true) { - const { from, to } = PosData; - firstText = from; - secondText = to; - marginText = "→"; - } else { - const { Pos } = PosData; - if (Pos !== "") { - firstText = Pos; - } - } - return ( - - - - - - - 現在地: - - - {marginText == "→" ? firstText + marginText + secondText : firstText} - - - ); -}; diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx new file mode 100644 index 0000000..1e204b9 --- /dev/null +++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx @@ -0,0 +1,98 @@ +import lineColorList from "@/assets/originData/lineColorList"; +import { useCurrentTrain } from "@/stateBox/useCurrentTrain"; +import { useStationList, StationProps } from "@/stateBox/useStationList"; +import { useEffect, useState } from "react"; +import { Text, TouchableOpacity, View } from "react-native"; + +export const FixedStation = ({ stationID }) => { + const { fixedPosition, setFixedPosition } = useCurrentTrain(); + const { getStationDataFromId } = useStationList(); + const [station, setStation] = useState([]); + useEffect(() => { + const data = getStationDataFromId(stationID); + setStation(data); + }, [stationID]); + console.log(station); + const lineColor = + station.length > 0 + ? lineColorList[station[0]?.StationNumber.slice(0, 1)] + : "white"; + return ( + { + setFixedPosition({ type: null, value: null }); + }} + > + + + {station.map((s) => { + if (s.StationNumber === null) return null; + return ( + + + {s.StationNumber?.slice(0, 1)} + + + {s.StationNumber?.slice(1)} + + + ); + })} + + + {station[0]?.Station_JP} + + + + 駅情報固定中 + + + + + + 次:15:00 快速マリン 岡山 + + + + ); +}; \ No newline at end of file diff --git a/components/Apps/FixedPositionBox/FixedTrainBox.tsx b/components/Apps/FixedPositionBox/FixedTrainBox.tsx new file mode 100644 index 0000000..ad8bb40 --- /dev/null +++ b/components/Apps/FixedPositionBox/FixedTrainBox.tsx @@ -0,0 +1,450 @@ +import lineColorList from "@/assets/originData/lineColorList"; +import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; +import { useCurrentTrain } from "@/stateBox/useCurrentTrain"; +import { useStationList, StationProps } from "@/stateBox/useStationList"; +import { FC, useEffect, useState } from "react"; +import { Text, TouchableOpacity, View, Image } from "react-native"; +import { customTrainDataDetector } from "../../custom-train-data"; +import { getStringConfig, typeID } from "@/lib/getStringConfig"; +import { getTrainType } from "@/lib/getTrainType"; +import { trainPosition } from "@/lib/trainPositionTextArray"; +import { StationNumberMaker } from "../../駅名表/StationNumberMaker"; +import { lineListPair, stationIDPair } from "@/lib/getStationList"; +import { findReversalPoints } from "@/lib/eachTrainInfoCoreLib/findReversalPoints"; + +type props = { + trainID: string; +}; + +export const FixedTrain:FC = ({ trainID }) => { + const { + fixedPosition, + setFixedPosition, + currentTrain, + getCurrentStationData, + getPosition, + } = useCurrentTrain(); + const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram(); + + const getTrainDataFromCurrentTrain = (trainNum: string) => { + const customTrainData = customTrainDataDetector( + trainNum, + allCustomTrainData + ); + switch (customTrainData.type) { + case "Normal": + case "OneMan": + const currentTrainData = currentTrain.filter((a) => a.num == trainNum); + if (currentTrainData.length == 0) return customTrainData; + else if (currentTrainData[0].Type.includes("rapid:")) { + const typeText = currentTrainData[0].Type.split(":"); + const returnData = { + type: "Rapid", + trainName: typeText[1].replace("\r", ""), + trainIcon: null, + trainNumDistance: null, + info: "", + }; + return returnData; + } + return customTrainData; + default: + return customTrainData; + } + }; + const [train, setTrain] = useState<{ + Pos?: string; + Direction?: number; + Index?: number; + Line?: string; + PosNum?: number; + Type?: string; + delay?: string | number; + num?: string; + }>(null); + const [customData, setCustomData] = useState<{ + ToData: string; + TrainNumber: string; + id: string; + img: string; + isWanman: boolean; + trainName: string; + trainNumDistance: number; + type: typeID; + viaData: string; + info?: string; + uwasa?: string; + }>(getTrainDataFromCurrentTrain(trainID)); + useEffect(() => { + setCustomData(getTrainDataFromCurrentTrain(trainID)); + }, [currentTrain, trainID]); + useEffect(() => { + const stationData = getCurrentStationData(trainID); + if (stationData) { + setTrain(stationData); + } + }, [trainID, currentTrain]); + + const { getStationDataFromName, stationList, originalStationList } = + useStationList(); + + const [trainDataWidhThrough, setTrainDataWithThrough] = useState( + [] + ); + + useEffect(() => { + const trainData = allTrainDiagram[trainID]?.split("#"); + if (!trainData) return; + //let haveThrough = false; + // + const stopStationList = trainData.map((i) => { + const [station, se, time] = i.split(","); + //if (se == "通編") setHaveThrough(true); + return stationList.map((a) => a.filter((d) => d.StationName == station)); + }); + const allThroughStationList = stopStationList.map((i, index, array) => { + let allThroughStation = []; + if (index == array.length - 1) return; + + const firstItem = array[index]; + const secondItem = array[index + 1]; + let betweenStationLine = ""; + let baseStationNumberFirst = ""; + let baseStationNumberSecond = ""; + Object.keys(stationIDPair).forEach((d, index2, array) => { + if (!d) return; + const haveFirst = firstItem[index2]; + const haveSecond = secondItem[index2]; + if (haveFirst.length && haveSecond.length) { + betweenStationLine = d; + baseStationNumberFirst = haveFirst[0].StationNumber; + baseStationNumberSecond = haveSecond[0].StationNumber; + } + }); + if (!betweenStationLine) return; + let reverse = false; + originalStationList[ + lineListPair[stationIDPair[betweenStationLine]] + ].forEach((d) => { + if ( + d.StationNumber > baseStationNumberFirst && + d.StationNumber < baseStationNumberSecond + ) { + allThroughStation.push(`${d.Station_JP},通過,`); + //setHaveThrough(true); + reverse = false; + } else { + if ( + d.StationNumber < baseStationNumberFirst && + d.StationNumber > baseStationNumberSecond + ) { + allThroughStation.push(`${d.Station_JP},通過,`); + //setHaveThrough(true); + reverse = true; + } + } + }); + if (reverse) allThroughStation.reverse(); + return allThroughStation; + }); + let mainArray = [...trainData]; + let indexs = 0; + trainData.forEach((d, index, array) => { + indexs = indexs + 1; + if (!allThroughStationList[index]) return; + if (allThroughStationList[index].length == 0) return; + mainArray.splice(indexs, 0, ...allThroughStationList[index]); + indexs = indexs + allThroughStationList[index].length; + }); + setTrainDataWithThrough(mainArray); + }, [allTrainDiagram, stationList, trainID]); + const stopStationIDList = trainDataWidhThrough.map((i) => { + const [station, se, time] = i.split(","); + const Stations = stationList.map((a) => + a.filter((d) => d.StationName == station) + ); + const StationNumbers = + Stations && + Stations.reduce((newArray, e) => { + return newArray.concat(e); + }, []).map((d) => d.StationNumber); + return StationNumbers; + }); + const [currentPosition, setCurrentPosition] = useState([]); + + useEffect(() => { + const position = getPosition(train); + if (position) setCurrentPosition(position); + }, [train]); + + const [nextStationData, setNextStationData] = useState([]); + useEffect(() => { + const points = findReversalPoints(currentPosition, stopStationIDList); + if (!points) return; + if (points.length == 0) return; + let searchCount = points.findIndex((d) => d == true); + for (searchCount; searchCount < points.length; searchCount++) { + const nextPos = trainDataWidhThrough[searchCount]; + if (nextPos) { + const [station, se, time] = nextPos.split(","); + if (se.includes("通")) continue; + else { + setNextStationData(getStationDataFromName(station)); + break; + } + } + } + }, [currentPosition, trainDataWidhThrough]); + const [ToData, setToData] = useState(""); + useEffect(() => { + if (customData.ToData && customData.ToData != "") { + setToData(customData.ToData); + } else { + if (trainDataWidhThrough.length == 0) return; + setToData( + trainDataWidhThrough[trainDataWidhThrough.length - 2].split(",")[0] + ); + } + }, [customData, trainDataWidhThrough]); + const [stringConfig, setStringConfig] = useState([, ,]); + useEffect(() => { + const x = getStringConfig(customData.type, customData.TrainNumber); + setStringConfig(x); + }, [customData]); + + const [station, setStation] = useState([]); + useEffect(() => { + const data = getStationDataFromName(ToData); + setStation(data); + }, [ToData]); + const lineColor = + station.length > 0 + ? lineColorList[station[0]?.StationNumber.slice(0, 1)] + : "black"; + return ( + { + setFixedPosition({ type: null, value: null }); + }} + > + + + + + + + {stringConfig[0]} + + {customData.trainName && ( + 6 ? 9 : 14, + color: "white", + maxWidth: 65, + textAlignVertical: "center", + }} + > + {customData.trainName} + + )} + + + + + + + + {ToData}行 + + + + + + + + 次は + + + + {nextStationData[0]?.Station_JP || "不明"} + + + + + + + ); +}; + +const CurrentPositionBox = ({ train, lineColor }) => { + let firstText = ""; + let secondText = ""; + let marginText = ""; + let externalText = ""; + const { isBetween, Pos: PosData } = trainPosition(train); + if (isBetween === true) { + const { from, to } = PosData; + firstText = from; + secondText = to; + marginText = "→"; + } else { + const { Pos } = PosData; + if (Pos !== "") { + firstText = Pos; + } + } + return ( + + + + + + + 現在地: + + + {marginText == "→" ? firstText + marginText + secondText : firstText} + + + ); +}; From b76f1adec11832a22dd4bb9c6aec951c595e7bf7 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 8 Sep 2025 11:22:36 +0000 Subject: [PATCH 11/17] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/FixedPositionBox/FixedStationBox.tsx | 102 +++++++++--------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx index 1e204b9..c5b9e4b 100644 --- a/components/Apps/FixedPositionBox/FixedStationBox.tsx +++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx @@ -1,4 +1,5 @@ import lineColorList from "@/assets/originData/lineColorList"; +import { StationNumberMaker } from "@/components/駅名表/StationNumberMaker"; import { useCurrentTrain } from "@/stateBox/useCurrentTrain"; import { useStationList, StationProps } from "@/stateBox/useStationList"; import { useEffect, useState } from "react"; @@ -12,87 +13,92 @@ export const FixedStation = ({ stationID }) => { const data = getStationDataFromId(stationID); setStation(data); }, [stationID]); - console.log(station); const lineColor = station.length > 0 ? lineColorList[station[0]?.StationNumber.slice(0, 1)] : "white"; return ( { setFixedPosition({ type: null, value: null }); }} > - + - {station.map((s) => { - if (s.StationNumber === null) return null; - return ( - - - {s.StationNumber?.slice(0, 1)} - - - {s.StationNumber?.slice(1)} - - - ); - })} + + + {station[0]?.Station_JP} + + - {station[0]?.Station_JP} - - - 駅情報固定中 + + + 次:15:00 快速マリン 岡山 + 次:15:00 快速マリン 岡山 ); -}; \ No newline at end of file +}; From b0cf70262065bafcd775b7a1218347a6cc1eb8b0 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 8 Sep 2025 12:28:10 +0000 Subject: [PATCH 12/17] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88?= =?UTF-8?q?=E3=81=9A=E6=9C=80=E4=BD=8E=E9=99=90=E3=81=AE=E9=A7=85=E7=99=BA?= =?UTF-8?q?=E8=BB=8A=E6=83=85=E5=A0=B1=E3=81=8C=E5=8B=95=E4=BD=9C=E3=81=8C?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/FixedPositionBox/FixedStationBox.tsx | 190 ++++++++++++++++-- 1 file changed, 176 insertions(+), 14 deletions(-) diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx index c5b9e4b..d27e505 100644 --- a/components/Apps/FixedPositionBox/FixedStationBox.tsx +++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx @@ -1,7 +1,12 @@ import lineColorList from "@/assets/originData/lineColorList"; import { StationNumberMaker } from "@/components/駅名表/StationNumberMaker"; +import { objectIsEmpty } from "@/lib/objectIsEmpty"; +import { trainPosition } from "@/lib/trainPositionTextArray"; +import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; +import { useAreaInfo } from "@/stateBox/useAreaInfo"; import { useCurrentTrain } from "@/stateBox/useCurrentTrain"; import { useStationList, StationProps } from "@/stateBox/useStationList"; +import dayjs from "dayjs"; import { useEffect, useState } from "react"; import { Text, TouchableOpacity, View } from "react-native"; @@ -17,6 +22,151 @@ export const FixedStation = ({ stationID }) => { station.length > 0 ? lineColorList[station[0]?.StationNumber.slice(0, 1)] : "white"; + //// + + const timeFiltering = (d) => { + const baseTime = 2; + if (currentTrain.filter((t) => t.num == d.train).length == 0) { + const date = dayjs(); + const trainTime = date + .hour(parseInt(d.time.split(":")[0])) + .minute(parseInt(d.time.split(":")[1])); + + if (date.isAfter(trainTime)) { + return false; + } else if (trainTime.diff(date) < baseTime * 60 * 60 * 1000) { + return true; + } + return false; + } else { + const Pos = trainPosition( + currentTrain.filter((t) => t.num == d.train)[0] + ); + const nextPos = Pos.isBetween ? Pos.Pos.to : Pos.Pos.Pos; + const PrePos = Pos.isBetween ? Pos.Pos.from : ""; + if (station[0].Station_JP == nextPos) { + if (d.lastStation != station[0].Station_JP) return true; + } else if (station[0].Station_JP == PrePos) { + return false; + } + const date = dayjs(); + let [h, m] = d.time.split(":"); + let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay) + ? 0 + : currentTrain.filter((t) => t.num == d.train)[0].delay; + const db = date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay)); + return !date.isAfter(db); + } + }; + type trainDataProps = { + train?: string; + lastStation?: string; + time?: string; + isThrough?: boolean; + }; + const getTime = (stationDiagram, station) => { + const returnData = Object.keys(stationDiagram) + .map((trainNum) => { + let trainData: trainDataProps = {}; + stationDiagram[trainNum].split("#").forEach((data) => { + if (data.match("着")) { + trainData.lastStation = data.split(",着,")[0]; + } + if (data.match("着編")) { + trainData.lastStation = data.split(",着編,")[0]; + } + if (data.split(",")[0] === station.Station_JP) { + if (data.match(",発,")) { + trainData.time = data.split(",発,")[1]; + } else if (data.match(",発編,")) { + trainData.time = data.split(",発編,")[1]; + } else if (data.match(",通編,")) { + trainData.time = data.split(",通編,")[1]; + trainData.isThrough = true; + } else if (data.match(",着,")) { + trainData.time = data.split(",着,")[1]; + } else if (data.match(",着編,")) { + trainData.time = data.split(",着編,")[1]; + } + } + }); + return { + train: trainNum, + time: trainData.time, + lastStation: trainData.lastStation, + isThrough: trainData.isThrough, + }; + }) + .filter((d) => d.time); + return returnData.sort((a, b) => { + switch (true) { + case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]): + return -1; + case parseInt(a.time.split(":")[0]) > parseInt(b.time.split(":")[0]): + return 1; + case parseInt(a.time.split(":")[1]) < parseInt(b.time.split(":")[1]): + return -1; + case parseInt(a.time.split(":")[1]) > parseInt(b.time.split(":")[1]): + return 1; + default: + return 0; + } + }); + }; + + const { allTrainDiagram } = useAllTrainDiagram(); + const { areaInfo, areaStationID } = useAreaInfo(); + const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表 + const [isInfoArea, setIsInfoArea] = useState(false); + const { currentTrain } = useCurrentTrain(); + + useEffect(() => { + // 現在の駅に停車するダイヤを作成する副作用[列車ダイヤと現在駅情報] + if (!allTrainDiagram) { + setStationDiagram({}); + return; + } + if (station.length == 0) { + setStationDiagram({}); + return; + } + let returnData = {}; + Object.keys(allTrainDiagram).forEach((key) => { + if (allTrainDiagram[key].match(station[0].Station_JP + ",")) { + returnData[key] = allTrainDiagram[key]; + } + }); + setStationDiagram(returnData); + setIsInfoArea(station.some((s) => areaStationID.includes(s.StationNumber))); + }, [allTrainDiagram, station]); + + const [trainTimeAndNumber, setTrainTimeAndNumber] = useState([]); + + useEffect(() => { + //現在の駅に停車する列車から時刻を切り出してLEDベースにフォーマット + if (objectIsEmpty(stationDiagram)) return () => {}; + const getTimeData = getTime(stationDiagram, station[0]); + setTrainTimeAndNumber(getTimeData); + }, [stationDiagram]); + const [selectedTrain, setSelectedTrain] = useState< + { + isThrough?: boolean; + train?: string; + lastStation?: string; + time?: string; + }[] + >([]); + useEffect(() => { + if (!trainTimeAndNumber) return () => {}; + if (!currentTrain) return () => {}; + const data = trainTimeAndNumber + .filter((d) => currentTrain.map((m) => m.num).includes(d.train)) //現在の列車に絞る[ToDo] + .filter(timeFiltering); + //.filter((d) => !!finalSwitch || d.lastStation != station[0].Station_JP) //最終列車表示設定 + setSelectedTrain(data); + }, [trainTimeAndNumber, currentTrain /*finalSwitch*/]); + + console.log(selectedTrain); return ( { backgroundColor: lineColor, flexDirection: "row", width: "100%", - }} > { textAlignVertical: "center", margin: 0, padding: 0, - flex:1 + flex: 1, }} > {station[0]?.Station_JP} @@ -64,14 +213,15 @@ export const FixedStation = ({ stationID }) => { backgroundColor: "white", width: 10, borderLeftColor: lineColor, + borderTopColor: lineColor, borderBottomColor: "white", - borderBottomWidth: 24, - borderLeftWidth: 10, + borderBottomWidth: 16, + borderLeftWidth: 8, borderRightWidth: 0, - borderTopWidth: 0, + borderTopWidth: 5, height: "100%", }} - /> + /> { flex: 1, }} > - 駅情報固定中 + 次の発車予定: @@ -89,15 +239,27 @@ export const FixedStation = ({ stationID }) => { flex: 5, flexDirection: "column", backgroundColor: lineColor, + borderTopWidth: 5, + borderTopColor: lineColor, }} > - - - 次:15:00 快速マリン 岡山 - - - 次:15:00 快速マリン 岡山 - + {selectedTrain.length > 0 ? ( + selectedTrain.map((d) => ( + + {d.time} + {d.train} + {d.lastStation} + 定刻 + + )) + ) : ( + + 次:15:00 快速マリン 岡山 + + )} ); From 4dba21ccddfa17168aaecb1762104b6049508985 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 8 Sep 2025 14:50:36 +0000 Subject: [PATCH 13/17] =?UTF-8?q?=E5=88=97=E8=BB=8A=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=81=8C=E6=AD=A3=E3=81=97=E3=81=8F=E8=A1=A8=E7=A4=BA=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/FixedPositionBox/FixedStationBox.tsx | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx index d27e505..40d54c6 100644 --- a/components/Apps/FixedPositionBox/FixedStationBox.tsx +++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx @@ -1,5 +1,7 @@ import lineColorList from "@/assets/originData/lineColorList"; import { StationNumberMaker } from "@/components/駅名表/StationNumberMaker"; +import { checkDuplicateTrainData } from "@/lib/checkDuplicateTrainData"; +import { getTrainDelayStatus } from "@/lib/getTrainDelayStatus"; import { objectIsEmpty } from "@/lib/objectIsEmpty"; import { trainPosition } from "@/lib/trainPositionTextArray"; import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; @@ -238,29 +240,51 @@ export const FixedStation = ({ stationID }) => { style={{ flex: 5, flexDirection: "column", - backgroundColor: lineColor, + backgroundColor: "white", borderTopWidth: 5, borderTopColor: lineColor, }} > {selectedTrain.length > 0 ? ( selectedTrain.map((d) => ( - - {d.time} - {d.train} - {d.lastStation} - 定刻 - + )) ) : ( - 次:15:00 快速マリン 岡山 + 当駅を発着する走行中の列車はありません。 )} ); }; + +const FixedStationBoxEachTrain = ({ d, station }) => { + const { currentTrain } = useCurrentTrain(); + const { stationList } = useStationList(); + const currentTrainData = checkDuplicateTrainData( + currentTrain.filter((a) => a.num == d.train), + stationList + ); + + const trainDelayStatus = `${getTrainDelayStatus( + currentTrainData, + station.Station_JP + )}`; + + return ( + + {d.time} + {d.train} + {d.lastStation} + {trainDelayStatus} + + ); +}; From b43604c7f11096206170f27c05d70acfbb635690 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 8 Sep 2025 15:12:22 +0000 Subject: [PATCH 14/17] =?UTF-8?q?=E6=99=82=E5=88=BB=E3=82=924=E6=99=82?= =?UTF-8?q?=E3=81=A7=E6=97=A5=E4=BB=98=E5=A4=89=E6=9B=B4=E7=B7=9A=E3=81=A8?= =?UTF-8?q?=E3=81=97=E3=81=A6=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/FixedPositionBox/FixedStationBox.tsx | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx index 40d54c6..941e326 100644 --- a/components/Apps/FixedPositionBox/FixedStationBox.tsx +++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx @@ -51,13 +51,29 @@ export const FixedStation = ({ stationID }) => { } else if (station[0].Station_JP == PrePos) { return false; } - const date = dayjs(); let [h, m] = d.time.split(":"); let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay) ? 0 : currentTrain.filter((t) => t.num == d.train)[0].delay; - const db = date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay)); - return !date.isAfter(db); + const date = dayjs(); + let targetHour = parseInt(h); + + // 4時を日付変更線として処理 + if (targetHour < 4) { + targetHour += 24; + } + + let currentHour = date.hour(); + if (currentHour < 4) { + currentHour += 24; + } + + const db = dayjs() + .hour(targetHour) + .minute(parseInt(m) + parseInt(delay)); + const currentTime = dayjs().hour(currentHour); + + return !currentTime.isAfter(db); } }; type trainDataProps = { @@ -168,7 +184,6 @@ export const FixedStation = ({ stationID }) => { setSelectedTrain(data); }, [trainTimeAndNumber, currentTrain /*finalSwitch*/]); - console.log(selectedTrain); return ( { )) ) : ( - 当駅を発着する走行中の列車はありません。 + + 当駅を発着する走行中の列車はありません。 + )} @@ -278,7 +295,7 @@ const FixedStationBoxEachTrain = ({ d, station }) => { return ( {d.time} From 4674f46c82cb8028c29e10b1bd158f7b1f803bf8 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 8 Sep 2025 18:09:20 +0000 Subject: [PATCH 15/17] =?UTF-8?q?=E7=A8=AE=E5=88=A5=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/FixedPositionBox/FixedStationBox.tsx | 64 ++++++++++++++++--- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx index 941e326..d4e3900 100644 --- a/components/Apps/FixedPositionBox/FixedStationBox.tsx +++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx @@ -1,7 +1,10 @@ import lineColorList from "@/assets/originData/lineColorList"; +import { customTrainDataDetector } from "@/components/custom-train-data"; import { StationNumberMaker } from "@/components/駅名表/StationNumberMaker"; import { checkDuplicateTrainData } from "@/lib/checkDuplicateTrainData"; +import { typeID } from "@/lib/getStringConfig"; import { getTrainDelayStatus } from "@/lib/getTrainDelayStatus"; +import { getTrainType } from "@/lib/getTrainType"; import { objectIsEmpty } from "@/lib/objectIsEmpty"; import { trainPosition } from "@/lib/trainPositionTextArray"; import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; @@ -221,6 +224,7 @@ export const FixedStation = ({ stationID }) => { margin: 0, padding: 0, flex: 1, + color:"white" }} > {station[0]?.Station_JP} @@ -265,7 +269,7 @@ export const FixedStation = ({ stationID }) => { )) ) : ( @@ -283,6 +287,7 @@ export const FixedStation = ({ stationID }) => { const FixedStationBoxEachTrain = ({ d, station }) => { const { currentTrain } = useCurrentTrain(); const { stationList } = useStationList(); + const { allCustomTrainData } = useAllTrainDiagram(); const currentTrainData = checkDuplicateTrainData( currentTrain.filter((a) => a.num == d.train), stationList @@ -292,16 +297,55 @@ const FixedStationBoxEachTrain = ({ d, station }) => { currentTrainData, station.Station_JP )}`; - + const getTrainDataFromCurrentTrain = (trainNum: string) => { + const customTrainData = customTrainDataDetector( + d.train, + allCustomTrainData + ); + switch (customTrainData.type) { + case "Normal": + case "OneMan": + const currentTrainData = currentTrain.filter((a) => a.num == trainNum); + if (currentTrainData.length == 0) return customTrainData; + else if (currentTrainData[0].Type.includes("rapid:")) { + const typeText = currentTrainData[0].Type.split(":"); + const returnData = { + type: "Rapid", + trainName: typeText[1].replace("\r", ""), + trainIcon: null, + trainNumDistance: null, + info: "", + }; + return returnData; + } + return customTrainData; + default: + return customTrainData; + } + }; + const [train, setTrain] = useState<{ + ToData: string; + TrainNumber: string; + id: string; + img: string; + isWanman: boolean; + trainName: string; + trainNumDistance: number; + type: typeID; + viaData: string; + info?: string; + uwasa?: string; + }>(getTrainDataFromCurrentTrain(d.train)); + useEffect(() => { + setTrain(getTrainDataFromCurrentTrain(d.train)); + }, [currentTrain, d.train]); + const { name, color } = getTrainType(train.type); return ( - - {d.time} - {d.train} - {d.lastStation} - {trainDelayStatus} + + {d.time} + {name} + {d.lastStation} + {trainDelayStatus} ); }; From 30c05bdee65a94f1a4a2623d1b7613565fadeb11 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 8 Sep 2025 18:46:54 +0000 Subject: [PATCH 16/17] =?UTF-8?q?=E5=81=9C=E8=BB=8A=E3=81=99=E3=82=8B?= =?UTF-8?q?=E5=88=97=E8=BB=8A=E4=BB=A5=E5=A4=96=E3=82=92=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=81=E6=A8=AA=E3=83=A2=E3=83=BC=E3=83=89=E3=82=92?= =?UTF-8?q?=E4=BB=AE=E6=9C=89=E5=8A=B9=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/FixedPositionBox/FixedStationBox.tsx | 23 +++++++++++-------- stateBox/useDeviceOrientationChange.js | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx index d4e3900..5febbf0 100644 --- a/components/Apps/FixedPositionBox/FixedStationBox.tsx +++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx @@ -182,8 +182,8 @@ export const FixedStation = ({ stationID }) => { if (!currentTrain) return () => {}; const data = trainTimeAndNumber .filter((d) => currentTrain.map((m) => m.num).includes(d.train)) //現在の列車に絞る[ToDo] - .filter(timeFiltering); - //.filter((d) => !!finalSwitch || d.lastStation != station[0].Station_JP) //最終列車表示設定 + .filter(timeFiltering).filter(d=>!d.isThrough) + .filter((d) => d.lastStation != station[0].Station_JP) //最終列車表示設定 setSelectedTrain(data); }, [trainTimeAndNumber, currentTrain /*finalSwitch*/]); @@ -210,16 +210,18 @@ export const FixedStation = ({ stationID }) => { backgroundColor: lineColor, flexDirection: "row", width: "100%", + alignContent: "center", + alignItems: "center", }} > { backgroundColor: "white", borderTopWidth: 5, borderTopColor: lineColor, + overflow: "hidden", }} > {selectedTrain.length > 0 ? ( @@ -339,13 +342,13 @@ const FixedStationBoxEachTrain = ({ d, station }) => { useEffect(() => { setTrain(getTrainDataFromCurrentTrain(d.train)); }, [currentTrain, d.train]); - const { name, color } = getTrainType(train.type); + const { name, color } = getTrainType(train.type, true); return ( - - {d.time} - {name} - {d.lastStation} - {trainDelayStatus} + + {d.time} + {name} + {d.lastStation}行 + {trainDelayStatus} ); }; diff --git a/stateBox/useDeviceOrientationChange.js b/stateBox/useDeviceOrientationChange.js index 5efd975..130062d 100644 --- a/stateBox/useDeviceOrientationChange.js +++ b/stateBox/useDeviceOrientationChange.js @@ -18,8 +18,8 @@ export const DeviceOrientationChangeProvider = ({ children }) => { ); }; useEffect(() => { - data(); - //ScreenOrientation.unlockAsync(); + //data(); + ScreenOrientation.unlockAsync(); }, []); // useEffect(() => { From c7487d38dba1f34e3f4fbe4a2071c4e7b227fce5 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 9 Sep 2025 14:28:34 +0000 Subject: [PATCH 17/17] =?UTF-8?q?=E5=88=97=E8=BB=8A=E3=81=AE=E7=8F=BE?= =?UTF-8?q?=E5=9C=A8=E5=9C=B0=E3=81=8C=E8=BF=BD=E5=BE=93=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/FixedPositionBox/FixedTrainBox.tsx | 99 ++++++++++++++++--- stateBox/useCurrentTrain.js | 1 - 2 files changed, 87 insertions(+), 13 deletions(-) diff --git a/components/Apps/FixedPositionBox/FixedTrainBox.tsx b/components/Apps/FixedPositionBox/FixedTrainBox.tsx index ad8bb40..fcaa66b 100644 --- a/components/Apps/FixedPositionBox/FixedTrainBox.tsx +++ b/components/Apps/FixedPositionBox/FixedTrainBox.tsx @@ -16,7 +16,7 @@ type props = { trainID: string; }; -export const FixedTrain:FC = ({ trainID }) => { +export const FixedTrain: FC = ({ trainID }) => { const { fixedPosition, setFixedPosition, @@ -178,12 +178,18 @@ export const FixedTrain:FC = ({ trainID }) => { }, [train]); const [nextStationData, setNextStationData] = useState([]); + const [untilStationData, setUntilStationData] = useState([]); useEffect(() => { const points = findReversalPoints(currentPosition, stopStationIDList); if (!points) return; if (points.length == 0) return; - let searchCount = points.findIndex((d) => d == true); - for (searchCount; searchCount < points.length; searchCount++) { + let searchCountBase = points.findIndex((d) => d == true); + for ( + let searchCount = searchCountBase; + searchCount < points.length; + searchCount++ + ) { + console.log(trainDataWidhThrough[searchCount]); const nextPos = trainDataWidhThrough[searchCount]; if (nextPos) { const [station, se, time] = nextPos.split(","); @@ -194,6 +200,15 @@ export const FixedTrain:FC = ({ trainID }) => { } } } + let trainList = []; + for ( + let searchCount = searchCountBase - 1; + searchCount < points.length; + searchCount++ + ) { + trainList.push(trainDataWidhThrough[searchCount]); + } + setUntilStationData(trainList); }, [currentPosition, trainDataWidhThrough]); const [ToData, setToData] = useState(""); useEffect(() => { @@ -350,7 +365,7 @@ export const FixedTrain:FC = ({ trainID }) => { marginHorizontal: 5, }} > - 次は + {nextStationData[0]?.Station_JP == train?.Pos ? "ただいま" : "次は"} = ({ trainID }) => { > - + ); }; -const CurrentPositionBox = ({ train, lineColor }) => { +const CurrentPositionBox = ({ train, lineColor, trainDataWithThrough }) => { let firstText = ""; let secondText = ""; let marginText = ""; @@ -439,12 +458,68 @@ const CurrentPositionBox = ({ train, lineColor }) => { }} > - - 現在地: - - - {marginText == "→" ? firstText + marginText + secondText : firstText} - + + {trainDataWithThrough.length > 0 && + trainDataWithThrough.map((d, index, array) => { + if (!d) return null; + if (d == "") return null; + const [station, se, time] = d.split(","); + return ( + <> + {(index == 0 && secondText == "") || + {station.split("").map((i, index) => { + return ( + + {i} + + ); + })} + + + {se.includes("通") ? "" : "●"} + + } + {(index == 0 && secondText != "") && ( + + + + + )} + + ); + })} + ); }; diff --git a/stateBox/useCurrentTrain.js b/stateBox/useCurrentTrain.js index ac1152b..316b75f 100644 --- a/stateBox/useCurrentTrain.js +++ b/stateBox/useCurrentTrain.js @@ -147,7 +147,6 @@ export const CurrentTrainProvider = ({ children }) => { const setInjectData = ({ type, value, fixed }) => { if (type === "station") { const script = getInjectJavascriptAddress(value); - console.log(value); inject(script); } else if (type === "train") { const currentTrain = getCurrentStationData(value);