Files
react-native/Libraries/NavigationExperimental/NavigationTypeDefinition.js
Eric Vicenti 472f815e45 NavigationExperimental: Add key to NavigationSceneRendererProps
Summary:
This should simplify the renderScene usage a bit because the react key is required and this will make sure they are rendered with the right key automatically.

It changes the string to make sure people do not rely on this API for anything else.

Reviewed By: javache

Differential Revision: D3033933

fb-gh-sync-id: 036424af28693be32c3a3290f5c6667a6a6a04ac
fbshipit-source-id: 036424af28693be32c3a3290f5c6667a6a6a04ac
2016-05-05 11:58:26 -07:00

118 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 NavigationState = {
key: string,
};
export type NavigationParentState = {
index: number,
key: string,
children: Array<NavigationState>,
};
export type NavigationAction = any;
export type NavigationLayout = {
height: NavigationAnimatedValue,
initHeight: number,
initWidth: number,
isMeasured: boolean,
width: NavigationAnimatedValue,
};
export type NavigationPosition = NavigationAnimatedValue;
export type NavigationScene = {
index: number,
isStale: boolean,
key: string,
navigationState: NavigationState,
};
export type NavigationSceneRendererProps = {
// The layout of the containing view of the scenes.
layout: NavigationLayout,
// The navigation state of the containing view.
navigationState: NavigationParentState,
// Callback to navigation with an action.
onNavigate: NavigationActionCaller,
// The progressive index of the containing view's navigation state.
position: NavigationPosition,
// The scene to render.
scene: NavigationScene,
// The key of the scene
key: string,
// 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,
};
// Functions.
export type NavigationActionCaller = Function;
export type NavigationAnimationSetter = (
position: NavigationAnimatedValue,
newState: NavigationParentState,
lastState: NavigationParentState,
) => void;
export type NavigationRenderer = (
navigationState: ?NavigationState,
onNavigate: NavigationActionCaller,
) => ReactElement;
export type NavigationReducer = (
state: ?NavigationState,
action: ?NavigationAction,
) => NavigationState;
export type NavigationSceneRenderer = (
props: NavigationSceneRendererProps,
) => ?ReactElement;
export type NavigationStyleInterpolator = (
props: NavigationSceneRendererProps,
) => Object;