最後の駅リスト選択を維持するように変更

This commit is contained in:
harukin-expo-dev-env 2025-05-06 16:27:42 +00:00
parent 7ca4cf95e6
commit 6a58263e94
2 changed files with 15 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import { AS } from "@/storageControl";
import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs";
import React, { useEffect, useRef } from "react";
import { View, TouchableOpacity, Text, LayoutAnimation } from "react-native";
@ -49,11 +50,15 @@ export const CarouselTypeChanger = ({
if (!position) return;
returnToDefaultMode();
setStationListMode("position");
AS.setItem("stationListMode", "position");
setSelectedCurrentStation(0);
}}
onPress={() => {
if (!position) return;
returnToDefaultMode();
setStationListMode("position");
AS.setItem("stationListMode", "position");
setSelectedCurrentStation(0);
}}
>
<Ionicons
@ -108,12 +113,14 @@ export const CarouselTypeChanger = ({
returnToDefaultMode();
// お気に入りリスト更新
setStationListMode("favorite");
AS.setItem("stationListMode", "favorite");
setSelectedCurrentStation(0);
}}
onPress={() => {
returnToDefaultMode();
// お気に入りリスト更新
setStationListMode("favorite");
AS.setItem("stationListMode", "favorite");
setSelectedCurrentStation(0);
}}
>

View File

@ -29,6 +29,7 @@ import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs";
import { CarouselBox } from "./components/Menu/Carousel/CarouselBox";
import { CarouselTypeChanger } from "./components/Menu/Carousel/CarouselTypeChanger";
import { useUserPosition } from "./stateBox/useUserPosition";
import { AS } from "./storageControl";
configureReanimatedLogger({
level: ReanimatedLogLevel.error, // Set the log level to error
strict: true, // Reanimated runs in strict mode by default
@ -49,6 +50,13 @@ export default function Menu({
const [stationListMode, setStationListMode] = useState(
/*<"position"|"favorite">*/ "position"
);
useEffect(()=>{
AS.getItem("stationListMode").then((res) => {
setStationListMode(res);
}).catch((e) => {
// AS.setItem("stationListMode", "position");
});
}, []);
const mapsRef = useRef(null);
const returnToTop = (bool = true) => {
scrollRef.current.scrollTo({