近くの駅の情報がとりあえず出るようになった
This commit is contained in:
parent
6d51db98fa
commit
2c505c4b17
21
menu.js
21
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);
|
||||
@ -105,6 +107,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
|
||||
const [allStationData, setAllStationData] = useState([]);
|
||||
useEffect(() => {
|
||||
if (stationListMode == "position") {
|
||||
console.log(currentStation);
|
||||
setAllStationData(
|
||||
[currentStation].filter((d) => d != undefined)
|
||||
);
|
||||
@ -112,7 +115,6 @@ export default function Menu({ getCurrentTrain, scrollRef }) {
|
||||
setAllStationData(
|
||||
[currentStation, ...favoriteStation].filter((d) => d != undefined)
|
||||
);
|
||||
|
||||
}
|
||||
}, [currentStation, favoriteStation, stationListMode]);
|
||||
useEffect(() => {
|
||||
@ -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
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user