-
-
Save qawemlilo/de53d29543be0b1311173b41bb140c8e to your computer and use it in GitHub Desktop.
Sample DrawerLayout opened by clicking in a TouchableHighlight component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
*/ | |
'use strict'; | |
var React = require('react-native'); | |
var { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
DrawerLayoutAndroid, | |
TouchableHighlight, | |
} = React; | |
var DrawerTest = React.createClass({ | |
openDrawer:function() { | |
this.refs['DRAWER'].openDrawer() | |
}, | |
render: function() { | |
var navigationView = ( | |
<View style={{flex: 1, backgroundColor: '#fff'}}> | |
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>I'm in the Drawer!</Text> | |
</View> | |
); | |
return ( | |
<DrawerLayoutAndroid | |
drawerWidth={300} | |
ref={'DRAWER'} | |
drawerPosition={DrawerLayoutAndroid.positions.Left} | |
renderNavigationView={() => navigationView}> | |
<View style={{flex: 1, alignItems: 'center'}}> | |
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text> | |
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text> | |
<TouchableHighlight onPress={this.openDrawer}> | |
<Text>{'Open Drawer'}</Text> | |
</TouchableHighlight> | |
</View> | |
</DrawerLayoutAndroid> | |
); | |
} | |
}); | |
AppRegistry.registerComponent('DrawerTest', () => DrawerTest); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment