お気に入り/現在地切り替え機能を仮作成
This commit is contained in:
18
menu.js
18
menu.js
@@ -35,6 +35,7 @@ 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 mapsRef = useRef(null);
|
||||
const MapHeight =
|
||||
height -
|
||||
@@ -62,7 +63,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
|
||||
const makeCurrentStation = (location) => {
|
||||
if (!originalStationList) return () => {};
|
||||
const findStationEachLine = (selectLine) => {
|
||||
const searchArea = 0.002;
|
||||
const searchArea = stationListMode == "position" ? 0.1 : 0.002;
|
||||
const _calcDistance = (from, to) => {
|
||||
let lat = Math.abs(from.lat - to.lat);
|
||||
let lng = Math.abs(from.lng - to.lng);
|
||||
@@ -80,7 +81,9 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
|
||||
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.filter((d) => {
|
||||
console.log(d);
|
||||
return d.length > 0})
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
@@ -102,10 +105,17 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
|
||||
|
||||
const [allStationData, setAllStationData] = useState([]);
|
||||
useEffect(() => {
|
||||
if(stationListMode == "position"){
|
||||
setAllStationData(
|
||||
[currentStation].filter((d) => d != undefined)
|
||||
);
|
||||
}else{
|
||||
setAllStationData(
|
||||
[currentStation, ...favoriteStation].filter((d) => d != undefined)
|
||||
);
|
||||
}, [currentStation, favoriteStation]);
|
||||
|
||||
}
|
||||
}, [currentStation, favoriteStation,stationListMode]);
|
||||
useEffect(() => {
|
||||
if (allStationData.length == 0) {
|
||||
setSelectedCurrentStation(0);
|
||||
@@ -178,7 +188,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
|
||||
}}
|
||||
onPress={() => alert("地図をタップ")}
|
||||
/>
|
||||
<CarouselTypeChanger {...{ locationStatus, position, mapsRef }} />
|
||||
<CarouselTypeChanger {...{ locationStatus, position, mapsRef,stationListMode, setStationListMode,setSelectedCurrentStation }} />
|
||||
{allStationData.length != 0 && originalStationList.length != 0 && (
|
||||
<>
|
||||
<CarouselBox
|
||||
|
Reference in New Issue
Block a user