expo / ex-navigation

Route-centric navigation for React Native
997 stars 201 forks source link

Add `before` and `after` props `NavigationBar.Title`. #419

Closed dantman closed 7 years ago

dantman commented 7 years ago

This helps insert non-text components before and after title text in the title area.

Adding things like icons to the title is impossible when all of NavigationBar.Title’s children are text.

chirag04 commented 7 years ago

Does renderTitle not work for you?

dantman commented 7 years ago

@chirag04 Then you have to manually reimplement all the text styles from scratch to get them back, just so you can stick an icon on the end.

chirag04 commented 7 years ago

The default implementation of header text doesn't do much. it's not a bad idea of override it especially when you have custom need for icons etc. before and after seems very to fix your very specific case and will only increase the api surface area and maintenance.

dantman commented 7 years ago

@chirag04 titleStyles.title(Text) contains a bunch of platform specific styles and are based on platform recommendations instead of app styling. Recreating that in app styles just to add something like an app menu or add a title icon is a bad idea.

How do you feel about decoupling the text portion as a separate component from the title container it is in so the app can override / extend them individually?

satya164 commented 7 years ago

@dantman pretty sure the styles are pretty simple. anyways, you can just import the component and reuse, why add more props?

dantman commented 7 years ago

Superseded by #421.

Ok @chirag04, instead of adding some single-purpose properties to the title bar component I just split the container and text portions of the title bar up. This will work with absolutely any customizations one might want to do to the title bar.