From 7f67fc6cc840cd85bb9141e60a04039081faeec1 Mon Sep 17 00:00:00 2001 From: harukin-OneMix4 Date: Tue, 27 Jun 2023 21:34:20 +0900 Subject: [PATCH] =?UTF-8?q?menu=E5=81=B4=E3=81=AB=E3=82=82=E5=88=97?= =?UTF-8?q?=E8=BB=8A=E8=A1=A8=E7=A4=BA=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/menu.js b/menu.js index 390e858..0ccfaf4 100644 --- a/menu.js +++ b/menu.js @@ -34,6 +34,7 @@ import { TicketBox } from "./components/atom/TicketBox"; import { TextBox } from "./components/atom/TextBox"; import { getStationList, lineList } from "./lib/getStationList"; import { JRSTraInfo } from "./components/ActionSheetComponents/JRSTraInfo"; +import { EachTrainInfo } from "./components/ActionSheetComponents/EachTrainInfo"; import useInterval from "./lib/useInterval"; export default function Menu(props) { @@ -55,6 +56,13 @@ export default function Menu(props) { }); }, []); + //列車情報表示関連 + const EachTrainInfoAsSR = useRef(null); + const [trainInfo, setTrainInfo] = useState({ + trainNum: undefined, + limited: undefined, + }); + const getCurrentPosition = () => { if (locationStatus !== "granted") return () => {}; Location.getCurrentPositionAsync({}).then((location) => @@ -124,13 +132,11 @@ export default function Menu(props) { const allStationData = [currentStation, ...favoriteStation].filter( (d) => d != undefined ); - console.log(allStationData); useEffect(() => { if (allStationData.length == 0) { setSelectedCurrentStation(0); return; } - console.log(allStationData[selectedCurrentStation]); if (allStationData[selectedCurrentStation] == undefined) { const count = selectedCurrentStation - 1; setSelectedCurrentStation(count); @@ -138,12 +144,35 @@ export default function Menu(props) { }, [selectedCurrentStation, currentStation, favoriteStation]); useEffect(() => { if (!carouselRef.current) return; - console.log(carouselRef.current); if (carouselRef.current?._itemToSnapTo != selectedCurrentStation) { carouselRef.current.snapToItem(0); carouselRef.current.snapToItem(selectedCurrentStation); } }, [selectedCurrentStation]); + + const openStationACFromEachTrainInfo = (stationName) => { + EachTrainInfoAsSR.current?.hide(); + const findStationEachLine = (selectLine) => { + let NearStation = selectLine.filter((d) => d.Station_JP == stationName); + return NearStation; + }; + let returnDataBase = lineList + .map((d) => findStationEachLine(originalStationList[d])) + .filter((d) => d.length > 0) + .reduce((pre, current) => { + pre.push(...current); + return pre; + }, []); + if (returnDataBase.length) { + setStationBoardData(returnDataBase); + sleep(30, function () { + StationBoardAcSR.current?.show(); + }); + } else { + setStationBoardData(undefined); + StationBoardAcSR.current?.hide(); + } + }; return ( + ); }