Skip to content

Commit

Permalink
tabs show onPress item (#828)
Browse files Browse the repository at this point in the history
* tabs show onPress item

* [Fix] Fix sceneStyle layout dislocation

DefaultRenderer

* ESLINT

* ESLINT

* recovery

this is not a good solution.

* fix

@alextkd

* ESLINT
  • Loading branch information
phproot authored and aksonov committed Jun 22, 2016
1 parent a769b10 commit 1260168
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Actions {
});
list = normalized; // normalize the list of scenes

const condition = el => (!el.props.component && !el.props.children &&
const condition = el => (!el.props.component && !el.props.children && !el.props.onPress &&
(!el.props.type || el.props.type === REFRESH_ACTION));
// determine sub-states
let baseKey = root.key;
Expand All @@ -126,7 +126,9 @@ class Actions {
if (list.length) {
res.children = list.map(c => this.iterate(c, res, refs, wrapBy).key);
} else {
assert(component, `component property is not set for key=${key}`);
if (!staticProps.onPress) {
assert(component, `component property is not set for key=${key}`);
}
// wrap scene if parent is "tabs"
if (parentProps.tabs) {
const innerKey = `${res.key}_`;
Expand Down
6 changes: 5 additions & 1 deletion src/TabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ class TabBar extends Component {
`No action is defined for name=${el.props.name} ` +
`actions: ${JSON.stringify(Object.keys(Actions))}`);
}
Actions[el.props.name]();
if (typeof el.props.onPress === 'function') {
el.props.onPress();
} else {
Actions[el.props.name]();
}
}

renderScene(navigationState) {
Expand Down

0 comments on commit 1260168

Please sign in to comment.