我想知道如何从嵌套在材料底部标签栏上的堆栈导航器内的特定屏幕隐藏底部标签栏
这是我的堆栈导航器代码
import React from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import PondScreen from '../screens/PondScreen/PondScreen';
import PondDetailScreen from '../screens/PondScreen/PondDetailScreen';
const Stack = createStackNavigator();
export function PondStack() {
return (
<Stack.Navigator
initialRouteName="PondScreen"
headerMode="none"
mode="card"
>
<Stack.Screen
name="PondScreen"
component={PondScreen}
/>
<Stack.Screen
name="PondDetailScreen"
component={PondDetailScreen}
options={{
tabBarVisible: false
}}
/>
</Stack.Navigator>
);
}
这是我的材料底部选项卡导航器的代码
import React from 'react';
import { View } from 'react-native';
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import { Entypo, Feather } from '@expo/vector-icons';
import { PondStack } from './StackNavigators';
import StockScreen from '../screens/StockScreen';
import OrderScreen from '../screens/OrderScreen';
import SettingsScreen from '../screens/SettingsScreen';
const Tab = createMaterialBottomTabNavigator();
export default function BottomTab() {
return (
<Tab.Navigator
labeled={false}
initialRouteName="Pond"
activeColor="#EB3349"
inactiveColor="#888888"
backBehavior="none"
shifting={true}
barStyle={{
backgroundColor: '#FFFFFF'
}}
>
<Tab.Screen
name="Pond"
component={PondStack}
options={{
tabBarIcon: ({ color}) => (
<View style={{ flex: 1 }}>
<Entypo name="air" color={color} size={20} />
</View>
)
}}
/>
<Tab.Screen
name="Stock"
component={StockScreen}
options={{
tabBarIcon: ({ color }) => (
<View style={{ flex: 1 }}>
<Feather name="box" color={color} size={20} />
</View>
)
}}
/>
<Tab.Screen
name="Order"
component={OrderScreen}
options={{
tabBarIcon: ({ color}) => (
<View style={{ flex: 1 }}>
<Feather name="dollar-sign" color={color} size={20} />
</View>
)
}}
/>
<Tab.Screen
name="Settings"
component={SettingsScreen}
options={{
tabBarIcon: ({ color}) => (
<View style={{ flex: 1 }}>
<Feather name="settings" color={color} size={20} />
</View>
)
}}
/>
</Tab.Navigator>
)
}
我目前正在使用 Expo 来构建我的项目。
我的依赖项(package.json)
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.5",
"@react-navigation/material-bottom-tabs": "^5.0.0",
"@react-navigation/native": "^5.0.0",
"@react-navigation/stack": "^5.0.0",
"@types/react-native": "^0.61.12",
"expo": "~36.0.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-gesture-handler": "~1.5.0",
"react-native-paper": "^3.6.0",
"react-native-raw-bottom-sheet": "^2.0.6",
"react-native-reanimated": "~1.4.0",
"react-native-safe-area-context": "0.6.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"babel-preset-expo": "~8.0.0"
},
"private": true
}