Appsのprops構文整理
This commit is contained in:
parent
7781cf43e8
commit
85519cf857
56
Apps.js
56
Apps.js
@ -9,10 +9,20 @@ import { MenuPage } from "./MenuPage.js";
|
|||||||
import { useAreaInfo } from "./stateBox/useAreaInfo.js";
|
import { useAreaInfo } from "./stateBox/useAreaInfo.js";
|
||||||
import "./components/ActionSheetComponents/sheets.js";
|
import "./components/ActionSheetComponents/sheets.js";
|
||||||
|
|
||||||
const Tab = createBottomTabNavigator();
|
|
||||||
export function AppContainer() {
|
export function AppContainer() {
|
||||||
|
const Tab = createBottomTabNavigator();
|
||||||
const { areaInfo, areaIconBadgeText } = useAreaInfo();
|
const { areaInfo, areaIconBadgeText } = useAreaInfo();
|
||||||
const navigationRef = React.useRef();
|
const navigationRef = React.useRef();
|
||||||
|
const getTabProps = (name, label, icon, iconFamily, tabBarBadge) => ({
|
||||||
|
name,
|
||||||
|
options: {
|
||||||
|
tabBarLabel: label,
|
||||||
|
headerTransparent: true,
|
||||||
|
gestureEnabled: true,
|
||||||
|
tabBarIcon: initIcon(icon, iconFamily),
|
||||||
|
tabBarBadge,
|
||||||
|
},
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<NavigationContainer name="Root" style={{ flex: 1 }} ref={navigationRef}>
|
<NavigationContainer name="Root" style={{ flex: 1 }} ref={navigationRef}>
|
||||||
<Tab.Navigator
|
<Tab.Navigator
|
||||||
@ -21,41 +31,25 @@ export function AppContainer() {
|
|||||||
lazy={false}
|
lazy={false}
|
||||||
>
|
>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="login"
|
{...getTabProps("login", "位置情報", "barchart", "AntDesign")}
|
||||||
options={{
|
children={(props) => <Top {...props} navigationRef={navigationRef} />}
|
||||||
tabBarLabel: "位置情報",
|
/>
|
||||||
headerTransparent: true,
|
|
||||||
gestureEnabled: true,
|
|
||||||
tabBarIcon: initIcon("barchart", "AntDesign"),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{(props) => <Top {...props} navigationRef={navigationRef} />}
|
|
||||||
</Tab.Screen>
|
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="menuPage"
|
{...getTabProps("menuPage", "リンク", "radio", "Ionicons")}
|
||||||
options={{
|
|
||||||
tabBarLabel: "リンク",
|
|
||||||
headerTransparent: true,
|
|
||||||
gestureEnabled: true,
|
|
||||||
tabBarIcon: initIcon("radio", "Ionicons"),
|
|
||||||
}}
|
|
||||||
component={MenuPage}
|
component={MenuPage}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="home"
|
{...getTabProps(
|
||||||
options={{
|
"home",
|
||||||
tabBarLabel: "運行情報",
|
"運行情報",
|
||||||
headerTransparent: true,
|
"train",
|
||||||
gestureEnabled: true,
|
"Ionicons",
|
||||||
tabBarIcon: initIcon("train", "Ionicons"),
|
areaInfo ? areaIconBadgeText : undefined
|
||||||
tabBarBadge: areaInfo ? areaIconBadgeText : undefined,
|
)}
|
||||||
}}
|
children={(props) => <TNDView {...props} />}
|
||||||
>
|
/>
|
||||||
{(props) => <TNDView {...props} />}
|
|
||||||
</Tab.Screen>
|
|
||||||
</Tab.Navigator>
|
</Tab.Navigator>
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user