我已经浏览了 SO 和 github 上关于反应导航的各种帖子,但其中大多数是反应原生堆栈导航器与抽屉导航器的组合。我找不到任何可以帮助解决我的问题的东西。
我想做的是我有一个带有五个屏幕的底部标签栏,可以很好地加载正确的数据,我想添加一个抽屉导航器以提供更多屏幕并具有不同的数据。我已经设法在标签导航器的顶部构建了抽屉导航器,但是当抽屉打开时,它与底部标签栏重叠,因此只要抽屉打开,底部标签导航就没有用了。在抽屉导航器下添加选项卡也会显示Tabs
为抽屉菜单中的选项之一。
我想要实现的是,1. 底部标签导航始终可见。2. 当抽屉打开时,抽屉菜单打开并且不重叠底部标签栏。3.抽屉菜单应该只有那些可以从抽屉菜单导航的屏幕。
下面是我的导航代码,
import React from 'react'
// Navigators
import { DrawerNavigator, StackNavigator, createBottomTabNavigator } from 'react-navigation'
// TabNavigator screens
import ProfileConnector from '../connectors/ProfileConnector'
import InboxConnector from '../connectors/InboxConnector'
import AttendanceConnector from '../connectors/AttendanceConnector'
import Results from '../layouts/results/Results'
import TimetableConnector from '../connectors/TimetableConnector'
import Icon from 'react-native-vector-icons/Entypo'
import {Dimensions} from 'react-native'
const deviceW = Dimensions.get('window').width
const basePx = 375
function px2dp(px) {
return px * deviceW / basePx
}
import Gallery from '../layouts/gallery/Gallery'
export const Tabs = createBottomTabNavigator({
Profile: {
screen: ProfileConnector,
navigationOptions: {
tabBarLabel: 'Profile',
tabBarIcon: ({tintColor}) => <Icon name="user" size={px2dp(22)} color={tintColor}/>,
},
},
Inbox: {
screen: InboxConnector,
navigationOptions: {
tabBarLabel: 'Inbox',
tabBarIcon: ({tintColor}) => <Icon name="inbox" size={px2dp(22)} color={tintColor}/>,
},
},
Attendance: {
screen: AttendanceConnector,
navigationOptions: {
tabBarLabel: 'Attendance',
tabBarIcon: ({tintColor}) => <Icon name="hand" size={px2dp(22)} color={tintColor}/>,
},
},
Timetable: {
screen: TimetableConnector,
navigationOptions: {
tabBarLabel: 'Timetable',
tabBarIcon: ({tintColor}) => <Icon name="calendar" size={px2dp(22)} color={tintColor}/>,
},
},
Results: {
screen: Results,
navigationOptions: {
tabBarLabel: 'Results',
tabBarIcon: ({tintColor}) => <Icon name="bar-graph" size={px2dp(22)} color={tintColor}/>,
},
},
}, {
initialRouteName: 'Inbox',
tabBarPosition: 'bottom',
swipeEnabled: true,
tabBarOptions: {
activeTintColor: 'teal',
inactiveTintColor: '#424949',
activeBackgroundColor: "white",
inactiveTintColor: '#424949',
labelStyle: { fontSize: 14 },
style : { height : 50}
}
});
export const Drawer = DrawerNavigator({
Tabs: {screen: Tabs},
Gallery: { screen: Gallery },
},{
drawerWidth: 250,
drawerPosition: 'left',
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle',
})
有人可以帮我吗?
谢谢,维克拉姆