【发布时间】:2020-02-18 16:02:39
【问题描述】:
从抽屉项目中按下时,我必须导航到特定选项卡。我搜索了很多,但找不到与我的问题有关的任何内容
我尝试关注此导航操作链接,但不知道如何实现它 Navigate to specific tab from Drawer Navigator.
const TabNavigator = createMaterialTopTabNavigator(
{
Upcoming: { screen: UpcomingScreen },
Accepted: { screen: AcceptedScreen },
Ongoing: { screen: OngoingScreen },
Completed: { screen: CompletedScreen },
},
);
const Screen1_StackNavigator = createStackNavigator({
First: {
screen: TabNavigator,
},
});
const DrawerNavigatorExample = createDrawerNavigator({
Screen1: {
//Title
screen: Screen1_StackNavigator,
navigationOptions: {
drawerLabel: 'Upcoming Trips',
labelStyle: {
fontFamily: Fonts.LatoLight,
fontWeight: '200',
},
drawerIcon: () => (
// <Icon name="align-center" size={20} color="#365888" />
<Image style={{height: 20, width: 21}} source={require('./images/calendar.png')} />
)
},
},
Screen2: {
//Title
screen: Screen2_StackNavigator,
navigationOptions: {
drawerLabel: () => null,
},
},
Screen3: {
//Title
screen: Screen1_StackNavigator,
navigationOptions: {
drawerLabel: 'Accepted Trips',
labelStyle: {
fontFamily: Fonts.LatoLight,
fontWeight: '200',
},
drawerIcon: () => (
// <Icon name="align-center" size={20} color="#365888" />
<Image style={{height: 22, width: 22}} source={require('./images/sticker.png')} />
)
},
},
Screen4: {
//Title
screen: Screen1_StackNavigator,
navigationOptions: {
drawerLabel: 'Ongoing Trips',
labelStyle: {
fontFamily: Fonts.LatoLight,
fontWeight: 'normal'
},
drawerIcon: () => (
// <Icon name="align-center" size={20} color="#365888" />
<Image style={{height: 22, width: 22}} source={require('./images/navigator.png')} />
)
},
},
Screen5: {
//Title
screen: Screen1_StackNavigator,
navigationOptions: {
drawerLabel: 'Completed Trips',
labelStyle: {
fontFamily: Fonts.LatoLight,
fontWeight: 'normal'
},
drawerIcon: () => (
// <Icon name="align-center" size={20} color="#365888" />
<Image style={{height: 24, width: 20}} source={require('./images/checklist.png')} />
)
},
},
})
当我按下抽屉菜单上的“Screen3”时,它应该导航到选项卡导航器中的“已接受”屏幕。当我按下抽屉菜单上的“Screen4”时,它应该导航到选项卡导航器中的“正在进行”屏幕。当我在抽屉菜单上按“Screen5”时,它应该导航到选项卡导航器中的“已完成”屏幕。有什么办法可以实现吗?谢谢
【问题讨论】:
标签: react-native react-navigation react-navigation-stack react-navigation-drawer react-native-tabnavigator