94 lines
3.0 KiB
JavaScript
94 lines
3.0 KiB
JavaScript
import React, { useEffect } from "react";
|
|
import { createStackNavigator } from "@react-navigation/stack";
|
|
import { SheetManager } from "react-native-actions-sheet";
|
|
import { AS } from "./storageControl";
|
|
import TrainBase from "./components/trainbaseview";
|
|
import HowTo from "./howto";
|
|
import Menu from "./menu";
|
|
import News from "./components/news";
|
|
import Setting from "./components/Settings/settings";
|
|
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
|
import { optionData } from "./lib/stackOption";
|
|
import AllTrainDiagramView from "./components/AllTrainDiagramView";
|
|
import { useCurrentTrain } from "./stateBox/useCurrentTrain";
|
|
import { useNavigation } from "@react-navigation/native";
|
|
import { news } from "./config/newsUpdate";
|
|
const Stack = createStackNavigator();
|
|
|
|
export function MenuPage() {
|
|
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
|
const { getCurrentTrain } = useCurrentTrain();
|
|
const navigation = useNavigation();
|
|
const { addListener } = navigation;
|
|
useEffect(() => {
|
|
AS.getItem("startPage")
|
|
.then((res) => {
|
|
if (res == "true") navigation.navigate("positions");
|
|
})
|
|
.catch((e) => {
|
|
//6.0以降false
|
|
AS.setItem("startPage", "false");
|
|
});
|
|
|
|
//ニュース表示
|
|
AS.getItem("status")
|
|
.then((d) => {
|
|
if (d != news) navigation.navigate("topMenu", { screen: "news" });
|
|
})
|
|
.catch(() => navigation.navigate("topMenu", { screen: "news" }));
|
|
AS.getItem("isSetIcon")
|
|
.then((isSetIcon) => {
|
|
if (isSetIcon == "true") SheetManager.show("TrainIconUpdate");
|
|
})
|
|
.catch((error) => console.error("Error fetching icon setting:", error));
|
|
}, []);
|
|
useEffect(() => {
|
|
const unsubscribe = addListener("tabPress", (e) => {
|
|
AS.getItem("favoriteStation")
|
|
.then((d) => {
|
|
const returnData = JSON.parse(d);
|
|
if (favoriteStation.toString() != d) {
|
|
setFavoriteStation(returnData);
|
|
}
|
|
})
|
|
.catch((d) => console.log(d));
|
|
});
|
|
|
|
return unsubscribe;
|
|
}, [navigation]);
|
|
return (
|
|
<Stack.Navigator>
|
|
<Stack.Screen
|
|
name="menu"
|
|
options={{
|
|
headerShown: false,
|
|
gestureEnabled: true,
|
|
headerTransparent: true,
|
|
}}
|
|
children={() => <Menu getCurrentTrain={getCurrentTrain} />}
|
|
/>
|
|
<Stack.Screen name="news" options={optionData} component={News} />
|
|
<Stack.Screen
|
|
name="setting"
|
|
options={{
|
|
...optionData,
|
|
gestureEnabled: false,
|
|
cardOverlayEnabled: true,
|
|
}}
|
|
component={Setting}
|
|
/>
|
|
<Stack.Screen
|
|
name="trainbase"
|
|
options={{ ...optionData }}
|
|
component={TrainBase}
|
|
/>
|
|
<Stack.Screen
|
|
name="AllTrainIDList"
|
|
options={{ ...optionData, gestureEnabled: false }}
|
|
component={AllTrainDiagramView}
|
|
/>
|
|
<Stack.Screen name="howto" options={optionData} component={HowTo} />
|
|
</Stack.Navigator>
|
|
);
|
|
}
|