近くの駅の情報がとりあえず出るようになった

This commit is contained in:
harukin-expo-dev-env 2025-04-13 16:17:15 +00:00
parent 6d51db98fa
commit 2c505c4b17
2 changed files with 22 additions and 12 deletions

27
menu.js
View File

@ -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{
} 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("地図をタップ")}
/>
<CarouselTypeChanger {...{ locationStatus, position, mapsRef,stationListMode, setStationListMode,setSelectedCurrentStation }} />
<CarouselTypeChanger
{...{
locationStatus,
position,
mapsRef,
stationListMode,
setStationListMode,
setSelectedCurrentStation,
}}
/>
{allStationData.length != 0 && originalStationList.length != 0 && (
<>
<CarouselBox

View File

@ -36,7 +36,6 @@ export const StationListProvider: FC<Props> = ({ 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) => {