|
import React from 'react'; |
|
import { |
|
Dimensions, |
|
Platform, |
|
Text, |
|
} from 'react-native'; |
|
|
|
// Modified the imports to rely on public api from react-navigation |
|
import { createNavigationContainer, createNavigator, TabRouter } from 'react-navigation'; |
|
|
|
// Modified the imports to rely on private api from react-navigation |
|
import DrawerScreen from 'react-navigation/src/views/Drawer/DrawerScreen'; |
|
import DrawerView from 'react-navigation/src/views/Drawer/DrawerView'; |
|
|
|
import Globals from '../utils/Globals'; |
|
|
|
const DefaultDrawerConfig = { |
|
/* |
|
* Default drawer width is screen width - header width |
|
* https://material.io/guidelines/patterns/navigation-drawer.html |
|
*/ |
|
drawerWidth: Dimensions.get('window').width - (Platform.OS === 'android' ? 56 : 64), |
|
contentComponent: DrawerView.Items, |
|
// contentComponent: (<Text>Olá amigos</Text>), |
|
// drawerPosition: 'left', |
|
contentOptions: { |
|
activeTintColor: Globals.app.color, |
|
style: { |
|
// marginTop: 150, |
|
} |
|
} |
|
}; |
|
|
|
const CustomDrawerNavigator = ( |
|
routeConfigs, |
|
config, |
|
) => { |
|
const mergedConfig = { ...DefaultDrawerConfig, ...config }; |
|
const { |
|
containerConfig, |
|
drawerWidth, |
|
contentComponent, |
|
contentOptions, |
|
drawerPosition, |
|
...tabsConfig |
|
} = mergedConfig; |
|
const contentRouter = TabRouter(routeConfigs, tabsConfig); |
|
const drawerRouter = TabRouter({ |
|
DrawerClose: { |
|
screen: createNavigator(contentRouter)((props) => |
|
<DrawerScreen {...props} /> |
|
), |
|
}, |
|
DrawerOpen: { |
|
screen: () => null, |
|
}, |
|
}, { |
|
initialRouteName: 'DrawerClose', |
|
}); |
|
return createNavigationContainer(createNavigator(drawerRouter)((props) => |
|
<DrawerView |
|
{...props} |
|
style={{ |
|
backgroundColor: Globals.app.backgroundColorLight, |
|
}} |
|
drawerWidth={drawerWidth} |
|
contentComponent={contentComponent} |
|
contentOptions={contentOptions} |
|
drawerPosition={drawerPosition} |
|
/> |
|
), containerConfig); |
|
}; |
|
|
|
export default CustomDrawerNavigator; |