menuの変数名を変更

This commit is contained in:
harukin-expo-dev-env 2025-04-13 16:56:47 +00:00
parent 35bb460b54
commit 7232c40af1

46
menu.js
View File

@ -103,40 +103,40 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
const [nearPositionStation, setNearPositionStation] = useState(undefined); //第三要素
const carouselRef = useRef();
const [selectedCurrentStation, setSelectedCurrentStation] = useState(0);
const [listIndex, setListIndex] = useState(0);
const [allStationData, setAllStationData] = useState([]);
const [listUpStation, setListUpStation] = useState([]);
useEffect(() => {
if (stationListMode == "position") {
console.log(nearPositionStation);
setAllStationData([nearPositionStation].filter((d) => d != undefined));
setListUpStation([nearPositionStation].filter((d) => d != undefined));
} else {
setAllStationData(favoriteStation.filter((d) => d != undefined));
setListUpStation(favoriteStation.filter((d) => d != undefined));
}
}, [nearPositionStation, favoriteStation, stationListMode]);
useEffect(() => {
if (allStationData.length == 0) {
setSelectedCurrentStation(0);
if (listUpStation.length == 0) {
setListIndex(0);
return;
}
if (allStationData[selectedCurrentStation] == undefined) {
const count = selectedCurrentStation - 1;
setSelectedCurrentStation(count);
if (listUpStation[listIndex] == undefined) {
const count = listIndex - 1;
setListIndex(count);
}
}, [selectedCurrentStation, nearPositionStation, allStationData]);
}, [listIndex, nearPositionStation, listUpStation]);
useEffect(() => {
if (!carouselRef.current) return;
carouselRef?.current.scrollTo({
count: selectedCurrentStation - carouselRef.current.getCurrentIndex(),
count: listIndex - carouselRef.current.getCurrentIndex(),
animated: true,
});
}, [selectedCurrentStation]);
}, [listIndex]);
useEffect(() => {
if (originalStationList == undefined) return;
if (allStationData.length == 0) return;
if (allStationData[selectedCurrentStation] == undefined) return;
const { lat, lng } = allStationData[selectedCurrentStation][0];
if (listUpStation.length == 0) return;
if (listUpStation[listIndex] == undefined) return;
const { lat, lng } = listUpStation[listIndex][0];
const mapRegion = {
latitude: lat,
longitude: lng,
@ -144,7 +144,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
longitudeDelta: 0.05,
};
mapsRef.current.animateToRegion(mapRegion, 1000);
}, [selectedCurrentStation, nearPositionStation, allStationData, mapsRef]);
}, [listIndex, nearPositionStation, listUpStation, mapsRef]);
return (
<View
style={{
@ -190,25 +190,25 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
mapsRef,
stationListMode,
setStationListMode,
setSelectedCurrentStation,
setSelectedCurrentStation: setListIndex,
}}
/>
{allStationData.length != 0 && originalStationList.length != 0 && (
{listUpStation.length != 0 && originalStationList.length != 0 && (
<>
<CarouselBox
{...{
originalStationList,
allStationData,
allStationData: listUpStation,
currentStation: nearPositionStation,
setSelectedCurrentStation,
setSelectedCurrentStation: setListIndex,
carouselRef,
selectedCurrentStation,
selectedCurrentStation: listIndex,
navigate,
}}
/>
{allStationData[selectedCurrentStation] && (
{listUpStation[listIndex] && (
<LED_vision
station={allStationData[selectedCurrentStation]}
station={listUpStation[listIndex]}
getCurrentTrain={getCurrentTrain}
navigate={navigate}
openStationACFromEachTrainInfo={() => {}}