mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-23 20:10:49 +08:00
fix: properly handle header title
This commit is contained in:
@@ -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
|
||||
? () =>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user