Skip to content

Commit

Permalink
support onLeftPressed/onRightPressed over TabBar.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdzl2003 committed Feb 2, 2017
1 parent 9bcdb1a commit f904f05
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/pages/home/TabBar.js
Expand Up @@ -37,6 +37,7 @@ export default class TabBar extends Component {
static contextTypes = {
navigator: PropTypes.object,
};

goto(location) {
const { navigator } = this.context;
navigator.replace({ location });
Expand All @@ -50,13 +51,25 @@ export default class TabBar extends Component {
</TouchableOpacity>
);
}
onLeftPressed() {
if (this.childrenRef && this.childrenRef.onLeftPressed) {
this.childrenRef.onLeftPressed();
}
}
onRightPressed() {
if (this.childrenRef && this.childrenRef.onRightPressed) {
this.childrenRef.onRightPressed();
}
}
getRef = (ref) => {
this.childrenRef = ref;
};
render() {
const { children, router: _, ...others } = this.props;
console.log(others);
return (
<View style={styles.container}>
<View style={styles.content}>
{children}
{React.cloneElement(children, { ref: this.getRef })}
</View>
<View style={styles.tabBar}>
{this.renderItem('/home/home', '首页')}
Expand Down

0 comments on commit f904f05

Please sign in to comment.