Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a more custom drawer menu icon to open side navigation #802

Merged
merged 2 commits into from
Jun 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class NavBar extends React.Component {
function tryRender(state, wrapBy) {
let onPress = state.onLeft;
let buttonImage = state.leftButtonImage;
let menuIcon = state.drawerIcon;
const style = [styles.leftButton, self.props.leftButtonStyle, state.leftButtonStyle];
const textStyle = [styles.barLeftButtonText, self.props.leftButtonTextStyle,
state.leftButtonTextStyle];
Expand All @@ -304,9 +305,17 @@ class NavBar extends React.Component {

if (!onPress && !!drawer && typeof drawer.toggle === 'function') {
buttonImage = state.drawerImage;
if (buttonImage) {
if (buttonImage || menuIcon) {
onPress = drawer.toggle;
}
if (!menuIcon) {
menuIcon = (
<Image
source={buttonImage}
style={state.leftButtonIconStyle || styles.defaultImageStyle}
/>
);
}
}

if (onPress && (state.leftTitle || buttonImage)) {
Expand All @@ -325,10 +334,7 @@ class NavBar extends React.Component {
}
{buttonImage &&
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'flex-start' }}>
<Image
source={buttonImage}
style={state.leftButtonIconStyle || styles.defaultImageStyle}
/>
{menuIcon}
</View>
}
</TouchableOpacity>
Expand Down