Added drawerPosition prop to DrawerView. Fixes #87 (#89)

This commit is contained in:
Ferran Negre
2017-01-30 16:44:57 +00:00
committed by Satyajit Sahoo
parent c5720cafb4
commit 123bce5402
4 changed files with 12 additions and 1 deletions

3
.gitignore vendored
View File

@@ -2,6 +2,9 @@
.vscode/
jsconfig.json
# IntelliJ/Webstorm
.idea
# NodeJS
npm-debug.log
node_modules

View File

@@ -82,6 +82,7 @@ DrawerNavigator(RouteConfigs, DrawerNavigatorConfig)
### Drawer Navigator Options
- `drawerWidth` - Width of the drawer
- `drawerPosition` - Options are `left` or `right`. Default is `left` position.
- `contentComponent` - Component to use to render the navigation items. Receives the `navigation` prop for the drawer. Defaults to `DrawerView.Items`.
- `contentOptions` - Configure the drawer content, see below.

View File

@@ -31,6 +31,7 @@ const DefaultDrawerConfig = {
*/
drawerWidth: Dimensions.get('window').width - (Platform.OS === 'android' ? 56 : 64),
contentComponent: DrawerView.Items,
drawerPosition: 'left',
};
const DrawerNavigator = (
@@ -43,6 +44,7 @@ const DrawerNavigator = (
drawerWidth,
contentComponent,
contentOptions,
drawerPosition,
...tabsConfig
} = mergedConfig;
const contentRouter = TabRouter(routeConfigs, tabsConfig);
@@ -64,6 +66,7 @@ const DrawerNavigator = (
drawerWidth={drawerWidth}
contentComponent={contentComponent}
contentOptions={contentOptions}
drawerPosition={drawerPosition}
/>
), containerConfig);
};

View File

@@ -24,6 +24,7 @@ export type DrawerScene = {
export type DrawerViewConfig = {
drawerWidth: number,
drawerPosition: 'left' | 'right',
contentComponent: ReactClass<*>,
contentOptions?: {},
style?: any;
@@ -119,7 +120,10 @@ export default class DrawerView extends PureComponent<void, Props, void> {
onDrawerOpen={this._handleDrawerOpen}
onDrawerClose={this._handleDrawerClose}
renderNavigationView={this._renderNavigationView}
drawerPosition={DrawerLayout.positions.Left}
drawerPosition={
this.props.drawerPosition === 'right' ?
DrawerLayout.positions.Right : DrawerLayout.positions.Left
}
>
<DrawerScreen
screenProps={this.props.screenProps}