Summary:
Remove prop `onNavigate` from these views.
- NavigationAnimatedView
- NavigationCardStack
- NavigationCard

Also, the `sceneProps` onject that is passed to the `renderScene` function
no longer contains `onNavigate`.

The contract that `onNavigate` expects has been vague. Different data flow
system may expect complete different params for such function

For instance,

  * onNavigate({type: 'back'});
  * onNavigate({type: 'BACK'});
  * onNavigate('back'});

We have no intention to unify such generic API since it's more likely to be
constrained by the data flow frameworks such as redux or flux.

Also, passing the prop `onNavigate` all the way down to the component that
invokes the navigation action can be really tedious. We'd expect developer
to either pass such callback (onNavigate) via context or just set up some
kind of static actions that any component can call directly.

`onNavigate` was previously added as a part of (redux-like) reducers-friendly
feature but that's no longer the case.

This new prop `onNavigateBack` is used to explicitly handle the case when the back button or back gesture
is performed.

Reviewed By: ericvicenti

Differential Revision: D3410873

fbshipit-source-id: a703cf0debd474cff33d6610e858b9c4bb3ecbf5
This commit is contained in:
Hedger Wang 2016-06-09 17:48:39 -07:00 коммит произвёл Facebook Github Bot 9
Родитель 7e445e6cfa
Коммит fb0007d853
13 изменённых файлов: 89 добавлений и 105 удалений

Просмотреть файл

@ -24,8 +24,6 @@ const NavigationExampleRow = require('./NavigationExampleRow');
const React = require('react'); const React = require('react');
const ReactNative = require('react-native'); const ReactNative = require('react-native');
const emptyFunction = require('fbjs/lib/emptyFunction');
/** /**
* Basic example that shows how to use <NavigationCardStack /> to build * Basic example that shows how to use <NavigationCardStack /> to build
* an app with controlled navigation system. * an app with controlled navigation system.
@ -137,11 +135,8 @@ class YourNavigator extends React.Component {
// Now use the `NavigationCardStack` to render the scenes. // Now use the `NavigationCardStack` to render the scenes.
render(): ReactElement { render(): ReactElement {
// TODO(hedger): prop `onNavigate` will be deprecated soon. For now,
// use `emptyFunction` as a placeholder.
return ( return (
<NavigationCardStack <NavigationCardStack
onNavigate={emptyFunction}
onNavigateBack={this._onPopRoute} onNavigateBack={this._onPopRoute}
navigationState={this.props.navigationState} navigationState={this.props.navigationState}
renderScene={this._renderScene} renderScene={this._renderScene}

Просмотреть файл

@ -249,6 +249,7 @@ const YourNavigator = createAppNavigationContainer(class extends Component {
// This sets up the methods (e.g. Pop, Push) for navigation. // This sets up the methods (e.g. Pop, Push) for navigation.
constructor(props: any, context: any) { constructor(props: any, context: any) {
super(props, context); super(props, context);
this._back = this._back.bind(this);
this._renderHeader = this._renderHeader.bind(this); this._renderHeader = this._renderHeader.bind(this);
this._renderScene = this._renderScene.bind(this); this._renderScene = this._renderScene.bind(this);
} }
@ -264,7 +265,7 @@ const YourNavigator = createAppNavigationContainer(class extends Component {
<View style={styles.navigator}> <View style={styles.navigator}>
<NavigationCardStack <NavigationCardStack
key={'stack_' + tabKey} key={'stack_' + tabKey}
onNavigate={this.props.navigate} onNavigateBack={this._back}
navigationState={scenes} navigationState={scenes}
renderOverlay={this._renderHeader} renderOverlay={this._renderHeader}
renderScene={this._renderScene} renderScene={this._renderScene}
@ -298,6 +299,10 @@ const YourNavigator = createAppNavigationContainer(class extends Component {
/> />
); );
} }
_back() {
this.props.navigate({type: 'pop'});
}
}); });
// Next step. // Next step.
@ -310,6 +315,7 @@ const YourHeader = createAppNavigationContainer(class extends Component {
constructor(props: Object, context: any) { constructor(props: Object, context: any) {
super(props, context); super(props, context);
this._back = this._back.bind(this);
this._renderTitleComponent = this._renderTitleComponent.bind(this); this._renderTitleComponent = this._renderTitleComponent.bind(this);
} }
@ -318,11 +324,15 @@ const YourHeader = createAppNavigationContainer(class extends Component {
<NavigationHeader <NavigationHeader
{...this.props} {...this.props}
renderTitleComponent={this._renderTitleComponent} renderTitleComponent={this._renderTitleComponent}
onNavigate={this.props.navigate} onNavigateBack={this._back}
/> />
); );
} }
_back(): void {
this.props.navigate({type: 'pop'});
}
_renderTitleComponent(): ReactElement { _renderTitleComponent(): ReactElement {
return ( return (
<NavigationHeader.Title> <NavigationHeader.Title>

Просмотреть файл

@ -63,11 +63,12 @@ type State = UIExplorerNavigationState & {
const APP_STATE_KEY = 'UIExplorerAppState.v1'; const APP_STATE_KEY = 'UIExplorerAppState.v1';
class UIExplorerApp extends React.Component { class UIExplorerApp extends React.Component {
_handleBack: Function;
_handleAction: Function;
_renderCard: Function;
_renderOverlay: Function; _renderOverlay: Function;
_renderScene: Function; _renderScene: Function;
_renderCard: Function;
_renderTitleComponent: Function; _renderTitleComponent: Function;
_handleAction: Function;
state: State; state: State;
constructor(props: Props) { constructor(props: Props) {
@ -76,6 +77,7 @@ class UIExplorerApp extends React.Component {
componentWillMount() { componentWillMount() {
this._handleAction = this._handleAction.bind(this); this._handleAction = this._handleAction.bind(this);
this._handleBack = this._handleAction.bind(this, {type: 'back'});
this._renderOverlay = this._renderOverlay.bind(this); this._renderOverlay = this._renderOverlay.bind(this);
this._renderScene = this._renderScene.bind(this); this._renderScene = this._renderScene.bind(this);
this._renderTitleComponent = this._renderTitleComponent.bind(this); this._renderTitleComponent = this._renderTitleComponent.bind(this);
@ -137,7 +139,7 @@ class UIExplorerApp extends React.Component {
style={styles.container} style={styles.container}
renderOverlay={this._renderOverlay} renderOverlay={this._renderOverlay}
renderScene={this._renderScene} renderScene={this._renderScene}
onNavigate={this._handleAction}
/> />
); );
} }
@ -146,6 +148,7 @@ class UIExplorerApp extends React.Component {
return ( return (
<NavigationHeader <NavigationHeader
{...props} {...props}
onNavigateBack={this._handleBack}
renderTitleComponent={this._renderTitleComponent} renderTitleComponent={this._renderTitleComponent}
/> />
); );

Просмотреть файл

@ -57,6 +57,7 @@ type SceneViewProps = {
type Props = NavigationSceneRendererProps & { type Props = NavigationSceneRendererProps & {
onComponentRef: (ref: any) => void, onComponentRef: (ref: any) => void,
onNavigateBack: ?Function,
panHandlers: ?NavigationPanPanHandlers, panHandlers: ?NavigationPanPanHandlers,
pointerEvents: string, pointerEvents: string,
renderScene: NavigationSceneRenderer, renderScene: NavigationSceneRenderer,
@ -93,6 +94,7 @@ class NavigationCard extends React.Component<any, Props, any> {
static propTypes = { static propTypes = {
...NavigationPropTypes.SceneRendererProps, ...NavigationPropTypes.SceneRendererProps,
onComponentRef: PropTypes.func.isRequired, onComponentRef: PropTypes.func.isRequired,
onNavigateBack: PropTypes.func,
panHandlers: NavigationPropTypes.panHandlers, panHandlers: NavigationPropTypes.panHandlers,
pointerEvents: PropTypes.string.isRequired, pointerEvents: PropTypes.string.isRequired,
renderScene: PropTypes.func.isRequired, renderScene: PropTypes.func.isRequired,
@ -121,7 +123,10 @@ class NavigationCard extends React.Component<any, Props, any> {
style; style;
const viewPanHandlers = panHandlers === undefined ? const viewPanHandlers = panHandlers === undefined ?
NavigationCardStackPanResponder.forHorizontal(props) : NavigationCardStackPanResponder.forHorizontal({
...props,
onNavigateBack: this.props.onNavigateBack,
}) :
panHandlers; panHandlers;
return ( return (

Просмотреть файл

@ -47,7 +47,6 @@ const {PropTypes} = React;
const {Directions} = NavigationCardStackPanResponder; const {Directions} = NavigationCardStackPanResponder;
import type { import type {
NavigationActionCaller,
NavigationState, NavigationState,
NavigationSceneRenderer, NavigationSceneRenderer,
NavigationSceneRendererProps, NavigationSceneRendererProps,
@ -60,9 +59,10 @@ import type {
type Props = { type Props = {
direction: NavigationGestureDirection, direction: NavigationGestureDirection,
navigationState: NavigationState, navigationState: NavigationState,
onNavigate: NavigationActionCaller, onNavigateBack: ?Function,
renderOverlay: ?NavigationSceneRenderer, renderOverlay: ?NavigationSceneRenderer,
renderScene: NavigationSceneRenderer, renderScene: NavigationSceneRenderer,
style: any,
}; };
type DefaultProps = { type DefaultProps = {
@ -90,7 +90,7 @@ class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
static propTypes = { static propTypes = {
direction: PropTypes.oneOf([Directions.HORIZONTAL, Directions.VERTICAL]), direction: PropTypes.oneOf([Directions.HORIZONTAL, Directions.VERTICAL]),
navigationState: NavigationPropTypes.navigationState.isRequired, navigationState: NavigationPropTypes.navigationState.isRequired,
onNavigate: NavigationPropTypes.SceneRendererProps.onNavigate, onNavigateBack: PropTypes.func,
renderOverlay: PropTypes.func, renderOverlay: PropTypes.func,
renderScene: PropTypes.func.isRequired, renderScene: PropTypes.func.isRequired,
}; };
@ -122,8 +122,6 @@ class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
navigationState={this.props.navigationState} navigationState={this.props.navigationState}
renderOverlay={this.props.renderOverlay} renderOverlay={this.props.renderOverlay}
renderScene={this._renderScene} renderScene={this._renderScene}
onNavigate={this.props.onNavigate}
// $FlowFixMe - style should be declared
style={[styles.animatedView, this.props.style]} style={[styles.animatedView, this.props.style]}
/> />
); );
@ -136,9 +134,13 @@ class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
NavigationCardStackStyleInterpolator.forVertical(props) : NavigationCardStackStyleInterpolator.forVertical(props) :
NavigationCardStackStyleInterpolator.forHorizontal(props); NavigationCardStackStyleInterpolator.forHorizontal(props);
const panHandlersProps = {
...props,
onNavigateBack: this.props.onNavigateBack,
};
const panHandlers = isVertical ? const panHandlers = isVertical ?
NavigationCardStackPanResponder.forVertical(props) : NavigationCardStackPanResponder.forVertical(panHandlersProps) :
NavigationCardStackPanResponder.forHorizontal(props); NavigationCardStackPanResponder.forHorizontal(panHandlersProps);
return ( return (
<NavigationCard <NavigationCard

Просмотреть файл

@ -28,7 +28,7 @@ import type {
const ANIMATION_DURATION = 250; const ANIMATION_DURATION = 250;
/** /**
* The threshold to invoke the `onNavigate` action. * The threshold to invoke the `onNavigateBack` action.
* For instance, `1 / 3` means that moving greater than 1 / 3 of the width of * For instance, `1 / 3` means that moving greater than 1 / 3 of the width of
* the view will navigate. * the view will navigate.
*/ */
@ -62,14 +62,8 @@ const Directions = {
export type NavigationGestureDirection = 'horizontal' | 'vertical'; export type NavigationGestureDirection = 'horizontal' | 'vertical';
/** type Props = NavigationSceneRendererProps & {
* Primitive gesture actions. onNavigateBack: ?Function,
*/
const Actions = {
// The gesture to navigate backward.
// This is done by swiping from the left to the right or from the top to the
// bottom.
BACK: {type: 'back'},
}; };
/** /**
@ -90,12 +84,12 @@ class NavigationCardStackPanResponder extends NavigationAbstractPanResponder {
_isResponding: boolean; _isResponding: boolean;
_isVertical: boolean; _isVertical: boolean;
_props: NavigationSceneRendererProps; _props: Props;
_startValue: number; _startValue: number;
constructor( constructor(
direction: NavigationGestureDirection, direction: NavigationGestureDirection,
props: NavigationSceneRendererProps, props: Props,
) { ) {
super(); super();
this._isResponding = false; this._isResponding = false;
@ -181,8 +175,16 @@ class NavigationCardStackPanResponder extends NavigationAbstractPanResponder {
props.position.stopAnimation((value: number) => { props.position.stopAnimation((value: number) => {
this._reset(); this._reset();
if (distance > DISTANCE_THRESHOLD || value <= index - POSITION_THRESHOLD) {
props.onNavigate(Actions.BACK); if (!props.onNavigateBack) {
return;
}
if (
distance > DISTANCE_THRESHOLD ||
value <= index - POSITION_THRESHOLD
) {
props.onNavigateBack();
} }
}); });
} }
@ -206,20 +208,20 @@ class NavigationCardStackPanResponder extends NavigationAbstractPanResponder {
function createPanHandlers( function createPanHandlers(
direction: NavigationGestureDirection, direction: NavigationGestureDirection,
props: NavigationSceneRendererProps, props: Props,
): NavigationPanPanHandlers { ): NavigationPanPanHandlers {
const responder = new NavigationCardStackPanResponder(direction, props); const responder = new NavigationCardStackPanResponder(direction, props);
return responder.panHandlers; return responder.panHandlers;
} }
function forHorizontal( function forHorizontal(
props: NavigationSceneRendererProps, props: Props,
): NavigationPanPanHandlers { ): NavigationPanPanHandlers {
return createPanHandlers(Directions.HORIZONTAL, props); return createPanHandlers(Directions.HORIZONTAL, props);
} }
function forVertical( function forVertical(
props: NavigationSceneRendererProps, props: Props,
): NavigationPanPanHandlers { ): NavigationPanPanHandlers {
return createPanHandlers(Directions.VERTICAL, props); return createPanHandlers(Directions.VERTICAL, props);
} }
@ -232,7 +234,6 @@ module.exports = {
RESPOND_THRESHOLD, RESPOND_THRESHOLD,
// enums // enums
Actions,
Directions, Directions,
// methods. // methods.

Просмотреть файл

@ -48,23 +48,27 @@ const {
} = ReactNative; } = ReactNative;
import type { import type {
NavigationActionCaller,
NavigationSceneRenderer,
NavigationSceneRendererProps, NavigationSceneRendererProps,
NavigationStyleInterpolator, NavigationStyleInterpolator,
} from 'NavigationTypeDefinition'; } from 'NavigationTypeDefinition';
type SubViewProps = NavigationSceneRendererProps & {
onNavigateBack: ?Function,
};
type SubViewRenderer = (subViewProps: SubViewProps) => ?ReactElement<any>;
type DefaultProps = { type DefaultProps = {
renderLeftComponent: NavigationSceneRenderer, renderLeftComponent: SubViewRenderer,
renderRightComponent: NavigationSceneRenderer, renderRightComponent: SubViewRenderer,
renderTitleComponent: NavigationSceneRenderer, renderTitleComponent: SubViewRenderer,
}; };
type Props = NavigationSceneRendererProps & { type Props = NavigationSceneRendererProps & {
renderLeftComponent: NavigationSceneRenderer, onNavigateBack: ?Function,
renderRightComponent: NavigationSceneRenderer, renderLeftComponent: SubViewRenderer,
renderTitleComponent: NavigationSceneRenderer, renderRightComponent: SubViewRenderer,
onNavigate: NavigationActionCaller, renderTitleComponent: SubViewRenderer,
style?: any, style?: any,
viewProps?: any, viewProps?: any,
}; };
@ -80,30 +84,31 @@ class NavigationHeader extends React.Component<DefaultProps, Props, any> {
static defaultProps = { static defaultProps = {
renderTitleComponent: (props: NavigationSceneRendererProps) => { renderTitleComponent: (props: SubViewProps) => {
const {navigationState} = props; const {navigationState} = props;
const title = String(navigationState.title || ''); const title = String(navigationState.title || '');
return <NavigationHeaderTitle>{title}</NavigationHeaderTitle>; return <NavigationHeaderTitle>{title}</NavigationHeaderTitle>;
}, },
renderLeftComponent: (props: NavigationSceneRendererProps) => { renderLeftComponent: (props: SubViewProps) => {
if (props.scene.index === 0) { if (props.scene.index === 0 || !props.onNavigateBack) {
return null; return null;
} }
return ( return (
<NavigationHeaderBackButton <NavigationHeaderBackButton
onNavigate={props.onNavigate} onPress={props.onNavigateBack}
/> />
); );
}, },
renderRightComponent: (props: NavigationSceneRendererProps) => { renderRightComponent: (props: SubViewProps) => {
return null; return null;
}, },
}; };
static propTypes = { static propTypes = {
...NavigationPropTypes.SceneRendererProps, ...NavigationPropTypes.SceneRendererProps,
onNavigateBack: PropTypes.func,
renderLeftComponent: PropTypes.func, renderLeftComponent: PropTypes.func,
renderRightComponent: PropTypes.func, renderRightComponent: PropTypes.func,
renderTitleComponent: PropTypes.func, renderTitleComponent: PropTypes.func,
@ -167,7 +172,7 @@ class NavigationHeader extends React.Component<DefaultProps, Props, any> {
_renderSubView( _renderSubView(
props: NavigationSceneRendererProps, props: NavigationSceneRendererProps,
name: SubViewName, name: SubViewName,
renderer: NavigationSceneRenderer, renderer: SubViewRenderer,
styleInterpolator: NavigationStyleInterpolator, styleInterpolator: NavigationStyleInterpolator,
): ?ReactElement<any> { ): ?ReactElement<any> {
const { const {
@ -189,7 +194,8 @@ class NavigationHeader extends React.Component<DefaultProps, Props, any> {
return null; return null;
} }
const subView = renderer(props); const subViewProps = {...props, onNavigateBack: this.props.onNavigateBack};
const subView = renderer(subViewProps);
if (subView === null) { if (subView === null) {
return null; return null;
} }

Просмотреть файл

@ -34,17 +34,17 @@ const {
} = ReactNative; } = ReactNative;
type Props = { type Props = {
onNavigate: Function onPress: Function,
} };
const NavigationHeaderBackButton = (props: Props) => ( const NavigationHeaderBackButton = (props: Props) => (
<TouchableOpacity style={styles.buttonContainer} onPress={() => props.onNavigate({type: 'BackAction'})}> <TouchableOpacity style={styles.buttonContainer} onPress={props.onPress}>
<Image style={styles.button} source={require('./assets/back-icon.png')} /> <Image style={styles.button} source={require('./assets/back-icon.png')} />
</TouchableOpacity> </TouchableOpacity>
); );
NavigationHeaderBackButton.propTypes = { NavigationHeaderBackButton.propTypes = {
onNavigate: React.PropTypes.func.isRequired onPress: React.PropTypes.func.isRequired
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({

Просмотреть файл

@ -27,7 +27,10 @@ import type {
NavigationGestureDirection, NavigationGestureDirection,
} from 'NavigationCardStackPanResponder'; } from 'NavigationCardStackPanResponder';
type Props = NavigationSceneRendererProps & {
onNavigateBack: ?Function,
onNavigateForward: ?Function,
};
/** /**
* Primitive gesture directions. * Primitive gesture directions.
@ -40,14 +43,6 @@ const {
Directions, Directions,
} = NavigationCardStackPanResponder; } = NavigationCardStackPanResponder;
/**
* Primitive gesture actions.
*/
const Actions = {
JUMP_BACK: {type: 'jump_back'},
JUMP_FORWARD: {type: 'jump_forward'},
};
/** /**
* Pan responder that handles gesture for a card in the cards list. * Pan responder that handles gesture for a card in the cards list.
* *
@ -66,12 +61,12 @@ class NavigationPagerPanResponder extends NavigationAbstractPanResponder {
_isResponding: boolean; _isResponding: boolean;
_isVertical: boolean; _isVertical: boolean;
_props: NavigationSceneRendererProps; _props: Props;
_startValue: number; _startValue: number;
constructor( constructor(
direction: NavigationGestureDirection, direction: NavigationGestureDirection,
props: NavigationSceneRendererProps, props: Props,
) { ) {
super(); super();
this._isResponding = false; this._isResponding = false;
@ -157,7 +152,8 @@ class NavigationPagerPanResponder extends NavigationAbstractPanResponder {
const { const {
navigationState, navigationState,
onNavigate, onNavigateBack,
onNavigateForward,
position, position,
} = this._props; } = this._props;
@ -172,7 +168,7 @@ class NavigationPagerPanResponder extends NavigationAbstractPanResponder {
distance > DISTANCE_THRESHOLD || distance > DISTANCE_THRESHOLD ||
value <= index - POSITION_THRESHOLD value <= index - POSITION_THRESHOLD
) { ) {
onNavigate(Actions.JUMP_BACK); onNavigateBack && onNavigateBack();
return; return;
} }
@ -180,7 +176,7 @@ class NavigationPagerPanResponder extends NavigationAbstractPanResponder {
distance < -DISTANCE_THRESHOLD || distance < -DISTANCE_THRESHOLD ||
value >= index + POSITION_THRESHOLD value >= index + POSITION_THRESHOLD
) { ) {
onNavigate(Actions.JUMP_FORWARD); onNavigateForward && onNavigateForward();
} }
}); });
} }
@ -204,19 +200,18 @@ class NavigationPagerPanResponder extends NavigationAbstractPanResponder {
function createPanHandlers( function createPanHandlers(
direction: NavigationGestureDirection, direction: NavigationGestureDirection,
props: NavigationSceneRendererProps, props: Props,
): NavigationPanPanHandlers { ): NavigationPanPanHandlers {
const responder = new NavigationPagerPanResponder(direction, props); const responder = new NavigationPagerPanResponder(direction, props);
return responder.panHandlers; return responder.panHandlers;
} }
function forHorizontal( function forHorizontal(
props: NavigationSceneRendererProps, props: Props,
): NavigationPanPanHandlers { ): NavigationPanPanHandlers {
return createPanHandlers(Directions.HORIZONTAL, props); return createPanHandlers(Directions.HORIZONTAL, props);
} }
module.exports = { module.exports = {
Actions,
forHorizontal, forHorizontal,
}; };

Просмотреть файл

@ -24,7 +24,6 @@ const StyleSheet = require('StyleSheet');
const View = require('View'); const View = require('View');
import type { import type {
NavigationActionCaller,
NavigationAnimatedValue, NavigationAnimatedValue,
NavigationAnimationSetter, NavigationAnimationSetter,
NavigationLayout, NavigationLayout,
@ -36,7 +35,6 @@ import type {
type Props = { type Props = {
applyAnimation: NavigationAnimationSetter, applyAnimation: NavigationAnimationSetter,
navigationState: NavigationState, navigationState: NavigationState,
onNavigate: NavigationActionCaller,
renderOverlay: ?NavigationSceneRenderer, renderOverlay: ?NavigationSceneRenderer,
renderScene: NavigationSceneRenderer, renderScene: NavigationSceneRenderer,
style: any, style: any,
@ -77,7 +75,6 @@ class NavigationAnimatedView
static propTypes = { static propTypes = {
applyAnimation: PropTypes.func, applyAnimation: PropTypes.func,
navigationState: NavigationPropTypes.navigationState.isRequired, navigationState: NavigationPropTypes.navigationState.isRequired,
onNavigate: PropTypes.func.isRequired,
renderOverlay: PropTypes.func, renderOverlay: PropTypes.func,
renderScene: PropTypes.func.isRequired, renderScene: PropTypes.func.isRequired,
}; };
@ -182,7 +179,6 @@ class NavigationAnimatedView
_renderScene(scene: NavigationScene): ?ReactElement<any> { _renderScene(scene: NavigationScene): ?ReactElement<any> {
const { const {
navigationState, navigationState,
onNavigate,
renderScene, renderScene,
} = this.props; } = this.props;
@ -195,7 +191,6 @@ class NavigationAnimatedView
return renderScene({ return renderScene({
layout: this.state.layout, layout: this.state.layout,
navigationState, navigationState,
onNavigate,
position, position,
progress, progress,
scene, scene,
@ -207,7 +202,6 @@ class NavigationAnimatedView
if (this.props.renderOverlay) { if (this.props.renderOverlay) {
const { const {
navigationState, navigationState,
onNavigate,
renderOverlay, renderOverlay,
} = this.props; } = this.props;
@ -220,7 +214,6 @@ class NavigationAnimatedView
return renderOverlay({ return renderOverlay({
layout: this.state.layout, layout: this.state.layout,
navigationState, navigationState,
onNavigate,
position, position,
progress, progress,
scene: scenes[navigationState.index], scene: scenes[navigationState.index],

Просмотреть файл

@ -67,7 +67,6 @@ const scene = PropTypes.shape({
const SceneRendererProps = { const SceneRendererProps = {
layout: layout.isRequired, layout: layout.isRequired,
navigationState: navigationState.isRequired, navigationState: navigationState.isRequired,
onNavigate: PropTypes.func.isRequired,
position: animatedValue.isRequired, position: animatedValue.isRequired,
progress: animatedValue.isRequired, progress: animatedValue.isRequired,
scene: scene.isRequired, scene: scene.isRequired,
@ -101,7 +100,6 @@ function extractSceneRendererProps(
return { return {
layout: props.layout, layout: props.layout,
navigationState: props.navigationState, navigationState: props.navigationState,
onNavigate: props.onNavigate,
position: props.position, position: props.position,
progress: props.progress, progress: props.progress,
scene: props.scene, scene: props.scene,

Просмотреть файл

@ -22,7 +22,6 @@ const View = require('View');
const invariant = require('fbjs/lib/invariant'); const invariant = require('fbjs/lib/invariant');
import type { import type {
NavigationActionCaller,
NavigationAnimatedValue, NavigationAnimatedValue,
NavigationLayout, NavigationLayout,
NavigationState, NavigationState,
@ -34,7 +33,6 @@ import type {
type Props = { type Props = {
configureTransition: NavigationTransitionConfigurator, configureTransition: NavigationTransitionConfigurator,
navigationState: NavigationState, navigationState: NavigationState,
onNavigate: NavigationActionCaller,
onTransitionEnd: () => void, onTransitionEnd: () => void,
onTransitionStart: () => void, onTransitionStart: () => void,
renderOverlay: ?NavigationSceneRenderer, renderOverlay: ?NavigationSceneRenderer,
@ -71,7 +69,6 @@ class NavigationTransitioner extends React.Component<any, Props, State> {
static propTypes = { static propTypes = {
configureTransition: PropTypes.func, configureTransition: PropTypes.func,
navigationState: NavigationPropTypes.navigationState.isRequired, navigationState: NavigationPropTypes.navigationState.isRequired,
onNavigate: PropTypes.func.isRequired,
onTransitionEnd: PropTypes.func, onTransitionEnd: PropTypes.func,
onTransitionStart: PropTypes.func, onTransitionStart: PropTypes.func,
renderOverlay: PropTypes.func, renderOverlay: PropTypes.func,
@ -186,7 +183,6 @@ class NavigationTransitioner extends React.Component<any, Props, State> {
_renderScene(scene: NavigationScene): ?ReactElement<any> { _renderScene(scene: NavigationScene): ?ReactElement<any> {
const { const {
navigationState, navigationState,
onNavigate,
renderScene, renderScene,
} = this.props; } = this.props;
@ -199,7 +195,6 @@ class NavigationTransitioner extends React.Component<any, Props, State> {
return renderScene({ return renderScene({
layout: this.state.layout, layout: this.state.layout,
navigationState, navigationState,
onNavigate,
position, position,
progress, progress,
scene, scene,
@ -211,7 +206,6 @@ class NavigationTransitioner extends React.Component<any, Props, State> {
if (this.props.renderOverlay) { if (this.props.renderOverlay) {
const { const {
navigationState, navigationState,
onNavigate,
renderOverlay, renderOverlay,
} = this.props; } = this.props;
@ -234,7 +228,6 @@ class NavigationTransitioner extends React.Component<any, Props, State> {
return renderOverlay({ return renderOverlay({
layout: this.state.layout, layout: this.state.layout,
navigationState, navigationState,
onNavigate,
position, position,
progress, progress,
scene: activeScene, scene: activeScene,

Просмотреть файл

@ -30,8 +30,6 @@ export type NavigationState = {
routes: Array<NavigationRoute>, routes: Array<NavigationRoute>,
}; };
export type NavigationAction = any;
export type NavigationLayout = { export type NavigationLayout = {
height: NavigationAnimatedValue, height: NavigationAnimatedValue,
initHeight: number, initHeight: number,
@ -54,9 +52,6 @@ export type NavigationSceneRendererProps = {
// The navigation state of the containing view. // The navigation state of the containing view.
navigationState: NavigationState, navigationState: NavigationState,
// Callback to navigation with an action.
onNavigate: NavigationActionCaller,
// The progressive index of the containing view's navigation state. // The progressive index of the containing view's navigation state.
position: NavigationAnimatedValue, position: NavigationAnimatedValue,
@ -97,24 +92,12 @@ export type NavigationTransitionSpec = {
// Functions. // Functions.
export type NavigationActionCaller = Function;
export type NavigationAnimationSetter = ( export type NavigationAnimationSetter = (
position: NavigationAnimatedValue, position: NavigationAnimatedValue,
newState: NavigationState, newState: NavigationState,
lastState: NavigationState, lastState: NavigationState,
) => void; ) => void;
export type NavigationRenderer = (
navigationState: ?NavigationRoute,
onNavigate: NavigationActionCaller,
) => ReactElement<any>;
export type NavigationReducer = (
state: ?NavigationRoute,
action: ?NavigationAction,
) => NavigationRoute;
export type NavigationSceneRenderer = ( export type NavigationSceneRenderer = (
props: NavigationSceneRendererProps, props: NavigationSceneRendererProps,
) => ?ReactElement<any>; ) => ?ReactElement<any>;