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);