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

Commit e481a33

Browse files
satya164osdnk
authored andcommitted
fix: add left offset in header only if a left button is rendered
(cherry picked from commit db63211)
1 parent 3558aa7 commit e481a33

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

src/views/Header/HeaderSegment.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,24 @@ export default class HeaderSegment extends React.Component<Props, State> {
274274
}
275275
}
276276

277+
const leftButton = left
278+
? left({
279+
backImage,
280+
pressColorAndroid,
281+
allowFontScaling: backAllowFontScaling,
282+
onPress: onGoBack,
283+
labelVisible: headerBackTitleVisible,
284+
label: leftLabel !== undefined ? leftLabel : previousTitle,
285+
truncatedLabel,
286+
labelStyle: [leftLabelStyle, customLeftLabelStyle],
287+
onLabelLayout: this.handleLeftLabelLayout,
288+
screenLayout: layout,
289+
titleLayout,
290+
tintColor: headerTintColor,
291+
canGoBack: Boolean(onGoBack),
292+
})
293+
: null;
294+
277295
return (
278296
<React.Fragment>
279297
<Animated.View
@@ -295,34 +313,20 @@ export default class HeaderSegment extends React.Component<Props, State> {
295313
style={{ height: headerStatusBarHeight }}
296314
/>
297315
<View pointerEvents="box-none" style={styles.content}>
298-
{left ? (
316+
{leftButton ? (
299317
<Animated.View
300318
pointerEvents="box-none"
301319
style={[styles.left, leftButtonStyle, leftContainerStyle]}
302320
>
303-
{left({
304-
backImage,
305-
pressColorAndroid,
306-
allowFontScaling: backAllowFontScaling,
307-
onPress: onGoBack,
308-
labelVisible: headerBackTitleVisible,
309-
label: leftLabel !== undefined ? leftLabel : previousTitle,
310-
truncatedLabel,
311-
labelStyle: [leftLabelStyle, customLeftLabelStyle],
312-
onLabelLayout: this.handleLeftLabelLayout,
313-
screenLayout: layout,
314-
titleLayout,
315-
tintColor: headerTintColor,
316-
canGoBack: Boolean(onGoBack),
317-
})}
321+
{leftButton}
318322
</Animated.View>
319323
) : null}
320324
<Animated.View
321325
pointerEvents="box-none"
322326
style={[
323327
Platform.select({
324328
ios: null,
325-
default: { left: onGoBack ? 72 : 16 },
329+
default: { left: leftButton ? 72 : 16 },
326330
}),
327331
styles.title,
328332
titleStyle,

0 commit comments

Comments
 (0)