mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-24 00:58:20 +00:00
drawerLockMode (#1377)
* added drawerLockMode with cabilities to update it on the fly * fixed incorrect name on markdown for usage * added handling if screenProps is not being used * Fix linting error * Use drawerLockMode instead of lockMode * Correct docs * Fix flow issues * Make drawerLockMode optional
This commit is contained in:
parent
2b40182cd7
commit
17c910fb5d
@ -87,7 +87,6 @@ The route configs object is a mapping from route name to a route config, which t
|
|||||||
|
|
||||||
|
|
||||||
### DrawerNavigatorConfig
|
### DrawerNavigatorConfig
|
||||||
|
|
||||||
- `drawerWidth` - Width of the drawer
|
- `drawerWidth` - Width of the drawer
|
||||||
- `drawerPosition` - Options are `left` or `right`. Default is `left` position.
|
- `drawerPosition` - Options are `left` or `right`. Default is `left` position.
|
||||||
- `contentComponent` - Component used to render the content of the drawer, for example, navigation items. Receives the `navigation` prop for the drawer. Defaults to `DrawerItems`. For more information, see below.
|
- `contentComponent` - Component used to render the content of the drawer, for example, navigation items. Receives the `navigation` prop for the drawer. Defaults to `DrawerItems`. For more information, see below.
|
||||||
@ -172,6 +171,10 @@ String, React Element or a function that given `{ focused: boolean, tintColor: s
|
|||||||
|
|
||||||
React Element or a function, that given `{ focused: boolean, tintColor: string }` returns a React.Element, to display in drawer sidebar
|
React Element or a function, that given `{ focused: boolean, tintColor: string }` returns a React.Element, to display in drawer sidebar
|
||||||
|
|
||||||
|
#### `drawerLockMode`
|
||||||
|
|
||||||
|
Specifies the [lock mode](https://facebook.github.io/react-native/docs/drawerlayoutandroid.html#drawerlockmode) of the drawer. This can also update dynamically by using screenProps.lockMode on your top level router.
|
||||||
|
|
||||||
### Navigator Props
|
### Navigator Props
|
||||||
|
|
||||||
The navigator component created by `DrawerNavigator(...)` takes the following props:
|
The navigator component created by `DrawerNavigator(...)` takes the following props:
|
||||||
|
@ -359,6 +359,7 @@ export type NavigationDrawerScreenOptions = {
|
|||||||
| ((options: { tintColor: ?string, focused: boolean }) => ?React.Element<
|
| ((options: { tintColor: ?string, focused: boolean }) => ?React.Element<
|
||||||
*
|
*
|
||||||
>),
|
>),
|
||||||
|
drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +43,7 @@ const DrawerNavigator = (
|
|||||||
const {
|
const {
|
||||||
containerConfig,
|
containerConfig,
|
||||||
drawerWidth,
|
drawerWidth,
|
||||||
|
drawerLockMode,
|
||||||
contentComponent,
|
contentComponent,
|
||||||
contentOptions,
|
contentOptions,
|
||||||
drawerPosition,
|
drawerPosition,
|
||||||
@ -82,6 +83,7 @@ const DrawerNavigator = (
|
|||||||
)((props: *) =>
|
)((props: *) =>
|
||||||
<DrawerView
|
<DrawerView
|
||||||
{...props}
|
{...props}
|
||||||
|
drawerLockMode={drawerLockMode}
|
||||||
useNativeAnimations={useNativeAnimations}
|
useNativeAnimations={useNativeAnimations}
|
||||||
drawerWidth={drawerWidth}
|
drawerWidth={drawerWidth}
|
||||||
contentComponent={contentComponent}
|
contentComponent={contentComponent}
|
||||||
|
@ -29,6 +29,7 @@ export type DrawerItem = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type DrawerViewConfig = {
|
export type DrawerViewConfig = {
|
||||||
|
drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open',
|
||||||
drawerWidth: number,
|
drawerWidth: number,
|
||||||
drawerPosition: 'left' | 'right',
|
drawerPosition: 'left' | 'right',
|
||||||
contentComponent: ReactClass<*>,
|
contentComponent: ReactClass<*>,
|
||||||
@ -138,11 +139,26 @@ export default class DrawerView<T: *> extends PureComponent<void, Props, void> {
|
|||||||
const DrawerScreen = this.props.router.getComponentForRouteName(
|
const DrawerScreen = this.props.router.getComponentForRouteName(
|
||||||
'DrawerClose'
|
'DrawerClose'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const screenNavigation = addNavigationHelpers({
|
||||||
|
state: this._screenNavigationProp.state,
|
||||||
|
dispatch: this._screenNavigationProp.dispatch,
|
||||||
|
});
|
||||||
|
|
||||||
|
const config = this.props.router.getScreenOptions(
|
||||||
|
screenNavigation,
|
||||||
|
this.props.screenProps
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DrawerLayout
|
<DrawerLayout
|
||||||
ref={(c: *) => {
|
ref={(c: *) => {
|
||||||
this._drawer = c;
|
this._drawer = c;
|
||||||
}}
|
}}
|
||||||
|
drawerLockMode={
|
||||||
|
(this.props.screenProps && this.props.screenProps.drawerLockMode) ||
|
||||||
|
(config && config.drawerLockMode)
|
||||||
|
}
|
||||||
drawerWidth={this.props.drawerWidth}
|
drawerWidth={this.props.drawerWidth}
|
||||||
onDrawerOpen={this._handleDrawerOpen}
|
onDrawerOpen={this._handleDrawerOpen}
|
||||||
onDrawerClose={this._handleDrawerClose}
|
onDrawerClose={this._handleDrawerClose}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user