2016-03-04 22:56:37 +00:00
|
|
|
/**
|
|
|
|
* 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');
|
|
|
|
|
2016-10-14 17:40:15 +00:00
|
|
|
import type React from 'react';
|
|
|
|
|
2016-03-04 22:56:37 +00:00
|
|
|
// Object Instances
|
|
|
|
|
|
|
|
export type NavigationAnimatedValue = Animated.Value;
|
|
|
|
|
|
|
|
// Value & Structs.
|
|
|
|
|
|
|
|
export type NavigationGestureDirection = 'horizontal' | 'vertical';
|
|
|
|
|
2016-05-20 21:24:24 +00:00
|
|
|
export type NavigationRoute = {
|
2016-03-04 22:56:37 +00:00
|
|
|
key: string,
|
2016-07-01 00:54:50 +00:00
|
|
|
title?: string
|
2016-03-04 22:56:37 +00:00
|
|
|
};
|
|
|
|
|
2016-05-20 21:24:24 +00:00
|
|
|
export type NavigationState = {
|
2016-05-21 01:09:57 +00:00
|
|
|
index: number,
|
2016-05-22 23:27:53 +00:00
|
|
|
routes: Array<NavigationRoute>,
|
2016-03-04 22:56:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export type NavigationLayout = {
|
|
|
|
height: NavigationAnimatedValue,
|
|
|
|
initHeight: number,
|
|
|
|
initWidth: number,
|
2016-04-19 22:56:33 +00:00
|
|
|
isMeasured: boolean,
|
2016-03-04 22:56:37 +00:00
|
|
|
width: NavigationAnimatedValue,
|
|
|
|
};
|
|
|
|
|
|
|
|
export type NavigationScene = {
|
|
|
|
index: number,
|
2016-06-27 19:03:51 +00:00
|
|
|
isActive: boolean,
|
2016-03-04 22:56:37 +00:00
|
|
|
isStale: boolean,
|
2016-03-21 18:13:59 +00:00
|
|
|
key: string,
|
2016-05-21 01:09:57 +00:00
|
|
|
route: NavigationRoute,
|
2016-03-04 22:56:37 +00:00
|
|
|
};
|
|
|
|
|
2016-06-14 23:41:59 +00:00
|
|
|
export type NavigationTransitionProps = {
|
|
|
|
// The layout of the transitioner of the scenes.
|
2016-03-04 22:56:37 +00:00
|
|
|
layout: NavigationLayout,
|
|
|
|
|
2016-06-14 23:41:59 +00:00
|
|
|
// The navigation state of the transitioner.
|
2016-05-20 21:24:24 +00:00
|
|
|
navigationState: NavigationState,
|
2016-03-04 22:56:37 +00:00
|
|
|
|
2016-06-14 23:41:59 +00:00
|
|
|
// The progressive index of the transitioner's navigation state.
|
2016-05-18 20:32:52 +00:00
|
|
|
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,
|
2016-03-04 22:56:37 +00:00
|
|
|
|
2016-06-14 23:41:59 +00:00
|
|
|
// All the scenes of the transitioner.
|
|
|
|
scenes: Array<NavigationScene>,
|
|
|
|
|
2016-06-21 20:50:31 +00:00
|
|
|
// The active scene, corresponding to the route at
|
|
|
|
// `navigationState.routes[navigationState.index]`.
|
2016-06-14 23:41:59 +00:00
|
|
|
scene: NavigationScene,
|
2016-07-25 18:46:47 +00:00
|
|
|
|
|
|
|
// The gesture distance for `horizontal` and `vertical` transitions
|
|
|
|
gestureResponseDistance?: ?number,
|
2016-03-04 22:56:37 +00:00
|
|
|
};
|
|
|
|
|
2016-06-21 20:50:31 +00:00
|
|
|
// Similar to `NavigationTransitionProps`, except that the prop `scene`
|
|
|
|
// represents the scene for the renderer to render.
|
|
|
|
export type NavigationSceneRendererProps = NavigationTransitionProps;
|
|
|
|
|
2016-03-15 22:58:38 +00:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2016-05-18 20:32:52 +00:00
|
|
|
export type NavigationTransitionSpec = {
|
|
|
|
duration?: number,
|
|
|
|
// An easing function from `Easing`.
|
|
|
|
easing?: () => any,
|
2016-06-30 01:39:48 +00:00
|
|
|
// A timing function such as `Animated.timing`.
|
|
|
|
timing?: (value: NavigationAnimatedValue, config: any) => any,
|
2016-05-18 20:32:52 +00:00
|
|
|
};
|
|
|
|
|
2016-03-04 22:56:37 +00:00
|
|
|
// Functions.
|
|
|
|
|
|
|
|
export type NavigationAnimationSetter = (
|
|
|
|
position: NavigationAnimatedValue,
|
2016-05-20 21:24:24 +00:00
|
|
|
newState: NavigationState,
|
|
|
|
lastState: NavigationState,
|
2016-03-04 22:56:37 +00:00
|
|
|
) => void;
|
|
|
|
|
|
|
|
export type NavigationSceneRenderer = (
|
|
|
|
props: NavigationSceneRendererProps,
|
2016-10-16 11:11:59 +00:00
|
|
|
) => ?React.Element<any>;
|
2016-03-24 22:48:27 +00:00
|
|
|
|
|
|
|
export type NavigationStyleInterpolator = (
|
|
|
|
props: NavigationSceneRendererProps,
|
|
|
|
) => Object;
|