全コンポーネントをcomponentからchildへ移動

This commit is contained in:
harukin-DeskMini 2023-01-30 03:02:00 +09:00
parent 556b04e3b0
commit 746c996cba

37
App.js
View File

@ -10,10 +10,10 @@ import { Platform, UIManager } from "react-native";
import { UpdateAsync } from "./UpdateAsync.js"; import { UpdateAsync } from "./UpdateAsync.js";
import { getStationList2 } from "./lib/getStationList2"; import { getStationList2 } from "./lib/getStationList2";
import Apps from "./Apps"; import Apps from "./Apps";
import tndView from "./ndView"; import TNDView from "./ndView";
import TrainBase from "./trainbaseview"; import TrainBase from "./trainbaseview";
import HowTo from "./howto"; import HowTo from "./howto";
import menu from "./menu"; import Menu from "./menu";
import News from "./components/news.js"; import News from "./components/news.js";
import Setting from "./components/settings.js"; import Setting from "./components/settings.js";
import TrainMenu from "./components/trainMenu.js"; import TrainMenu from "./components/trainMenu.js";
@ -35,40 +35,43 @@ export default function App() {
<Tab.Navigator> <Tab.Navigator>
<Tab.Screen <Tab.Screen
name="login" name="login"
component={Top}
options={{ options={{
tabBarLabel: "位置情報", tabBarLabel: "位置情報",
headerTransparent: true, headerTransparent: true,
gestureEnabled: true, gestureEnabled: true,
tabBarIcon: initIcon("barchart", "AntDesign"), tabBarIcon: initIcon("barchart", "AntDesign"),
}} }}
/> >
{(props) => <Top {...props} />}
</Tab.Screen>
<Tab.Screen <Tab.Screen
name="menuPage" name="menuPage"
component={menuPage}
options={{ options={{
tabBarLabel: "リンク", tabBarLabel: "リンク",
headerTransparent: true, headerTransparent: true,
gestureEnabled: true, gestureEnabled: true,
tabBarIcon: initIcon("ios-radio", "Ionicons"), tabBarIcon: initIcon("ios-radio", "Ionicons"),
}} }}
/> >
{(props) => <MenuPage {...props} />}
</Tab.Screen>
<Tab.Screen <Tab.Screen
name="home" name="home"
component={tndView}
options={{ options={{
tabBarLabel: "運行情報", tabBarLabel: "運行情報",
headerTransparent: true, headerTransparent: true,
gestureEnabled: true, gestureEnabled: true,
tabBarIcon: initIcon("md-train", "Ionicons"), tabBarIcon: initIcon("md-train", "Ionicons"),
}} }}
/> >
{(props) => <TNDView {...props} />}
</Tab.Screen>
</Tab.Navigator> </Tab.Navigator>
</NavigationContainer> </NavigationContainer>
); );
} }
const initIcon = (name, type, props) => { const initIcon = (name, type) => {
switch (type) { switch (type) {
case "Ionicons": case "Ionicons":
return ({ focused, color, size }) => ( return ({ focused, color, size }) => (
@ -161,22 +164,24 @@ const Top = ({ navigation }) => {
</Stack.Navigator> </Stack.Navigator>
); );
}; };
function menuPage() { function MenuPage() {
return ( return (
<Stack.Navigator> <Stack.Navigator>
<Stack.Screen <Stack.Screen
name="menu" name="menu"
component={menu}
options={{ options={{
headerShown: false, headerShown: false,
gestureEnabled: true, gestureEnabled: true,
headerTransparent: true, headerTransparent: true,
}} }}
/> >
<Stack.Screen name="setting" component={Setting} options={optionData} /> {(props) => <Menu {...props} />}
</Stack.Screen>
<Stack.Screen name="setting" options={optionData}>
{(props) => <Setting {...props} />}
</Stack.Screen>
<Stack.Screen <Stack.Screen
name="trainbase" name="trainbase"
component={TrainBase}
options={{ options={{
...TransitionPresets.ModalPresentationIOS, ...TransitionPresets.ModalPresentationIOS,
cardOverlayEnabled: true, cardOverlayEnabled: true,
@ -185,7 +190,9 @@ function menuPage() {
headerTransparent: true, headerTransparent: true,
gestureResponseDistance: { vertical: 300 }, gestureResponseDistance: { vertical: 300 },
}} }}
/> >
{(props) => <TrainBase {...props} />}
</Stack.Screen>
</Stack.Navigator> </Stack.Navigator>
); );
} }