From 2c505c4b17b266cc39eb2de27e137f4f69abd25a Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 16:17:15 +0000 Subject: [PATCH] =?UTF-8?q?=E8=BF=91=E3=81=8F=E3=81=AE=E9=A7=85=E3=81=AE?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=81=8C=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88?= =?UTF-8?q?=E3=81=9A=E5=87=BA=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=AA?= =?UTF-8?q?=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 33 ++++++++++++++++++++++----------- stateBox/useStationList.tsx | 1 - 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/menu.js b/menu.js index c41aa4d..015f5cb 100644 --- a/menu.js +++ b/menu.js @@ -35,7 +35,9 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const { bottom, left, right, top } = useSafeAreaInsets(); const tabBarHeight = useBottomTabBarHeight(); const [mapsOpacity, setMapsOpacity] = useState(false); - const [stationListMode, setStationListMode] = useState/*<"position"|"favorite">*/("position"); + const [stationListMode, setStationListMode] = useState( + /*<"position"|"favorite">*/ "position" + ); const mapsRef = useRef(null); const MapHeight = height - @@ -59,11 +61,11 @@ export default function Menu({ getCurrentTrain, scrollRef }) { useEffect(() => { if (!position) return () => {}; makeCurrentStation(position); - }, [position]); + }, [position, stationListMode]); const makeCurrentStation = (location) => { if (!originalStationList) return () => {}; const findStationEachLine = (selectLine) => { - const searchArea = stationListMode == "position" ? 0.1 : 0.002; + const searchArea = stationListMode == "position" ? 0.07 : 0.002; const _calcDistance = (from, to) => { let lat = Math.abs(from.lat - to.lat); let lng = Math.abs(from.lng - to.lng); @@ -104,17 +106,17 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const [allStationData, setAllStationData] = useState([]); useEffect(() => { - if(stationListMode == "position"){ + if (stationListMode == "position") { + console.log(currentStation); setAllStationData( [currentStation].filter((d) => d != undefined) ); - }else{ - setAllStationData( - [currentStation, ...favoriteStation].filter((d) => d != undefined) - ); - + } else { + setAllStationData( + [currentStation, ...favoriteStation].filter((d) => d != undefined) + ); } - }, [currentStation, favoriteStation,stationListMode]); + }, [currentStation, favoriteStation, stationListMode]); useEffect(() => { if (allStationData.length == 0) { setSelectedCurrentStation(0); @@ -186,7 +188,16 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }} onPress={() => alert("地図をタップ")} /> - + {allStationData.length != 0 && originalStationList.length != 0 && ( <> = ({ children }) => { getStationList().then(setOriginalStationList); }, []); const getStationDataFromId: (id: string) => any[] = (id) => { - console.log("id", id); let returnArray = []; Object.keys(originalStationList).forEach((key) => { originalStationList[key].forEach((station) => {