Skip to content

Commit 253dc8e

Browse files
committed
Rendering menu button when drawer is present
1 parent 80567cb commit 253dc8e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/NavBar.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const {
3232
Header: NavigationHeader,
3333
} = NavigationExperimental;
3434

35-
export default class extends React.Component {
35+
export default class NavBar extends React.Component {
3636
componentWillMount(){
3737
const state = this.props.navigationState;
3838
this._renderRightButton = this._renderRightButton.bind(this);
@@ -78,7 +78,18 @@ export default class extends React.Component {
7878

7979
_renderBackButton() {
8080
if (this.props.navigationState.index === 0) {
81+
if(!!this.context.drawer && typeof this.context.drawer.toggle === 'function'){
82+
return (
83+
<TouchableOpacity style={[styles.backButton, this.props.navigationState.leftButtonStyle]} onPress={() => {
84+
var drawer = this.context.drawer;
85+
drawer.toggle();
86+
}}>
87+
<Image source={require('./menu_burger.png')} style={[styles.backButtonImage, this.props.navigationState.barButtonIconStyle]}/>
88+
</TouchableOpacity>
89+
);
90+
}else{
8191
return null;
92+
}
8293
}
8394
return (
8495
<TouchableOpacity style={[styles.backButton, this.props.navigationState.leftButtonStyle]} onPress={Actions.pop}>
@@ -153,6 +164,11 @@ export default class extends React.Component {
153164

154165
}
155166

167+
168+
NavBar.contextTypes = {
169+
drawer: React.PropTypes.object
170+
}
171+
156172
const styles = StyleSheet.create({
157173
title: {
158174
textAlign: 'center',

src/menu_burger.png

706 Bytes
Loading

0 commit comments

Comments
 (0)