Skip to content

Commit

Permalink
support onRight/rightTitle/rightButtonImage for Actions.refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
aksonov committed Jul 12, 2017
1 parent 904c8db commit a5666a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Example/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Example extends Component {
</Scene>
</Scene>
</Scene>
<Scene key="login" rightTitle="Right" onRight={()=>{}} >
<Scene key="login" >
<Scene key="loginModal" component={Login} title="Login" leftTitle="Cancel" onLeft={Actions.pop}/>
<Scene
key="loginModal2"
Expand Down
7 changes: 7 additions & 0 deletions Example/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const styles = StyleSheet.create({
});

export default class extends React.Component {
componentDidMount() {
Actions.refresh({
title: 'Login!',
rightTitle: 'rightTitle',
onRight: () => {},
});
}
render() {
const title = this.props.title || 'No Title';
const data = this.props.data || 'No Data';
Expand Down
7 changes: 5 additions & 2 deletions src/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ function createNavigationOptions(params) {
res.tabBarIcon = tabBarIcon || icon;
}

if ((rightButtonImage || rightTitle || params.renderRightButton) && onRight) {
if (rightButtonImage || rightTitle || params.renderRightButton || onRight || navigationParams.onRight
|| navigationParams.rightTitle || navigationParams.rightButtonImage) {
res.headerRight = getValue(navigationParams.right || right || rightButton || params.renderRightButton,
{ ...navigationParams, ...screenProps }) || renderRightButton({ ...params, ...navigationParams });
}

if (leftButtonImage || backButtonImage || backTitle || leftTitle || params.renderLeftButton || leftButtonTextStyle || backButtonTextStyle || onLeft) {
if (leftButtonImage || backButtonImage || backTitle || leftTitle || params.renderLeftButton || leftButtonTextStyle
|| backButtonTextStyle || onLeft || navigationParams.leftTitle || navigationParams.onLeft || navigationParams.leftButtonImage
|| navigationParams.backButtonImage || navigationParams.backTitle) {
res.headerLeft = getValue(navigationParams.left || left || leftButton || params.renderLeftButton, { ...params, ...navigationParams, ...screenProps })
|| renderLeftButton({ ...params, ...navigationParams }) || (init ? null : renderBackButton({ ...params, ...navigationParams, ...screenProps }));
}
Expand Down

0 comments on commit a5666a6

Please sign in to comment.