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 header.left property #29

Merged
merged 8 commits into from
Jan 27, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/api/navigators/StackNavigator.md
Expand Up @@ -117,7 +117,8 @@ All `navigationOptions` for the `StackNavigator`:
- `header` - a config object for the header bar:
- `visible` - Boolean toggle of header visibility. Only works when `headerMode` is `screen`.
- `title` - Title string used by the navigation bar, or a custom React component
- `right` - Custom component displayed on the right side of the header
- `right` - Custom React Element to display on the right side of the header
- `left` - Custom React Element to display on the left side of the header
- `style` - Style object for the navigation bar

### Examples
Expand Down
5 changes: 5 additions & 0 deletions src/TypeDefinition.js
Expand Up @@ -113,6 +113,11 @@ export type HeaderConfig = {
*/
right?: React.Element<*>,

/**
* Renders a custom left component
*/
left?: React.Element<*>,

/**
* Style passed into navigation bar container
*/
Expand Down
20 changes: 17 additions & 3 deletions src/views/CardStack.js
Expand Up @@ -201,13 +201,27 @@ class CardStack extends React.Component<DefaultProps, Props, void> {
style={header.style}
mode={headerMode}
onNavigateBack={() => this.props.navigation.goBack(null)}
renderLeftComponent={(props) => {
const navigation = this._getChildNavigation(props.scene);
const header = this.props.router.getScreenConfig(navigation, 'header');
if (header && header.left) {
return header.left;
}
const { renderLeftComponent } = this.props.headerComponent.defaultProps;
if (typeof renderLeftComponent === 'function') {
return renderLeftComponent(props);
}
return null;
}}
renderRightComponent={({ scene }) => {
const navigation = this._getChildNavigation(scene);
const header = this.props.router.getScreenConfig(navigation, 'header');
const right = header && header.right;
return right;
if (header && header.right) {
return header.right;
}
return null;
}}
renderTitleComponent={({ scene, navigationState }) => {
renderTitleComponent={({ scene }) => {
const navigation = this._getChildNavigation(scene);
const header = this.props.router.getScreenConfig(navigation, 'header');
let title = null;
Expand Down