From 7ab402d35f1bcf9ba659ececeb55980a2afcf886 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Wed, 24 Sep 2025 09:45:08 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=8A=E4=BA=88=E8=8B=A5=E5=AE=AE=E4=BF=A1?= =?UTF-8?q?=E5=8F=B7=E6=89=80=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92=E8=A9=B3?= =?UTF-8?q?=E7=B4=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfoCore.js | 30 +- .../Apps/FixedPositionBox/FixedTrainBox.tsx | 287 +++++++++++------- stateBox/useCurrentTrain.tsx | 4 +- 3 files changed, 201 insertions(+), 120 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index 82abb7c..c3bfe7e 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -249,7 +249,35 @@ export const EachTrainInfoCore = ({ useEffect(() => { const position = getPosition(currentTrainData); - if (position) setCurrentPosition(position); + if (position) { + if (position.length > 1) { + if (position[0] == "-Iyo") { + position[0] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) - 1 + ][0]; + } + else if (position[0] == "+Iyo") { + position[0] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) + 1 + ][0]; + } + if (position[1] == "+Iyo") { + position[1] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) + 1 + ][0]; + }else if (position[1] == "-Iyo") { + position[1] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) - 1 + ][0]; + } + } + + setCurrentPosition(position); + } }, [currentTrainData]); useEffect(() => { diff --git a/components/Apps/FixedPositionBox/FixedTrainBox.tsx b/components/Apps/FixedPositionBox/FixedTrainBox.tsx index 104b87f..3739c0e 100644 --- a/components/Apps/FixedPositionBox/FixedTrainBox.tsx +++ b/components/Apps/FixedPositionBox/FixedTrainBox.tsx @@ -144,19 +144,50 @@ export const FixedTrain: FC = ({ const [currentPosition, setCurrentPosition] = useState([]); useEffect(() => { - const position = getPosition(train); - if (position) setCurrentPosition(position); + let position = getPosition(train); + if (position) { + if (position.length > 1) { + if (position[0] == "-Iyo") { + position[0] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) - 1 + ][0]; + } + else if (position[0] == "+Iyo") { + position[0] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) + 1 + ][0]; + } + if (position[1] == "+Iyo") { + position[1] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) + 1 + ][0]; + }else if (position[1] == "-Iyo") { + position[1] = + stopStationIDList[ + stopStationIDList.findIndex((d) => d.includes("U14")) - 1 + ][0]; + } + } + + setCurrentPosition(position); + } }, [train]); const [nextStationData, setNextStationData] = useState([]); const [untilStationData, setUntilStationData] = useState([]); useEffect(() => { + //棒線駅判定を入れて、棒線駅なら時間を見て分数がマイナスならcontinue; const points = findReversalPoints(currentPosition, stopStationIDList); if (!points) return; if (points.length == 0) return; - let searchCountBase = points.findIndex((d) => d == true); + let searchCountFirst = points.findIndex((d) => d == true); + let searchCountLast = points.findLastIndex((d) => d == true); + console.log("searchCountBase", searchCountFirst, searchCountLast); for ( - let searchCount = searchCountBase; + let searchCount = searchCountFirst; searchCount < points.length; searchCount++ ) { @@ -172,7 +203,7 @@ export const FixedTrain: FC = ({ } let trainList = []; for ( - let searchCount = searchCountBase - 1; + let searchCount = searchCountFirst - 1; searchCount < points.length; searchCount++ ) { @@ -259,12 +290,12 @@ export const FixedTrain: FC = ({ alignContent: "center", alignSelf: "center", alignItems: "center", - maxWidth: displaySize === 226 ? 60 : 100, + maxWidth: displaySize === 226 ? 80 : 100, }} > 4 ? 12 : 14, fontFamily: customTrainType.fontAvailable ? "JR-Nishi" : undefined, @@ -282,7 +313,7 @@ export const FixedTrain: FC = ({ {customData.trainName && ( 6 ? 8 : 14, + fontSize: trainNameText.length > 4 ? 8 : 14, color: "white", maxWidth: displaySize === 226 ? 200 : 60, textAlignVertical: "center", @@ -610,116 +641,138 @@ const CurrentPositionBox = ({ overScrollMode="always" > {trainDataWithThrough.length > 0 && - trainDataWithThrough.map((d, index) => { - if (!d) return null; - if (d == "") return null; - const [station, se, time] = d.split(","); - let distanceMinute = 0; - if (time != "") { - const now = dayjs(); - const hour = parseInt(time.split(":")[0]); - const distanceTime = now - .hour(hour < 4 ? hour + 24 : hour) - .minute(time.split(":")[1]); - distanceMinute = distanceTime.diff(now, "minute") + delayTime; - if (now.hour() < 4) { - if (hour < 4) { - distanceMinute = distanceMinute - 1440; - } - } - } - return ( - <> - - {station.split("").map((i, index) => { - return ( - - {i} - - ); - })} - - {isSmall || - (time != "" && ( - - {distanceMinute} - - ))} - - {se.includes("通") - ? null - : index == 1 && secondText == "" - ? "→" - : "●"} - - - {index == 0 && secondText != "" && ( - - - - - )} - - ); - })} + trainDataWithThrough.map((d, index) => ( + + ))} ); }; + +type eachStopType = { + d: string; + delayTime: number; + isSmall: boolean; + index: number; + secondText: string; +}; + +const EachStopData: FC = (props) => { + const { d, delayTime, isSmall, index, secondText } = props; + if (!d) return null; + if (d == "") return null; + const [station, se, time] = d.split(","); + let distanceMinute = 0; + if (time != "") { + const now = dayjs(); + const hour = parseInt(time.split(":")[0]); + const distanceTime = now + .hour(hour < 4 ? hour + 24 : hour) + .minute(parseInt(time.split(":")[1])); + distanceMinute = distanceTime.diff(now, "minute") + delayTime; + if (now.hour() < 4) { + if (hour < 4) { + distanceMinute = distanceMinute - 1440; + } + } + } + return ( + <> + + {station.split("").map((i, index, array) => { + return ( + + {i} + + ); + })} + + {isSmall || + (time != "" && ( + + {distanceMinute} + + ))} + + {index == 1 && secondText == "" + ? "→" + : se.includes("通") + ? null + : "●"} + + + {index == 0 && secondText != "" && ( + + + + + )} + + ); +}; diff --git a/stateBox/useCurrentTrain.tsx b/stateBox/useCurrentTrain.tsx index ec94e5f..7f8b686 100644 --- a/stateBox/useCurrentTrain.tsx +++ b/stateBox/useCurrentTrain.tsx @@ -131,9 +131,9 @@ export const CurrentTrainProvider: FC = ({ children }) => { } else if (pos[0] == "伊予白滝" && pos[1] == "伊予若宮") { return ["S14", "S18"]; } else if (pos[0] == "伊予大洲" && pos[1] == "伊予若宮") { - return ["U14", "U14"]; + return ["U14", "+Iyo"]; } else if (pos[0] == "伊予若宮" && pos[1] == "伊予大洲") { - return ["U14", "U14"]; + return ["-Iyo", "U14"]; } const currentPosID = Object.keys(originalStationList).map((key) => { let firstStation = false;