Topのルーティング関係を最適化
This commit is contained in:
parent
720b627011
commit
b6e24e08cb
8
Apps.js
8
Apps.js
@ -23,14 +23,16 @@ import { useDeviceOrientationChange } from "./stateBox/useDeviceOrientationChang
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
import TrainMenu from "./components/trainMenu";
|
||||
import { EachTrainInfoCore } from "./components/ActionSheetComponents/EachTrainInfoCore";
|
||||
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
/*
|
||||
import StatusbarDetect from './StatusbarDetect';
|
||||
var Status = StatusbarDetect(); */
|
||||
|
||||
export default function Apps({ navigation, webview, stationData }) {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
export default function Apps({ stationData }) {
|
||||
const { webview, currentTrain } = useCurrentTrain();
|
||||
const { height, width } = useWindowDimensions();
|
||||
const { navigate } = navigation;
|
||||
const { navigate } = useNavigation();
|
||||
var urlcache = "";
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
const { isLandscape, setIsLandscape } = useDeviceOrientationChange();
|
||||
|
57
Top.js
57
Top.js
@ -10,14 +10,9 @@ import HowTo from "./howto";
|
||||
import News from "./components/news.js";
|
||||
import TrainMenu from "./components/trainMenu.js";
|
||||
import FavoriteList from "./components/FavoriteList.js";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { optionData } from "./lib/stackOption.js";
|
||||
import { useCurrentTrain } from "./stateBox/useCurrentTrain.js";
|
||||
const Stack = createStackNavigator();
|
||||
export const Top = ({ navigation }) => {
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
const { webview, getCurrentTrain } = useCurrentTrain();
|
||||
|
||||
//地図用
|
||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||
|
||||
@ -42,16 +37,8 @@ export const Top = ({ navigation }) => {
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Apps
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
children={() => <Apps stationData={mapsStationData} />}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
@ -59,41 +46,23 @@ export const Top = ({ navigation }) => {
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="news" options={optionData}>
|
||||
{(props) => <News {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="trainMenu" options={optionData}>
|
||||
{(props) => (
|
||||
<TrainMenu
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
component={TrainBase}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
|
||||
<Stack.Screen name="howto" options={optionData} component={HowTo} />
|
||||
<Stack.Screen name="news" options={optionData} component={News} />
|
||||
|
||||
<Stack.Screen
|
||||
name="trainMenu"
|
||||
options={optionData}
|
||||
children={() => <TrainMenu stationData={mapsStationData} />}
|
||||
/>
|
||||
|
||||
<Stack.Screen
|
||||
name="favoriteList"
|
||||
options={{ ...optionData, gestureEnabled: false }}
|
||||
>
|
||||
{(props) => (
|
||||
<FavoriteList
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
children={() => <FavoriteList stationData={mapsStationData} />}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
};
|
||||
|
@ -3,9 +3,12 @@ import { View, Text, TouchableOpacity, ScrollView } from "react-native";
|
||||
import { ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import { useFavoriteStation } from "../stateBox/useFavoriteStation";
|
||||
export default function FavoriteList({ navigation, webview, stationData }) {
|
||||
const { navigate } = navigation;
|
||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
export default function FavoriteList({ stationData }) {
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
const { webview } = useCurrentTrain();
|
||||
const { navigate } = useNavigation();
|
||||
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
|
@ -4,11 +4,10 @@ import { WebView } from "react-native-webview";
|
||||
import StatusbarDetect from "../StatusbarDetect";
|
||||
import { AS } from "../storageControl";
|
||||
import { news } from "../config/newsUpdate";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
var Status = StatusbarDetect();
|
||||
export default function News(props) {
|
||||
const {
|
||||
navigation: { navigate },
|
||||
} = props;
|
||||
export default function News() {
|
||||
const { navigate } = useNavigation();
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
<WebView
|
||||
|
@ -2,13 +2,12 @@ import React, { useRef } from "react";
|
||||
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
||||
import MapView, { Marker } from "react-native-maps";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
export default function TrainMenu({
|
||||
navigation: { navigate },
|
||||
webview,
|
||||
stationData,
|
||||
style,
|
||||
}) {
|
||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
export default function TrainMenu({ stationData, style }) {
|
||||
const { webview } = useCurrentTrain();
|
||||
const mapRef = useRef();
|
||||
const { navigate } = useNavigation();
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC", ...style }}>
|
||||
<MapView
|
||||
|
Loading…
Reference in New Issue
Block a user