Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: check if left button is truthy to add a left offset
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Aug 21, 2019
1 parent 9195861 commit 8645e36
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions packages/stack/src/views/Header/HeaderSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,24 @@ export default class HeaderSegment extends React.Component<Props, State> {
}
}

const leftButton = left
? left({
backImage,
pressColorAndroid,
allowFontScaling: backAllowFontScaling,
onPress: onGoBack,
labelVisible: headerBackTitleVisible,
label: leftLabel !== undefined ? leftLabel : previousTitle,
truncatedLabel,
labelStyle: [leftLabelStyle, customLeftLabelStyle],
onLabelLayout: this.handleLeftLabelLayout,
screenLayout: layout,
titleLayout,
tintColor: headerTintColor,
canGoBack: Boolean(onGoBack),
})
: null;

return (
<React.Fragment>
<Animated.View
Expand All @@ -295,34 +313,20 @@ export default class HeaderSegment extends React.Component<Props, State> {
style={{ height: headerStatusBarHeight }}
/>
<View pointerEvents="box-none" style={styles.content}>
{left ? (
{leftButton ? (
<Animated.View
pointerEvents="box-none"
style={[styles.left, leftButtonStyle, leftContainerStyle]}
>
{left({
backImage,
pressColorAndroid,
allowFontScaling: backAllowFontScaling,
onPress: onGoBack,
labelVisible: headerBackTitleVisible,
label: leftLabel !== undefined ? leftLabel : previousTitle,
truncatedLabel,
labelStyle: [leftLabelStyle, customLeftLabelStyle],
onLabelLayout: this.handleLeftLabelLayout,
screenLayout: layout,
titleLayout,
tintColor: headerTintColor,
canGoBack: Boolean(onGoBack),
})}
{leftButton}
</Animated.View>
) : null}
<Animated.View
pointerEvents="box-none"
style={[
Platform.select({
ios: null,
default: { left: left ? 72 : 16 },
default: { left: leftButton ? 72 : 16 },
}),
styles.title,
titleStyle,
Expand Down

0 comments on commit 8645e36

Please sign in to comment.