From 86655f5632f30cf9ebcfc437e329f60d5c4e9b5a Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 12:08:55 +0000 Subject: [PATCH 01/14] =?UTF-8?q?=E9=80=9A=E9=81=8E=E9=A7=85=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/originData/tokushima.ts | 2 +- .../EachTrainInfo/EachStopList.js | 2 +- .../EachTrainInfoCore.js | 87 ++++++++++++++++--- .../findReversalPoints.js | 4 +- 4 files changed, 80 insertions(+), 15 deletions(-) diff --git a/assets/originData/tokushima.ts b/assets/originData/tokushima.ts index c90b303..b94015d 100644 --- a/assets/originData/tokushima.ts +++ b/assets/originData/tokushima.ts @@ -1,5 +1,5 @@ export default [ -{"Station_JP" : "徳島", "Station_EN" : "Tokushima", "MyStation" : "0", "StationNumber" : "T00", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/tokushima.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074642,134.550764", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/tokushima/"}, +{"Station_JP" : "徳島", "Station_EN" : "Tokushima", "MyStation" : "0", "StationNumber" : "B00", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/tokushima.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074642,134.550764", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/tokushima/"}, {"Station_JP" : "佐古", "Station_EN" : "Sako", "MyStation" : "0", "StationNumber" : "B01", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/sako.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.080616,134.538576", "JrHpUrl" : ""}, {"Station_JP" : "蔵本", "Station_EN" : "Kuramoto", "MyStation" : "1", "StationNumber" : "B02", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/kuramoto.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.079332,134.518705", "JrHpUrl" : ""}, {"Station_JP" : "府中", "Station_EN" : "Kō", "MyStation" : "2", "StationNumber" : "B04", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/ko.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074134,134.482939", "JrHpUrl" : ""}, diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js index a2813b3..dbfd194 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js @@ -43,7 +43,7 @@ export const EachStopList = ({ .set("hour", parseInt(time.split(":")[0])) .set("minute", parseInt(time.split(":")[1])) .add(isNaN(currentTrainData?.delay) ? 0 : currentTrainData.delay, "minute"); - const timeString = dates.format("HH:mm").split(":"); + const timeString = se == "通過"? "" :dates.format("HH:mm").split(":"); return ( d.StationNumber) .map((d) => d.StationNumber); - return StationNumbers[0]; + return StationNumbers; }); + useEffect(() => { + const stopStationList = trainData.map((i) => { + const [station, se, time] = i.split(","); + 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) => { + console.log(d.StationNumber, baseStationNumberFirst, baseStationNumberSecond); + if ( + d.StationNumber > baseStationNumberFirst && + d.StationNumber < baseStationNumberSecond + ) { + console.log(d.Station_JP); + allThroughStation.push(`${d.Station_JP},通過,`); + reverse = false; + } else { + if ( + d.StationNumber < baseStationNumberFirst && + d.StationNumber > baseStationNumberSecond + ) { + console.log(d.Station_JP); + allThroughStation.push(`${d.Station_JP},通過,`); + 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); + }, [trainData]); + const points = trainPositionSwitch == "true" ? findReversalPoints(currentPosition, stopStationIDList) @@ -360,18 +425,18 @@ export const EachTrainInfoCore = ({ )} - {trainData.map((i, index) => + {trainDataWidhThrough.map((i, index) => i.split(",")[1] == "提" ? ( ) : ( - + ) )} {tailStation.length != 0 && diff --git a/lib/eachTrainInfoCoreLib/findReversalPoints.js b/lib/eachTrainInfoCoreLib/findReversalPoints.js index 05f6f55..a7cd70e 100644 --- a/lib/eachTrainInfoCoreLib/findReversalPoints.js +++ b/lib/eachTrainInfoCoreLib/findReversalPoints.js @@ -20,11 +20,11 @@ export const findReversalPoints = (array, stopStationIDList) => { const stopStationIDListNumber = stopStationIDList.map((d) => { if (!d) return { line: [], ID: [] }; return { - line: d + line: d[0] .split("") .filter((s) => "A" < s && s < "Z") .join(""), - ID: d + ID: d[0] .split("") .filter((s) => "0" <= s && s <= "9") .join(""), From a9dddfca2c0d1087bf17d2836aa7efb67b71a3f7 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 12:54:32 +0000 Subject: [PATCH 02/14] =?UTF-8?q?=E9=80=9A=E9=81=8E=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=AE=E3=82=AA=E3=83=B3=E3=82=AA=E3=83=95=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfo/EachStopList.js | 14 ++++++-- .../EachTrainInfo/ScrollStickyContent.js | 27 ++++++++++++-- .../EachTrainInfoCore.js | 36 +++++++++++-------- 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js index dbfd194..66decaf 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js @@ -10,7 +10,9 @@ export const EachStopList = ({ points, currentTrainData, openStationACFromEachTrainInfo, + showThrew, }) => { + if (!showThrew && i.split(",")[1] == "通過") return null; const [station, se, time] = i.split(","); // 阿波池田,発,6:21 const Stations = stationList .map((a) => a.filter((d) => d.StationName == station)) @@ -43,7 +45,7 @@ export const EachStopList = ({ .set("hour", parseInt(time.split(":")[0])) .set("minute", parseInt(time.split(":")[1])) .add(isNaN(currentTrainData?.delay) ? 0 : currentTrainData.delay, "minute"); - const timeString = se == "通過"? "" :dates.format("HH:mm").split(":"); + const timeString = se == "通過" ? "" : dates.format("HH:mm").split(":"); return ( ( - {station} + + {station} + {points && points.findIndex((d) => d == index) >= 0 ? ( 🚊 diff --git a/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js index 3881b36..6496b4e 100644 --- a/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js +++ b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js @@ -1,7 +1,8 @@ import React from "react"; -import { View, Text } from "react-native"; +import { View, Text, LayoutAnimation } from "react-native"; -export const ScrollStickyContent = ({ currentTrainData }) => { +export const ScrollStickyContent = (props) => { + const { currentTrainData, showThrew, setShowThrew, haveThrough } = props; return ( { > 見込 - + { + if (!haveThrough) return; + LayoutAnimation.configureNext({ + duration: 200, + update: { type: "easeInEaseOut", springDamping: 0.6 }, + }); + setShowThrew(!showThrew); + }} + > + (通過{showThrew ? "▼" : "▶"}) + diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index a0107bc..0ef42bb 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -82,6 +82,8 @@ export const EachTrainInfoCore = ({ const [currentPosition, setCurrentPosition] = useState([]); const [trainData, setTrainData] = useState([]); const [trainDataWidhThrough, setTrainDataWithThrough] = useState([]); + const [showThrew, setShowThrew] = useState(false); + const [haveThrough, setHaveThrough] = useState(false); const stationList = originalStationList && @@ -136,13 +138,13 @@ export const EachTrainInfoCore = ({ originalStationList[ lineListPair[stationIDPair[betweenStationLine]] ].forEach((d) => { - console.log(d.StationNumber, baseStationNumberFirst, baseStationNumberSecond); if ( d.StationNumber > baseStationNumberFirst && d.StationNumber < baseStationNumberSecond ) { console.log(d.Station_JP); allThroughStation.push(`${d.Station_JP},通過,`); + setHaveThrough(true); reverse = false; } else { if ( @@ -151,6 +153,7 @@ export const EachTrainInfoCore = ({ ) { console.log(d.Station_JP); allThroughStation.push(`${d.Station_JP},通過,`); + setHaveThrough(true); reverse = true; } } @@ -161,11 +164,11 @@ export const EachTrainInfoCore = ({ let mainArray = [...trainData]; let indexs = 0; trainData.forEach((d, index, array) => { - indexs = indexs+1; - if(!allThroughStationList[index]) return; - if(allThroughStationList[index].length == 0) return; + indexs = indexs + 1; + if (!allThroughStationList[index]) return; + if (allThroughStationList[index].length == 0) return; mainArray.splice(indexs, 0, ...allThroughStationList[index]); - indexs = indexs+allThroughStationList[index].length; + indexs = indexs + allThroughStationList[index].length; }); setTrainDataWithThrough(mainArray); }, [trainData]); @@ -366,7 +369,9 @@ export const EachTrainInfoCore = ({ shortHeader={} longHeader={} topStickyContent={ - + } > {headStation.length != 0 && @@ -429,14 +434,17 @@ export const EachTrainInfoCore = ({ i.split(",")[1] == "提" ? ( ) : ( - + ) )} {tailStation.length != 0 && From 6a8bdba8497b4efc6e65b1f19495148de1f10185 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 12:57:58 +0000 Subject: [PATCH 03/14] =?UTF-8?q?=E3=83=AC=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ActionSheetComponents/EachTrainInfo/EachStopList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js index 66decaf..5ffecb7 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js @@ -136,7 +136,7 @@ export const EachStopList = ({ width: 60, }} > - {timeString[0]}:{timeString[1]} + {se == "通過" ? "レ" : `${timeString[0]}:${timeString[1]}`} {se?.replace("発", "出発").replace("着", "到着")} From bc8a786db748d06c749c6400c21a2452bb552f47 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 13:27:49 +0000 Subject: [PATCH 04/14] =?UTF-8?q?=E9=80=9A=E9=81=8E=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E3=83=87=E3=82=B6=E3=82=A4=E3=83=B3=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfo/ScrollStickyContent.js | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js index 6496b4e..23cf4e5 100644 --- a/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js +++ b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js @@ -50,27 +50,31 @@ export const ScrollStickyContent = (props) => { > 見込 - { - if (!haveThrough) return; - LayoutAnimation.configureNext({ - duration: 200, - update: { type: "easeInEaseOut", springDamping: 0.6 }, - }); - setShowThrew(!showThrew); - }} - > - (通過{showThrew ? "▼" : "▶"}) - + + + { + if (!haveThrough) return; + LayoutAnimation.configureNext({ + duration: 200, + update: { type: "easeInEaseOut", springDamping: 0.6 }, + }); + setShowThrew(!showThrew); + }} + > + (通過{showThrew ? "▼" : "▶"}) + + + From 64d56d3df60627f4175a506031728bcfcbd0d2c7 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 13:36:17 +0000 Subject: [PATCH 05/14] =?UTF-8?q?=E5=BD=93=E3=81=9F=E3=82=8A=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfo/ScrollStickyContent.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js index 23cf4e5..545428d 100644 --- a/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js +++ b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js @@ -1,5 +1,5 @@ import React from "react"; -import { View, Text, LayoutAnimation } from "react-native"; +import { View, Text, LayoutAnimation, TouchableOpacity } from "react-native"; export const ScrollStickyContent = (props) => { const { currentTrainData, showThrew, setShowThrew, haveThrough } = props; @@ -50,7 +50,16 @@ export const ScrollStickyContent = (props) => { > 見込 - + { + if (!haveThrough) return; + LayoutAnimation.configureNext({ + duration: 200, + update: { type: "easeInEaseOut", springDamping: 0.6 }, + }); + setShowThrew(!showThrew); + }} + > { textAlignVertical: "center", opacity: haveThrough ? 1 : 0, }} - onPress={() => { - if (!haveThrough) return; - LayoutAnimation.configureNext({ - duration: 200, - update: { type: "easeInEaseOut", springDamping: 0.6 }, - }); - setShowThrew(!showThrew); - }} > (通過{showThrew ? "▼" : "▶"}) - + From b6ba770a8aba6f40d4ba51992f92f2d4355eda59 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 15:00:08 +0000 Subject: [PATCH 06/14] =?UTF-8?q?=E5=88=97=E8=BB=8A=E3=82=A2=E3=82=A4?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=81=AE=E4=BD=8D=E7=BD=AE=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfo/EachStopList.js | 2 +- .../EachTrainInfoCore.js | 12 +- .../findReversalPoints.js | 116 ++++-------------- 3 files changed, 32 insertions(+), 98 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js index 5ffecb7..f5d3fb6 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js @@ -107,7 +107,7 @@ export const EachStopList = ({ {station} - {points && points.findIndex((d) => d == index) >= 0 ? ( + {points ? ( 🚊 ) : null} {!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && ( diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index 0ef42bb..5c283d9 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -95,7 +95,7 @@ export const EachTrainInfoCore = ({ ); // 使用例 - const stopStationIDList = trainData.map((i) => { + const stopStationIDList = trainDataWidhThrough.map((i) => { const [station, se, time] = i.split(","); const Stations = stationList.map((a) => a.filter((d) => d.StationName == station) @@ -104,9 +104,7 @@ export const EachTrainInfoCore = ({ Stations && Stations.reduce((newArray, e) => { return newArray.concat(e); - }, []) - .filter((d) => d.StationNumber) - .map((d) => d.StationNumber); + }, []).map((d) => d.StationNumber); return StationNumbers; }); useEffect(() => { @@ -142,7 +140,6 @@ export const EachTrainInfoCore = ({ d.StationNumber > baseStationNumberFirst && d.StationNumber < baseStationNumberSecond ) { - console.log(d.Station_JP); allThroughStation.push(`${d.Station_JP},通過,`); setHaveThrough(true); reverse = false; @@ -151,7 +148,6 @@ export const EachTrainInfoCore = ({ d.StationNumber < baseStationNumberFirst && d.StationNumber > baseStationNumberSecond ) { - console.log(d.Station_JP); allThroughStation.push(`${d.Station_JP},通過,`); setHaveThrough(true); reverse = true; @@ -176,7 +172,7 @@ export const EachTrainInfoCore = ({ const points = trainPositionSwitch == "true" ? findReversalPoints(currentPosition, stopStationIDList) - : []; + : stopStationIDList.map(() => false); const trainName = useMemo(() => { if (!data.limited) return ""; const limitedArray = data.limited.split(":"); @@ -439,7 +435,7 @@ export const EachTrainInfoCore = ({ i, index, stationList, - points, + points: points ? points[index] : false, currentTrainData, openStationACFromEachTrainInfo, showThrew, diff --git a/lib/eachTrainInfoCoreLib/findReversalPoints.js b/lib/eachTrainInfoCoreLib/findReversalPoints.js index a7cd70e..353a75c 100644 --- a/lib/eachTrainInfoCoreLib/findReversalPoints.js +++ b/lib/eachTrainInfoCoreLib/findReversalPoints.js @@ -7,105 +7,43 @@ export const findReversalPoints = (array, stopStationIDList) => { if (!array instanceof Array) return []; if (!array) return []; if (array[0] instanceof Array) return []; - const arrayNumber = array.map((d) => ({ - line: d - .split("") - .filter((s) => "A" < s && s < "Z") - .join(""), - ID: d - .split("") - .filter((s) => "0" <= s && s <= "9") - .join(""), - })); - const stopStationIDListNumber = stopStationIDList.map((d) => { - if (!d) return { line: [], ID: [] }; - return { - line: d[0] - .split("") - .filter((s) => "A" < s && s < "Z") - .join(""), - ID: d[0] - .split("") - .filter((s) => "0" <= s && s <= "9") - .join(""), - }; - }); + // 完全一致 if (array.length == 1) { - const index = stopStationIDList.indexOf(array[0]); - if (index != -1) return [index]; - // 通過駅の場合 - for (let i = 0; i < stopStationIDListNumber.length - 1; i++) { - if (stopStationIDListNumber[i].ID < arrayNumber[0].ID) { - if (stopStationIDListNumber[i + 1].ID > arrayNumber[0].ID) { - return [i + 1]; - } - } - if (stopStationIDListNumber[i].ID > arrayNumber[0].ID) { - if (stopStationIDListNumber[i + 1].ID < arrayNumber[0].ID) { - return [i + 1]; - } - } + const index = stopStationIDList.map((d) => { + let a = false; + d.forEach((x) => { + if (x == array[0]) a = true; + }); + return a; + }); + if (index != -1) { + return index; } } // 駅間の場合 if (array.length == 2) { - const index1 = stopStationIDList.indexOf(array[0]); - const index2 = stopStationIDList.indexOf(array[1]); - if (index1 != -1 && index2 != -1) { - // 駅間で通過駅も無い場合 - if (index1 < index2) { - if (index1 + 1 == index2) { - return [index2]; - } else { - const returnArray = []; - for (let i = index1 + 1; i <= index2; i++) { - returnArray.push(i); - } - return returnArray; + + const allThroughStation = stopStationIDList.map((d) => { + if(array[0] == "M12" && array[1] == "Y09" || array[0] == "Y09" && array[1] == "M12"){ + if(d[0] == "M12"){ + return true; } + else return false; } - if (index1 > index2) { - if (index2 + 1 == index1) return [index1]; - else { - const returnArray = []; - for (let i = index2 + 1; i <= index1; i++) { - returnArray.push(i); - } - return returnArray; - } - } - } else { - const getNearStationID = (stationID) => { - for (let i = 0; i <= stopStationIDListNumber.length; i++) { - if (stopStationIDListNumber[i].ID < stationID) { - if (stopStationIDListNumber[i + 1].ID > stationID) { - return i + 1; - } - } - if (stopStationIDListNumber[i].ID > stationID) { - if (stopStationIDListNumber[i + 1].ID < stationID) { - return i + 1; - } - } - } - }; - let newIndex1 = index1; - let newIndex2 = index2; - if (index1 == -1) { - newIndex1 = getNearStationID(arrayNumber[0].ID); - } - if (index2 == -1) { - newIndex2 = getNearStationID(arrayNumber[1].ID); - } - if (newIndex1 && newIndex2) { - return [newIndex1, newIndex2]; + if (d[0] < array[0] && d[0] > array[1]) { + return true; + } else if (d[0] < array[1] && d[0] > array[0]) { + return true; + }else if (d[0] < array[0] && d[0] == array[1]) { + return true; + } else if (d[0] == array[1] && d[0] > array[0]) { + return true; } - // 通過駅の場合 - } - - return []; + return false; + }); + return allThroughStation; } } catch (e) { console.log(e); From 8726cf35b9a3e197e7a271cde53cbd530acad444 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 20 Oct 2024 12:21:35 +0000 Subject: [PATCH 07/14] =?UTF-8?q?=E5=88=97=E8=BB=8A=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfoCore.js | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index 5c283d9..e73893e 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -257,9 +257,41 @@ export const EachTrainInfoCore = ({ if (currentTrainData?.Pos.match("~")) { const pos = currentTrainData?.Pos.replace("(下り)", "") .replace("(上り)", "") + .replace("(徳島線)", "") + .replace("(高徳線)", "") .split("~"); const direction = parseInt(currentTrainData?.Direction) || 0; - if (direction == 0) { + if (pos[0] == "児島" && pos[1] == "宇多津") { + setCurrentPosition(["M12", "Y09"]); + return; + } else if (pos[1] == "児島" && pos[0] == "宇多津") { + setCurrentPosition(["Y09", "M12"]); + 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) { + if (direction == 0) setCurrentPosition(currentPos.reverse()); + else setCurrentPosition(currentPos); + } else if (direction == 0) { setCurrentPosition([ getStationID(pos[1], stationList), getStationID(pos[0], stationList), From c2c23d85fb08c2cf872b195f7f74d0de497430b9 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 02:48:25 +0000 Subject: [PATCH 08/14] =?UTF-8?q?=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/EachData.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index 6feb5e5..22dd788 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -141,7 +141,7 @@ export const EachData: FC = (props) => { { From bd1ea0857c5fd4c56dd75c0e395ed255b47097f5 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Wed, 23 Oct 2024 07:00:33 +0000 Subject: [PATCH 09/14] =?UTF-8?q?=E7=8F=BE=E5=9C=A8=E5=9C=B0=E3=82=B8?= =?UTF-8?q?=E3=83=A3=E3=83=B3=E3=83=97=E6=A9=9F=E8=83=BD=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfoCore.js | 27 ++++++++++++++++++- components/DynamicHeaderScrollView.js | 6 ++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index e73893e..3f362cf 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from "react"; +import React, { useEffect, useMemo, useRef, useState } from "react"; import { View, Text, @@ -7,6 +7,7 @@ import { useWindowDimensions, BackHandler, Linking, + LayoutAnimation, } from "react-native"; import { SheetManager } from "react-native-actions-sheet"; import { AS } from "../../storageControl"; @@ -173,6 +174,28 @@ export const EachTrainInfoCore = ({ trainPositionSwitch == "true" ? findReversalPoints(currentPosition, stopStationIDList) : stopStationIDList.map(() => false); + const [isJumped, setIsJumped] = useState(false); + useEffect(() => { + if (isJumped) return () => {}; + if (!points) return () => {}; + if (points.length == 0) return () => {}; + const position = points.findIndex((d) => d == true); + if (position == -1) return () => {}; + if (trainDataWidhThrough[position].split(",")[1] == "通過") { + LayoutAnimation.configureNext({ + duration: 200, + update: { type: "easeInEaseOut", springDamping: 0.6 }, + }); + setShowThrew(true); + } + const count = position * 44-30; + // 0.5秒待機してからスクロール + setTimeout( + () => ScrollViewRef.current?.scrollTo({ y: count, animated: true }), + 500 + ); + setIsJumped(true); + }, [points]); const trainName = useMemo(() => { if (!data.limited) return ""; const limitedArray = data.limited.split(":"); @@ -198,6 +221,7 @@ export const EachTrainInfoCore = ({ const { height } = useWindowDimensions(); const { isLandscape } = useDeviceOrientationChange(); + const ScrollViewRef = useRef(); const [trueTrainID, setTrueTrainID] = useState(); useEffect(() => { @@ -389,6 +413,7 @@ export const EachTrainInfoCore = ({ from={from} styles={styles} actionSheetRef={actionSheetRef} + ScrollViewRef={ScrollViewRef} containerProps={{ style: { maxHeight: isLandscape ? height - 94 : (height / 100) * 70, diff --git a/components/DynamicHeaderScrollView.js b/components/DynamicHeaderScrollView.js index 5602473..180eae2 100644 --- a/components/DynamicHeaderScrollView.js +++ b/components/DynamicHeaderScrollView.js @@ -13,14 +13,13 @@ export const DynamicHeaderScrollView = (props) => { topStickyContent, styles, from, + ScrollViewRef, } = props; const [headerSize, setHeaderSize] = useState("default"); useLayoutEffect(() => { AS.getItem("headerSize") .then((res) => { - if (res) { - setHeaderSize(res); - } + if (res) setHeaderSize(res); }) .catch((e) => { AS.setItem("headerSize", "default"); @@ -160,6 +159,7 @@ export const DynamicHeaderScrollView = (props) => { stickyHeaderIndices={[1]} scrollEventThrottle={16} onScroll={onScroll} + ref={ScrollViewRef} > {topStickyContent && ( From 40b7437c87878c97c19126291d0c3d986339c116 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Wed, 23 Oct 2024 07:37:20 +0000 Subject: [PATCH 10/14] =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E7=99=BA=E5=8B=95=E6=9D=A1=E4=BB=B6=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../findReversalPoints.js | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/eachTrainInfoCoreLib/findReversalPoints.js b/lib/eachTrainInfoCoreLib/findReversalPoints.js index 353a75c..5981d75 100644 --- a/lib/eachTrainInfoCoreLib/findReversalPoints.js +++ b/lib/eachTrainInfoCoreLib/findReversalPoints.js @@ -17,31 +17,31 @@ export const findReversalPoints = (array, stopStationIDList) => { }); return a; }); - if (index != -1) { - return index; - } + if (index != -1) return index; } // 駅間の場合 if (array.length == 2) { - const allThroughStation = stopStationIDList.map((d) => { - if(array[0] == "M12" && array[1] == "Y09" || array[0] == "Y09" && array[1] == "M12"){ - if(d[0] == "M12"){ - return true; - } - else return false; - } - if (d[0] < array[0] && d[0] > array[1]) { - return true; - } else if (d[0] < array[1] && d[0] > array[0]) { - return true; - }else if (d[0] < array[0] && d[0] == array[1]) { - return true; - } else if (d[0] == array[1] && d[0] > array[0]) { - return true; - } + if ( + (array[0] == "M12" && array[1] == "Y09") || + (array[0] == "Y09" && array[1] == "M12") + ) + return d[0] == "M12" ? true : false; - return false; + let returndata = false; + d.forEach((x) => { + if (array[0] < x && x < array[1]) { + returndata = true; + } else if (array[0] < x && x == array[1]) { + returndata = true; + } else if (array[1] == x && x < array[0]) { + returndata = true; + } else if (array[1] < x && x < array[0]) { + returndata = true; + } + }); + + return returndata; }); return allThroughStation; } From 6440cff9283fa36b4cc13e3d4d561f5e43002079 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Wed, 23 Oct 2024 07:48:05 +0000 Subject: [PATCH 11/14] =?UTF-8?q?=E5=8B=95=E4=BD=9C=E5=8E=9F=E7=90=86?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ActionSheetComponents/EachTrainInfoCore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index 3f362cf..d0ee70f 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -188,7 +188,8 @@ export const EachTrainInfoCore = ({ }); setShowThrew(true); } - const count = position * 44-30; + if(position < 5) return() => {}; // 5駅以内の場合はスクロールしない + const count = position * 44-40; // 0.5秒待機してからスクロール setTimeout( () => ScrollViewRef.current?.scrollTo({ y: count, animated: true }), From eeb3993c712ac848d60e93b3972eeb3f95551e85 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Wed, 23 Oct 2024 08:00:09 +0000 Subject: [PATCH 12/14] =?UTF-8?q?css=E3=81=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfo/EachStopList.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js index f5d3fb6..9f3d451 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js @@ -107,9 +107,14 @@ export const EachStopList = ({ {station} - {points ? ( - 🚊 - ) : null} + + {points ? ( + + 🚊 + + ) : null} + + {!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && ( Date: Wed, 23 Oct 2024 14:30:47 +0000 Subject: [PATCH 13/14] =?UTF-8?q?=E5=80=A4=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ActionSheetComponents/EachTrainInfoCore.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index d0ee70f..f5ab02c 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -183,17 +183,17 @@ export const EachTrainInfoCore = ({ if (position == -1) return () => {}; if (trainDataWidhThrough[position].split(",")[1] == "通過") { LayoutAnimation.configureNext({ - duration: 200, + duration: 400, update: { type: "easeInEaseOut", springDamping: 0.6 }, }); setShowThrew(true); } if(position < 5) return() => {}; // 5駅以内の場合はスクロールしない - const count = position * 44-40; + const count = position * 44-50; // 0.5秒待機してからスクロール setTimeout( () => ScrollViewRef.current?.scrollTo({ y: count, animated: true }), - 500 + 400 ); setIsJumped(true); }, [points]); From 681f4d625ffdfedfc99b1d761f9880b908cc9ade Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Thu, 24 Oct 2024 17:21:50 +0000 Subject: [PATCH 14/14] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=81=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Settings/LayoutSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Settings/LayoutSettings.js b/components/Settings/LayoutSettings.js index 44b36bb..64af443 100644 --- a/components/Settings/LayoutSettings.js +++ b/components/Settings/LayoutSettings.js @@ -131,7 +131,7 @@ export const LayoutSettings = ({ bool={trainPosition} setBool={setTrainPosition} color="red" - str="列車の現在位置をアイコン表示" + str="列車の現在地表示/ジャンプ" />