メニュー表示機能追加
This commit is contained in:
30
Top.js
30
Top.js
@@ -13,9 +13,9 @@ import FavoriteList from "./components/FavoriteList.js";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { optionData } from "./lib/stackOption.js";
|
||||
import { useCurrentTrain } from "./stateBox/useCurrentTrain.js";
|
||||
import { AS } from "./storageControl.js";
|
||||
const Stack = createStackNavigator();
|
||||
export const Top = ({ navigation }) => {
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
export const Top = ({ navigation, navigationRef }) => {
|
||||
const { webview, getCurrentTrain } = useCurrentTrain();
|
||||
|
||||
//地図用
|
||||
@@ -24,14 +24,36 @@ export const Top = ({ navigation }) => {
|
||||
useEffect(() => {
|
||||
getStationList2().then(setMapsStationData);
|
||||
}, []);
|
||||
const [mapSwitch, setMapSwitch] = React.useState("false");
|
||||
const ASCore = ({ k, s, d }) =>
|
||||
AS.getItem(k)
|
||||
.then((d) => (d ? s(d) : AS.setItem(k, d)))
|
||||
.catch(() => AS.setItem(k, d));
|
||||
useEffect(() => {
|
||||
//地図スイッチ
|
||||
ASCore({ k: "mapSwitch", s: setMapSwitch, d: "false" });
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabLongPress", (e) => {
|
||||
const unsubscribe = navigation.addListener("tabLongPress", () => {
|
||||
navigation.navigate("favoriteList");
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabPress", () => {
|
||||
if (navigationRef.current?.getCurrentRoute().name == "Apps") {
|
||||
if (mapSwitch == "true") {
|
||||
navigation.navigate("trainMenu");
|
||||
} else {
|
||||
webview.current?.injectJavaScript(`AccordionClassEvent()`);
|
||||
}
|
||||
} else {
|
||||
navigation.navigate("Apps");
|
||||
}
|
||||
});
|
||||
return unsubscribe;
|
||||
}, [navigation, mapSwitch]);
|
||||
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
|
Reference in New Issue
Block a user