Skip to content

Instantly share code, notes, and snippets.

@TiagoGouvea
Created October 10, 2015 16:12
Show Gist options
  • Save TiagoGouvea/ba30975dd125d8a358ae to your computer and use it in GitHub Desktop.
Save TiagoGouvea/ba30975dd125d8a358ae to your computer and use it in GitHub Desktop.
Sample DrawerLayout opened by clicking in a TouchableHighlight component
/**
* 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);
@shiundu
Copy link

shiundu commented Jan 10, 2018

Thanks @yashvekaria for raising the issue and @lalkmim and @ajeshekl for the solution!

@shures
Copy link

shures commented Mar 25, 2019

I got an issue, it shows only shadows when clicking the bottom
but shows navigation view when swiped from left

@JexelJimenez
Copy link

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