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) => {