Skip to content

Commit

Permalink
Merge pull request #508 from lelandrichardson/lmr--add-getscenestyle-api
Browse files Browse the repository at this point in the history
Add getSceneStyle api to Scene and Router
  • Loading branch information
aksonov committed Apr 12, 2016
2 parents c551685 + 719b929 commit 32c48df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class App extends React.Component {
| other props | | | all properties that will be passed to all your scenes |
| children | | required (if no scenes property passed)| Scene root element |
| scenes | object | optional | scenes for Router created with Actions.create. This will allow to create all actions BEFORE React processing. If you don't need it you may pass Scene root element as children |
| getSceneStyle | function | optional | Optionally override the styles for NavigationCard's Animated.View rendering the scene. |
##### Scene:

| Property | Type | Default | Description |
Expand Down Expand Up @@ -130,6 +131,7 @@ class App extends React.Component {
| tabBarStyle | View style | | optional style override for the Tabs component |
| sceneStyle | View style | { flex: 1 } | optional style override for the Scene's component |
| other props | | | all properties that will be passed to your component instance |
| getSceneStyle | function | optional | Optionally override the styles for NavigationCard's Animated.View rendering the scene. |

## Example
![launch](https://cloud.githubusercontent.com/assets/1321329/11692367/7337cfe2-9e9f-11e5-8515-e8b7a9f230ec.gif)
Expand Down
10 changes: 6 additions & 4 deletions src/DefaultRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ export default class DefaultRenderer extends Component {
}

_renderCard(/*NavigationSceneRendererProps*/ props) {
const { key, direction, panHandlers, getSceneStyle } = props.scene.navigationState;
const style = getSceneStyle ? getSceneStyle(props) : null;
return (
<NavigationCard
{...props}
style={props.scene.navigationState.style}
key={"card_" + props.scene.navigationState.key}
direction={props.scene.navigationState.direction || "horizontal"}
panHandlers={props.scene.navigationState.panHandlers }
key={'card_' + key}
direction={direction || 'horizontal'}
panHandlers={panHandlers}
renderScene={this._renderScene}
style={style}
/>
);
}
Expand Down

0 comments on commit 32c48df

Please sign in to comment.