Skip to content
Permalink
Browse files

DrawerLayoutAndroid drawerPosition now expects a string, number is de…

…precated

Summary: The native change to support strings was made in D15912607 on June 21st. Migrating the JS callsites now to start passing strings instead of the constants.

Reviewed By: zackargyle, mdvacca

Differential Revision: D16703569

fbshipit-source-id: cb1d8698df55d2961cde1e2b1fbfcba086a03bb2
  • Loading branch information...
TheSavior authored and facebook-github-bot committed Aug 8, 2019
1 parent 0dcd57c commit 305b0a28142414d559d2d08795a5963716dc4b0f
@@ -60,7 +60,7 @@ type NativeProps = $ReadOnly<{|
/**
* Specifies the side of the screen from which the drawer will slide in.
*/
drawerPosition: ?Int32,
drawerPosition?: WithDefault<'left' | 'right', 'left'>,

/**
* Specifies the width of the drawer, more precisely the width of the view that be pulled in
@@ -12,15 +12,11 @@

const Platform = require('../../Utilities/Platform');
const React = require('react');
const ReactNative = require('../../Renderer/shims/ReactNative');
const StatusBar = require('../StatusBar/StatusBar');
const StyleSheet = require('../../StyleSheet/StyleSheet');
const UIManager = require('../../ReactNative/UIManager');
const View = require('../View/View');
const nullthrows = require('nullthrows');

const DrawerConsts = UIManager.getViewManagerConfig('AndroidDrawerLayout')
.Constants;
const dismissKeyboard = require('../../Utilities/dismissKeyboard');
import AndroidDrawerLayoutNativeComponent, {
Commands,
@@ -67,7 +63,7 @@ type Props = $ReadOnly<{|
/**
* Specifies the side of the screen from which the drawer will slide in.
*/
drawerPosition: ?number,
drawerPosition: ?('left' | 'right'),

/**
* Specifies the width of the drawer, more precisely the width of the view that be pulled in
@@ -148,7 +144,7 @@ type State = {|
* return (
* <DrawerLayoutAndroid
* drawerWidth={300}
* drawerPosition={DrawerLayoutAndroid.positions.Left}
* drawerPosition="left"
* renderNavigationView={() => navigationView}>
* <View style={{flex: 1, alignItems: 'center'}}>
* <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text>
@@ -160,7 +156,13 @@ type State = {|
* ```
*/
class DrawerLayoutAndroid extends React.Component<Props, State> {
static positions = DrawerConsts.DrawerPosition;
static get positions(): mixed {
console.warn(
'Setting DrawerLayoutAndroid drawerPosition using `DrawerLayoutAndroid.positions` is deprecated. Instead pass the string value "left" or "right"',
);

return {Left: 'left', Right: 'right'};
}
static defaultProps = {
drawerBackgroundColor: 'white',
};
@@ -25,7 +25,7 @@ describe('<DrawerLayoutAndroid />', () => {
const instance = render.create(
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
drawerPosition="left"
renderNavigationView={() => <View />}
/>,
);
@@ -36,7 +36,7 @@ describe('<DrawerLayoutAndroid />', () => {
const output = render.shallow(
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
drawerPosition="left"
renderNavigationView={() => <View />}
/>,
);
@@ -49,7 +49,7 @@ describe('<DrawerLayoutAndroid />', () => {
const output = render.shallow(
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
drawerPosition="left"
renderNavigationView={() => <View />}
/>,
);
@@ -62,7 +62,7 @@ describe('<DrawerLayoutAndroid />', () => {
const instance = render.create(
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
drawerPosition="left"
renderNavigationView={() => <View />}
/>,
);
@@ -3,7 +3,7 @@
exports[`<DrawerLayoutAndroid /> should render as <DrawerLayoutAndroid> when mocked 1`] = `
<AndroidDrawerLayout
drawerBackgroundColor="white"
drawerPosition={10}
drawerPosition="left"
drawerWidth={300}
onDrawerClose={[Function]}
onDrawerOpen={[Function]}
@@ -55,7 +55,7 @@ exports[`<DrawerLayoutAndroid /> should render as <DrawerLayoutAndroid> when moc
exports[`<DrawerLayoutAndroid /> should render as <DrawerLayoutAndroid> when not mocked 1`] = `
<AndroidDrawerLayout
drawerBackgroundColor="white"
drawerPosition={10}
drawerPosition="left"
drawerWidth={300}
onDrawerClose={[Function]}
onDrawerOpen={[Function]}
@@ -107,7 +107,7 @@ exports[`<DrawerLayoutAndroid /> should render as <DrawerLayoutAndroid> when not
exports[`<DrawerLayoutAndroid /> should shallow render as <DrawerLayoutAndroid> when mocked 1`] = `
<DrawerLayoutAndroid
drawerBackgroundColor="white"
drawerPosition={10}
drawerPosition="left"
drawerWidth={300}
renderNavigationView={[Function]}
/>
@@ -116,7 +116,7 @@ exports[`<DrawerLayoutAndroid /> should shallow render as <DrawerLayoutAndroid>
exports[`<DrawerLayoutAndroid /> should shallow render as <DrawerLayoutAndroid> when not mocked 1`] = `
<DrawerLayoutAndroid
drawerBackgroundColor="white"
drawerPosition={10}
drawerPosition="left"
drawerWidth={300}
renderNavigationView={[Function]}
/>
@@ -105,7 +105,7 @@ class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {
}
return (
<DrawerLayoutAndroid
drawerPosition={DrawerLayoutAndroid.positions.Left}
drawerPosition="left"
drawerWidth={Dimensions.get('window').width - DRAWER_WIDTH_LEFT}
keyboardDismissMode="on-drag"
onDrawerOpen={() => {

0 comments on commit 305b0a2

Please sign in to comment.
You can’t perform that action at this time.