This repository was archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathNavigator.js
More file actions
104 lines (91 loc) · 3.15 KB
/
Navigator.js
File metadata and controls
104 lines (91 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import PropTypes from 'prop-types';
import createMockComponent from './createMockComponent';
import View from './View';
import createReactClass from 'create-react-class';
const NavigatorSceneConfigType = PropTypes.shape({
gestures: PropTypes.object,
springFriction: PropTypes.number,
springTension: PropTypes.number,
defaultTransitionVelocity: PropTypes.number,
animationInterpolators: PropTypes.object,
});
const NavigatorSceneConfigs = {
PushFromRight: NavigatorSceneConfigType,
FloatFromRight: NavigatorSceneConfigType,
FloatFromLeft: NavigatorSceneConfigType,
FloatFromBottom: NavigatorSceneConfigType,
FloatFromBottomAndroid: NavigatorSceneConfigType,
FadeAndroid: NavigatorSceneConfigType,
HorizontalSwipeJump: NavigatorSceneConfigType,
HorizontalSwipeJumpFromRight: NavigatorSceneConfigType,
VerticalUpSwipeJump: NavigatorSceneConfigType,
VerticalDownSwipeJump: NavigatorSceneConfigType
};
const Navigator = createReactClass({
propTypes: {
/**
* Optional function that allows configuration about scene animations and
* gestures. Will be invoked with the route and the routeStack and should
* return a scene configuration object
*
* ```
* (route, routeStack) => Navigator.SceneConfigs.FloatFromRight
* ```
*/
configureScene: PropTypes.func,
/**
* Required function which renders the scene for a given route. Will be
* invoked with the route and the navigator object
*
* ```
* (route, navigator) =>
* <MySceneComponent title={route.title} navigator={navigator} />
* ```
*/
renderScene: PropTypes.func.isRequired,
/**
* Specify a route to start on. A route is an object that the navigator
* will use to identify each scene to render. `initialRoute` must be
* a route in the `initialRouteStack` if both props are provided. The
* `initialRoute` will default to the last item in the `initialRouteStack`.
*/
initialRoute: PropTypes.object,
/**
* Provide a set of routes to initially mount. Required if no initialRoute
* is provided. Otherwise, it will default to an array containing only the
* `initialRoute`
*/
initialRouteStack: PropTypes.arrayOf(PropTypes.object),
/**
* Will emit the target route upon mounting and before each nav transition
*/
onWillFocus: PropTypes.func,
/**
* Will be called with the new route of each scene after the transition is
* complete or after the initial mounting
*/
onDidFocus: PropTypes.func,
/**
* Optionally provide a navigation bar that persists across scene
* transitions
*/
navigationBar: PropTypes.node,
/**
* Optionally provide the navigator object from a parent Navigator
*/
navigator: PropTypes.object,
/**
* Styles to apply to the container of each scene
*/
sceneStyle: View.propTypes.style,
},
statics: {
BreadcrumbNavigationBar: createMockComponent('NavigatorBreadcrumbNavigationBar'),
NavigationBar: createMockComponent('NavigatorNavigationBar'),
SceneConfigs: NavigatorSceneConfigs,
},
render() {
return null;
}
});
module.exports = Navigator;