fix: properly handle header title

This commit is contained in:
satyajit.happy
2019-10-16 15:23:24 +02:00
parent b4b5f33757
commit 487d869891
2 changed files with 18 additions and 15 deletions

View File

@@ -1,8 +1,7 @@
import * as React from 'react';
import { StackActions } from 'react-navigation';
import HeaderSegment from './HeaderSegment';
import { HeaderProps, HeaderTitleProps } from '../../types';
import HeaderTitle from './HeaderTitle';
import { HeaderProps } from '../../types';
export default class Header extends React.PureComponent<HeaderProps> {
render() {
@@ -46,11 +45,6 @@ export default class Header extends React.PureComponent<HeaderProps> {
scene={scene}
title={title}
leftLabel={leftLabel}
headerTitle={
options.headerTitle === undefined
? (props: HeaderTitleProps) => <HeaderTitle {...props} />
: options.headerTitle
}
onGoBack={
previous
? () =>

View File

@@ -8,6 +8,7 @@ import {
} from 'react-native';
import Animated from 'react-native-reanimated';
import { SafeAreaContext, EdgeInsets } from 'react-native-safe-area-context';
import HeaderTitle from './HeaderTitle';
import HeaderBackButton from './HeaderBackButton';
import HeaderBackground from './HeaderBackground';
import memoize from '../../utils/memoize';
@@ -358,14 +359,22 @@ export default class HeaderSegment extends React.Component<Props, State> {
titleContainerStyle,
]}
>
{typeof headerTitle === 'function'
? headerTitle({
children: currentTitle,
onLayout: this.handleTitleLayout,
allowFontScaling: titleAllowFontScaling,
style: [{ color: headerTintColor }, customTitleStyle],
})
: headerTitle}
{typeof headerTitle === 'function' ? (
headerTitle({
children: currentTitle,
onLayout: this.handleTitleLayout,
allowFontScaling: titleAllowFontScaling,
style: [{ color: headerTintColor }, customTitleStyle],
})
) : (
<HeaderTitle
onLayout={this.handleTitleLayout}
allowFontScaling={titleAllowFontScaling}
style={[{ color: headerTintColor }, customTitleStyle]}
>
{currentTitle}
</HeaderTitle>
)}
</Animated.View>
{right !== undefined ? (
<Animated.View