Skip to content

Instantly share code, notes, and snippets.

@callmephilip
Created May 18, 2016 15:41
Show Gist options
  • Save callmephilip/fc9c63c59deb2bb69bc4ff5d3d809282 to your computer and use it in GitHub Desktop.
Save callmephilip/fc9c63c59deb2bb69bc4ff5d3d809282 to your computer and use it in GitHub Desktop.
/*
*
* GlobalNavigation
*
*/
import { View, NavigationExperimental } from 'react-native';
import React, { Component } from 'react';
import styles from './styles';
import { connect } from 'react-redux';
import ApplicationTabs from '../ApplicationTabs';
const { CardStack: NavigationCardStack } = NavigationExperimental;
class GlobalNavigation extends Component {
render() {
return (
<NavigationCardStack
direction={'vertical'}
navigationState={this.props.navigation}
onNavigate={this.props.onNavigate}
renderScene={this._renderScene.bind(this)}
style={styles.main}
/>
);
}
_renderScene(props) {
// XX: simplified _renderScene
if (props.scene.navigationState.key === 'applicationTabs') {
return (
<View style={{flex: 1}}>
<ApplicationTabs />
</View>
);
}
}
}
function mapDispatchToProps(dispatch) {
return {
dispatch,
onNavigate: (action) => dispatch(action)
};
}
function mapStateToProps(state) {
return {
navigation: state.get('globalNavigation')
};
}
export default connect(mapStateToProps, mapDispatchToProps)(GlobalNavigation);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment