mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Prettier React Native Libraries
Reviewed By: sahrens Differential Revision: D7961488 fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
This commit is contained in:
committed by
Facebook Github Bot
parent
1e2de71290
commit
d01ab66b47
@@ -4,7 +4,9 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const ColorPropType = require('ColorPropType');
|
||||
@@ -28,11 +30,7 @@ const requireNativeComponent = require('requireNativeComponent');
|
||||
const RK_DRAWER_REF = 'drawerlayout';
|
||||
const INNERVIEW_REF = 'innerView';
|
||||
|
||||
const DRAWER_STATES = [
|
||||
'Idle',
|
||||
'Dragging',
|
||||
'Settling',
|
||||
];
|
||||
const DRAWER_STATES = ['Idle', 'Dragging', 'Settling'];
|
||||
|
||||
/**
|
||||
* React component that wraps the platform `DrawerLayout` (Android only). The
|
||||
@@ -99,7 +97,7 @@ const DrawerLayoutAndroid = createReactClass({
|
||||
*/
|
||||
drawerPosition: PropTypes.oneOf([
|
||||
DrawerConsts.DrawerPosition.Left,
|
||||
DrawerConsts.DrawerPosition.Right
|
||||
DrawerConsts.DrawerPosition.Right,
|
||||
]),
|
||||
/**
|
||||
* Specifies the width of the drawer, more precisely the width of the view that be pulled in
|
||||
@@ -116,7 +114,7 @@ const DrawerLayoutAndroid = createReactClass({
|
||||
drawerLockMode: PropTypes.oneOf([
|
||||
'unlocked',
|
||||
'locked-closed',
|
||||
'locked-open'
|
||||
'locked-open',
|
||||
]),
|
||||
/**
|
||||
* Function called whenever there is an interaction with the navigation view.
|
||||
@@ -168,31 +166,41 @@ const DrawerLayoutAndroid = createReactClass({
|
||||
},
|
||||
|
||||
render: function() {
|
||||
const drawStatusBar = Platform.Version >= 21 && this.props.statusBarBackgroundColor;
|
||||
const drawerViewWrapper =
|
||||
const drawStatusBar =
|
||||
Platform.Version >= 21 && this.props.statusBarBackgroundColor;
|
||||
const drawerViewWrapper = (
|
||||
<View
|
||||
style={[
|
||||
styles.drawerSubview,
|
||||
{width: this.props.drawerWidth, backgroundColor: this.props.drawerBackgroundColor}
|
||||
{
|
||||
width: this.props.drawerWidth,
|
||||
backgroundColor: this.props.drawerBackgroundColor,
|
||||
},
|
||||
]}
|
||||
collapsable={false}>
|
||||
{this.props.renderNavigationView()}
|
||||
{drawStatusBar && <View style={styles.drawerStatusBar} />}
|
||||
</View>;
|
||||
const childrenWrapper =
|
||||
</View>
|
||||
);
|
||||
const childrenWrapper = (
|
||||
<View ref={INNERVIEW_REF} style={styles.mainSubview} collapsable={false}>
|
||||
{drawStatusBar &&
|
||||
<StatusBar
|
||||
translucent
|
||||
backgroundColor={this.props.statusBarBackgroundColor}
|
||||
/>}
|
||||
{drawStatusBar &&
|
||||
<View style={[
|
||||
styles.statusBar,
|
||||
{backgroundColor: this.props.statusBarBackgroundColor}
|
||||
]} />}
|
||||
{drawStatusBar && (
|
||||
<StatusBar
|
||||
translucent
|
||||
backgroundColor={this.props.statusBarBackgroundColor}
|
||||
/>
|
||||
)}
|
||||
{drawStatusBar && (
|
||||
<View
|
||||
style={[
|
||||
styles.statusBar,
|
||||
{backgroundColor: this.props.statusBarBackgroundColor},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
{this.props.children}
|
||||
</View>;
|
||||
</View>
|
||||
);
|
||||
return (
|
||||
<AndroidDrawerLayout
|
||||
{...this.props}
|
||||
@@ -234,7 +242,9 @@ const DrawerLayoutAndroid = createReactClass({
|
||||
|
||||
_onDrawerStateChanged: function(event) {
|
||||
if (this.props.onDrawerStateChanged) {
|
||||
this.props.onDrawerStateChanged(DRAWER_STATES[event.nativeEvent.drawerState]);
|
||||
this.props.onDrawerStateChanged(
|
||||
DRAWER_STATES[event.nativeEvent.drawerState],
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -245,7 +255,7 @@ const DrawerLayoutAndroid = createReactClass({
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
this._getDrawerLayoutHandle(),
|
||||
UIManager.AndroidDrawerLayout.Commands.openDrawer,
|
||||
null
|
||||
null,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -256,29 +266,28 @@ const DrawerLayoutAndroid = createReactClass({
|
||||
UIManager.dispatchViewManagerCommand(
|
||||
this._getDrawerLayoutHandle(),
|
||||
UIManager.AndroidDrawerLayout.Commands.closeDrawer,
|
||||
null
|
||||
null,
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Closing and opening example
|
||||
* Note: To access the drawer you have to give it a ref. Refs do not work on stateless components
|
||||
* render () {
|
||||
* this.openDrawer = () => {
|
||||
* this.refs.DRAWER.openDrawer()
|
||||
* }
|
||||
* this.closeDrawer = () => {
|
||||
* this.refs.DRAWER.closeDrawer()
|
||||
* }
|
||||
* return (
|
||||
* <DrawerLayoutAndroid ref={'DRAWER'}>
|
||||
* </DrawerLayoutAndroid>
|
||||
* )
|
||||
* }
|
||||
*/
|
||||
* Closing and opening example
|
||||
* Note: To access the drawer you have to give it a ref. Refs do not work on stateless components
|
||||
* render () {
|
||||
* this.openDrawer = () => {
|
||||
* this.refs.DRAWER.openDrawer()
|
||||
* }
|
||||
* this.closeDrawer = () => {
|
||||
* this.refs.DRAWER.closeDrawer()
|
||||
* }
|
||||
* return (
|
||||
* <DrawerLayoutAndroid ref={'DRAWER'}>
|
||||
* </DrawerLayoutAndroid>
|
||||
* )
|
||||
* }
|
||||
*/
|
||||
_getDrawerLayoutHandle: function() {
|
||||
return ReactNative.findNodeHandle(this.refs[RK_DRAWER_REF]);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
@@ -312,6 +321,9 @@ const styles = StyleSheet.create({
|
||||
});
|
||||
|
||||
// The View that contains both the actual drawer and the main view
|
||||
const AndroidDrawerLayout = requireNativeComponent('AndroidDrawerLayout', DrawerLayoutAndroid);
|
||||
const AndroidDrawerLayout = requireNativeComponent(
|
||||
'AndroidDrawerLayout',
|
||||
DrawerLayoutAndroid,
|
||||
);
|
||||
|
||||
module.exports = DrawerLayoutAndroid;
|
||||
|
||||
Reference in New Issue
Block a user