mirror of
https://github.com/status-im/react-native.git
synced 2025-02-12 01:16:46 +00:00
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
110 lines
2.8 KiB
JavaScript
110 lines
2.8 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule NavigationTypeDefinition
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
const Animated = require('Animated');
|
|
|
|
// Object Instances
|
|
|
|
export type NavigationAnimatedValue = Animated.Value;
|
|
|
|
// Value & Structs.
|
|
|
|
export type NavigationGestureDirection = 'horizontal' | 'vertical';
|
|
|
|
export type NavigationRoute = {
|
|
key: string,
|
|
};
|
|
|
|
export type NavigationState = {
|
|
index: number,
|
|
routes: Array<NavigationRoute>,
|
|
};
|
|
|
|
export type NavigationLayout = {
|
|
height: NavigationAnimatedValue,
|
|
initHeight: number,
|
|
initWidth: number,
|
|
isMeasured: boolean,
|
|
width: NavigationAnimatedValue,
|
|
};
|
|
|
|
export type NavigationScene = {
|
|
index: number,
|
|
isStale: boolean,
|
|
key: string,
|
|
route: NavigationRoute,
|
|
};
|
|
|
|
export type NavigationSceneRendererProps = {
|
|
// The layout of the containing view of the scenes.
|
|
layout: NavigationLayout,
|
|
|
|
// The navigation state of the containing view.
|
|
navigationState: NavigationState,
|
|
|
|
// The progressive index of the containing view's navigation state.
|
|
position: NavigationAnimatedValue,
|
|
|
|
// The value that represents the progress of the transition when navigation
|
|
// state changes from one to another. Its numberic value will range from 0
|
|
// to 1.
|
|
// progress.__getAnimatedValue() < 1 : transtion is happening.
|
|
// progress.__getAnimatedValue() == 1 : transtion completes.
|
|
progress: NavigationAnimatedValue,
|
|
|
|
// The scene to render.
|
|
scene: NavigationScene,
|
|
|
|
// All the scenes of the containing view's.
|
|
scenes: Array<NavigationScene>,
|
|
};
|
|
|
|
export type NavigationPanPanHandlers = {
|
|
onMoveShouldSetResponder: Function,
|
|
onMoveShouldSetResponderCapture: Function,
|
|
onResponderEnd: Function,
|
|
onResponderGrant: Function,
|
|
onResponderMove: Function,
|
|
onResponderReject: Function,
|
|
onResponderRelease: Function,
|
|
onResponderStart: Function,
|
|
onResponderTerminate: Function,
|
|
onResponderTerminationRequest: Function,
|
|
onStartShouldSetResponder: Function,
|
|
onStartShouldSetResponderCapture: Function,
|
|
};
|
|
|
|
export type NavigationTransitionSpec = {
|
|
duration?: number,
|
|
// An easing function from `Easing`.
|
|
easing?: () => any,
|
|
};
|
|
|
|
// Functions.
|
|
|
|
export type NavigationAnimationSetter = (
|
|
position: NavigationAnimatedValue,
|
|
newState: NavigationState,
|
|
lastState: NavigationState,
|
|
) => void;
|
|
|
|
export type NavigationSceneRenderer = (
|
|
props: NavigationSceneRendererProps,
|
|
) => ?ReactElement<any>;
|
|
|
|
export type NavigationStyleInterpolator = (
|
|
props: NavigationSceneRendererProps,
|
|
) => Object;
|
|
|
|
export type NavigationTransitionConfigurator = () => NavigationTransitionSpec;
|