I'm creating an react-native application and i'm using for navigation react-navigation.
I'm trying to get the following behavior:
Have a main Drawer menu, if i navigate to a item from Drawer, the drawer should close, navigate to scene and have the same navbar for all items in the drawer. In one item i have a tab navigator.
I actual implementation the only problem is: the drawer is not closing on item click. Any suggestion?
And if i navigate from a scene to another scene (this scene is not an drawer item), i can navigate to that scene but my header (navbar) is not changing and i don't have the back button. Any suggestion?
This is what i have done for moment, but is not working as expected.
import React from 'react' import { createStackNavigator, createSwitchNavigator, createDrawerNavigator, createMaterialTopTabNavigator, } from 'react-navigation' import { StyleSheet } from 'react-native' import { Icon } from 'react-native-elements' import { AppConfig } from '../constants' import { AppSizes, AppColors } from '../theme' import DrawerMenu from './drawerMenu' // import DrawerScreen from './DrawerScreen' // Scenes import LaunchContainer from '../containers/Launch' import LoginContainer from '../containers/Login' import HomeContainer from '../containers/Home' import RoomsHistoryContainer from '../containers/RoomsHistory' import LogoutContainer from '../containers/Logout' import ChatContainer from '../containers/Chat' const styles = StyleSheet.create({ iconStyle: { marginLeft: 10, }, }) const TabStack = createMaterialTopTabNavigator( { Conversation: { screen: RoomsHistoryContainer, navigationOptions: { title: 'Conversatii', }, }, Comunitate: { screen: LaunchContainer, navigationOptions: { title: 'Comunitate', }, }, Chatroom: { screen: LaunchContainer, navigationOptions: { title: 'Chatroom', }, }, }, { tabBarOptions: { style: { backgroundColor: AppColors.tabbar.background, }, activeTintColor: AppColors.tabbar.activeTintColor, inactiveTintColor: AppColors.tabbar.inactiveTintColor, indicatorStyle: { backgroundColor: AppColors.tabbar.indicatorColor, }, }, } ) const AppStack = createStackNavigator( { Home: { screen: HomeContainer }, Calendar: { screen: LaunchContainer }, Comunitate: { screen: TabStack, navigationOptions: { title: 'Comunitate' }, }, Logout: { screen: LogoutContainer }, ChatMessage: { screen: ChatContainer }, }, { headerMode: 'float', navigationOptions: ({ navigation }) => ({ ...AppConfig.navbarProps, title: 'My app', headerLeft: ( navigation.toggleDrawer()} /> ), }), } ) const DrawerStack = createDrawerNavigator( { Main: { screen: AppStack }, }, { contentComponent: DrawerMenu, contentOptions: { activeTintColor: 'white', activeBackgroundColor: 'white', }, drawerWidth: AppSizes.screen.width > 250 ? AppSizes.screen.width - 80 : 250, } ) const AuthStack = createStackNavigator( { SignIn: { screen: LoginContainer, navigationOptions: { title: 'Login', }, }, SignUp: { screen: LoginContainer, navigationOptions: { title: 'Logout', }, }, }, { headerMode: 'none', } ) const AppNavigator = createSwitchNavigator( { Launch: { screen: LaunchContainer }, App: { screen: DrawerStack }, Auth: { screen: AuthStack }, }, { initialRouteName: 'Launch', } ) export default AppNavigator