Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add headerBackTitleStyle screen option #1083

Merged
merged 5 commits into from
Apr 28, 2017
Merged

add headerBackTitleStyle screen option #1083

merged 5 commits into from
Apr 28, 2017

Conversation

koenpunt
Copy link

@koenpunt koenpunt commented Apr 17, 2017

I'm currently migrating an existing iOS app to React Native, where I use customized titles and back buttons.

The titles currently can be styled using headerTitleStyle, but for the back button there was no such option.

So this change adds a headerBackTitleStyle screen option, which makes it possible to set the style for the back button title , and when not set it inherits the headerTitleStyle.

TODO

  • Add documentation

Copy link

@grabbou grabbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good. I am not in favour of allowing custom headerBackTitleStyle as the default implementation is specifically made for iOS and optimised to look native. Inheriting things like fontFamily from headerTitleStyle makes sense.

headerTitleStyle,
} = this.props.getScreenDetails(lastScene).options;

if (headerBackTitle === null) {

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

return null;
}
const {
headerBackTitleStyle,

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

}
const { headerTitleStyle } = this.props.getScreenDetails(lastScene).options;

return [headerTitleStyle, headerBackTitleStyle];

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

since the title is customizable, the back title should too.
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.
also the title style of the last scene is no longer taken into account
@koenpunt
Copy link
Author

koenpunt commented Apr 27, 2017

@grabbou @satya164 I came to the conclusion that inheriting or merging the styles isn't that logical, since the title and the backbutton already have different styles by default. I overlooked that fact because in the application I'm working on I have the title and the button title styled the same.

That being said, I've reverted it to taking headerBackTitleStyle from the current scene, and accept that I have to explicitly set those styles on the backbutton when necessary.

@grabbou grabbou merged commit c04ea5b into react-navigation:master Apr 28, 2017
@koenpunt koenpunt deleted the back-title-style branch August 29, 2017 15:11
sourcecode911 pushed a commit to sourcecode911/react-navigation that referenced this pull request Mar 9, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants