From c920b9cfceec243ceb6452ee41a37167eb08f7a8 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Fri, 28 Apr 2017 07:55:15 +0200 Subject: [PATCH] add headerBackTitleStyle screen option (#1083) * add headerBackTitleStyle screen option since the title is customizable, the back title should too. * add documentation for `headerBackTitleStyle` * make absence of headerBackTitle not affect return value * merge styles so current scene can override If there's no last scene, return the `headerBackTitleStyle` from the current scene. Otherwise return the `headerTitleStyle` from the last scene, and the `headerBackTitleStyle` from the current scene, with the latter having precedence. * take headerBackTitleStyle from current scene also the title style of the last scene is no longer taken into account --- .../react-navigation/docs/api/navigators/StackNavigator.md | 4 ++++ packages/react-navigation/src/TypeDefinition.js | 1 + packages/react-navigation/src/views/Header.js | 1 + packages/react-navigation/src/views/HeaderBackButton.js | 6 ++++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/react-navigation/docs/api/navigators/StackNavigator.md b/packages/react-navigation/docs/api/navigators/StackNavigator.md index e73dde31..8d8e7f76 100644 --- a/packages/react-navigation/docs/api/navigators/StackNavigator.md +++ b/packages/react-navigation/docs/api/navigators/StackNavigator.md @@ -128,6 +128,10 @@ Style object for the header Style object for the title component +#### `headerBackTitleStyle` + +Style object for the back title + #### `headerTintColor` Tint color for the header diff --git a/packages/react-navigation/src/TypeDefinition.js b/packages/react-navigation/src/TypeDefinition.js index 680e2b81..69084937 100644 --- a/packages/react-navigation/src/TypeDefinition.js +++ b/packages/react-navigation/src/TypeDefinition.js @@ -221,6 +221,7 @@ export type NavigationStackScreenOptions = NavigationScreenOptions & { headerLeft?: React.Element<*>, headerBackTitle?: string, headerTruncatedBackTitle?: string, + headerBackTitleStyle?: Style, headerPressColorAndroid?: string, headerRight?: React.Element<*>, headerStyle?: Style, diff --git a/packages/react-navigation/src/views/Header.js b/packages/react-navigation/src/views/Header.js index ecbfc975..22c15a37 100644 --- a/packages/react-navigation/src/views/Header.js +++ b/packages/react-navigation/src/views/Header.js @@ -136,6 +136,7 @@ class Header extends React.PureComponent { tintColor={options.headerTintColor} title={backButtonTitle} truncatedTitle={truncatedBackButtonTitle} + titleStyle={options.headerBackTitleStyle} width={width} /> ); diff --git a/packages/react-navigation/src/views/HeaderBackButton.js b/packages/react-navigation/src/views/HeaderBackButton.js index 23af608d..050d9eda 100644 --- a/packages/react-navigation/src/views/HeaderBackButton.js +++ b/packages/react-navigation/src/views/HeaderBackButton.js @@ -10,7 +10,7 @@ import { StyleSheet, } from 'react-native'; -import type { LayoutEvent } from '../TypeDefinition'; +import type { LayoutEvent, Style } from '../TypeDefinition'; import TouchableItem from './TouchableItem'; @@ -18,6 +18,7 @@ type Props = { onPress?: () => void, pressColorAndroid?: ?string, title?: ?string, + titleStyle?: ?Style, tintColor?: ?string, truncatedTitle?: ?string, width?: ?number, @@ -59,6 +60,7 @@ class HeaderBackButton extends React.PureComponent { pressColorAndroid, width, title, + titleStyle, tintColor, truncatedTitle, } = this.props; @@ -92,7 +94,7 @@ class HeaderBackButton extends React.PureComponent { title && {backButtonTitle}