Skip to content

Commit

Permalink
Support ReactNavigation's drawerWidth property (#2515)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitecl authored and aksonov committed Oct 17, 2017
1 parent bc8fcc3 commit 9d52768
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions Example/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const Example = () => (
key="drawer"
contentComponent={DrawerContent}
drawerImage={MenuIcon}
drawerWidth={300}
>
{/*
Wrapper Scene needed to fix a bug where the tabs would
Expand Down
4 changes: 2 additions & 2 deletions dist/navigationStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ return null;
}
var res={};
var order=[];var _scene$props=
scene.props,navigator=_scene$props.navigator,contentComponent=_scene$props.contentComponent,lazy=_scene$props.lazy,duration=_scene$props.duration,parentProps=_objectWithoutProperties(_scene$props,['navigator','contentComponent','lazy','duration']);var
scene.props,navigator=_scene$props.navigator,contentComponent=_scene$props.contentComponent,drawerWidth=_scene$props.drawerWidth,lazy=_scene$props.lazy,duration=_scene$props.duration,parentProps=_objectWithoutProperties(_scene$props,['navigator','contentComponent','drawerWidth','lazy','duration']);var
tabs=parentProps.tabs,modal=parentProps.modal,lightbox=parentProps.lightbox,overlay=parentProps.overlay,tabBarPosition=parentProps.tabBarPosition,drawer=parentProps.drawer,tabBarComponent=parentProps.tabBarComponent,transitionConfig=parentProps.transitionConfig;
if(scene.type===_Modal2.default){
modal=true;
Expand Down Expand Up @@ -506,7 +506,7 @@ tabBarPosition=_reactNative.Platform.OS==='android'?'top':'bottom';
return(0,_reactNavigation.TabNavigator)(res,_extends({lazy:lazy,tabBarComponent:tabBarComponent,tabBarPosition:tabBarPosition,initialRouteName:initialRouteName,initialRouteParams:initialRouteParams,order:order},commonProps,{
tabBarOptions:createTabBarOptions(commonProps),navigationOptions:createNavigationOptions(commonProps)}));
}else if(drawer){
return(0,_reactNavigation.DrawerNavigator)(res,_extends({initialRouteName:initialRouteName,contentComponent:contentComponent,order:order},commonProps));
return(0,_reactNavigation.DrawerNavigator)(res,_extends({initialRouteName:initialRouteName,contentComponent:contentComponent,drawerWidth:drawerWidth,order:order},commonProps));
}else if(overlay){
return(0,_OverlayNavigator2.default)(res,_extends({lazy:lazy,initialRouteName:initialRouteName,initialRouteParams:initialRouteParams,order:order},commonProps,{
tabBarOptions:createTabBarOptions(commonProps),navigationOptions:createNavigationOptions(commonProps)}));
Expand Down
1 change: 1 addition & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Can use all `prop` as listed in `Scene` as `<Drawer>`, syntatic sugar for `<Scen
| `drawerIcon` | `React.Component` | | Arbitrary component to be used for drawer 'hamburger' icon, you have to set it together with `drawer` prop |
| `hideDrawerButton` | `boolean` | `false` | Boolean to show or not the drawerImage or drawerIcon |
| `drawerPosition` | `string` | Determines whether the drawer is on the right or the left. Keywords accepted are `right` and `left` |
| `drawerWidth` | `number` | | The width, in pixels, of the drawer (optional)


## Modals (`<Modal>` or `<Scene modal>`)
Expand Down
4 changes: 2 additions & 2 deletions src/navigationStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class NavigationStore {
}
const res = {};
const order = [];
const { navigator, contentComponent, lazy, duration, ...parentProps } = scene.props;
const { navigator, contentComponent, drawerWidth, lazy, duration, ...parentProps } = scene.props;
let { tabs, modal, lightbox, overlay, tabBarPosition, drawer, tabBarComponent, transitionConfig } = parentProps;
if (scene.type === Modal) {
modal = true;
Expand Down Expand Up @@ -506,7 +506,7 @@ class NavigationStore {
return TabNavigator(res, { lazy, tabBarComponent, tabBarPosition, initialRouteName, initialRouteParams, order, ...commonProps,
tabBarOptions: createTabBarOptions(commonProps), navigationOptions: createNavigationOptions(commonProps) });
} else if (drawer) {
return DrawerNavigator(res, { initialRouteName, contentComponent, order, ...commonProps });
return DrawerNavigator(res, { initialRouteName, contentComponent, drawerWidth, order, ...commonProps });
} else if (overlay) {
return OverlayNavigator(res, { lazy, initialRouteName, initialRouteParams, order, ...commonProps,
tabBarOptions: createTabBarOptions(commonProps), navigationOptions: createNavigationOptions(commonProps) });
Expand Down

0 comments on commit 9d52768

Please sign in to comment.