Clean up NavigationView.

Summary:This address the issue reported at
https://github.com/facebook/react-native/issues/6579#issuecomment-200984628

NavigationView should have the same API as NavigationAnimatedView does except
that NavigationView does not need the APIs for animation.

This unify the API of our core components so that people can freely
compose views with both NavigationAnimatedView or NavigationView.

Reviewed By: fkgozali

Differential Revision: D3096076

fb-gh-sync-id: 7536777a7d637da62a2636d750f9d91c5a0eb45f
fbshipit-source-id: 7536777a7d637da62a2636d750f9d91c5a0eb45f
This commit is contained in:
Hedger Wang
2016-03-29 15:56:53 -07:00
committed by Facebook Github Bot 9
parent 97d15f7f0a
commit 68918e8773
3 changed files with 169 additions and 42 deletions

View File

@@ -265,21 +265,33 @@ class NavigationCompositionExample extends React.Component {
}
class ExampleMainView extends React.Component {
_renderScene: NavigationSceneRenderer;
componentWillMount() {
this._renderScene = this._renderScene.bind(this);
}
render() {
return (
<NavigationView
navigationState={this.props.navigationState}
style={styles.tabsContent}
renderScene={(tabState, index) => (
<ExampleTabScreen
key={tabState.key}
navigationState={tabState}
onNavigate={this._handleNavigation.bind(this, tabState.key)}
/>
)}
renderScene={this._renderScene}
/>
);
}
_renderScene(props: NavigationSceneRendererProps): ReactElement {
const {scene} = props;
return (
<ExampleTabScreen
key={'tab_screen' + scene.key}
navigationState={scene.navigationState}
onNavigate={this._handleNavigation.bind(this, scene.key)}
/>
);
}
_handleNavigation(tabKey, action) {
if (ExampleExitAction.match(action)) {
this.props.onExampleExit();
@@ -288,6 +300,7 @@ class ExampleMainView extends React.Component {
this.props.onNavigate(action);
}
}
ExampleMainView = NavigationContainer.create(ExampleMainView);
const styles = StyleSheet.create({