Created
October 10, 2015 16:12
-
-
Save TiagoGouvea/ba30975dd125d8a358ae to your computer and use it in GitHub Desktop.
Sample DrawerLayout opened by clicking in a TouchableHighlight component
This file contains hidden or 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); |
Sad we can't 👍 on gist! Thanks @lalkmim for your clean solution.
Thanks @lalkmim for the solution!
Thanks @Ialkmim -- but in order to make it work, I had to change this.drawer.openDrawer() to this._drawer.openDrawer()...
@ajeshekl Thanks. Worked for me. Is it due to change in ES standard ?
Thanks @yashvekaria for raising the issue and @lalkmim and @ajeshekl for the solution!
I got an issue, it shows only shadows when clicking the bottom
but shows navigation view when swiped from left
I got an issue, it shows only shadows when clicking the bottom
but shows navigation view when swiped from left
same issue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @lalkmim! It worked!