@@ -21,22 +21,72 @@ export type AnimatedTextStyleProp = $PropertyType<
21
21
'style'
22
22
> ;
23
23
24
- export type HeaderMode = 'float' | 'screen' | 'none' ;
24
+ /**
25
+ * Navigation State + Action
26
+ */
25
27
26
- export type HeaderProps = {
27
- ...$Exact < NavigationSceneRendererProps > ,
28
- mode : HeaderMode ,
29
- router : NavigationRouter <
30
- NavigationState ,
31
- NavigationAction,
32
- NavigationStackScreenOptions
33
- > ,
34
- getScreenDetails : NavigationScene => NavigationScreenDetails <
35
- NavigationStackScreenOptions
36
- > ,
37
- style : ViewStyleProp ,
28
+ export type NavigationParams = {
29
+ [ key : string ] : mixed ,
30
+ } ;
31
+
32
+ export type NavigationNavigateAction = {
33
+ type : 'Navigation/NAVIGATE' ,
34
+ routeName : string ,
35
+ params ?: NavigationParams ,
36
+
37
+ // The action to run inside the sub-router
38
+ action ?: NavigationNavigateAction ,
39
+ } ;
40
+
41
+ export type NavigationBackAction = {
42
+ type : 'Navigation/BACK' ,
43
+ key ?: ?string ,
44
+ } ;
45
+
46
+ export type NavigationSetParamsAction = {
47
+ type : 'Navigation/SET_PARAMS' ,
48
+
49
+ // The key of the route where the params should be set
50
+ key : string ,
51
+
52
+ // The new params to merge into the existing route params
53
+ params ?: NavigationParams ,
54
+ } ;
55
+
56
+ export type NavigationInitAction = {
57
+ type : 'Navigation/INIT' ,
58
+ params ?: NavigationParams ,
59
+ } ;
60
+
61
+ export type NavigationResetAction = {
62
+ type : 'Navigation/RESET' ,
63
+ index : number ,
64
+ key ?: ?string ,
65
+ actions : Array < NavigationNavigateAction > ,
38
66
} ;
39
67
68
+ export type NavigationUriAction = {
69
+ type : 'Navigation/URI' ,
70
+ uri : string ,
71
+ } ;
72
+
73
+ export type NavigationStackAction =
74
+ | NavigationInitAction
75
+ | NavigationNavigateAction
76
+ | NavigationBackAction
77
+ | NavigationSetParamsAction
78
+ | NavigationResetAction ;
79
+
80
+ export type NavigationTabAction =
81
+ | NavigationInitAction
82
+ | NavigationNavigateAction
83
+ | NavigationBackAction ;
84
+
85
+ export type NavigationAction =
86
+ | NavigationInitAction
87
+ | NavigationStackAction
88
+ | NavigationTabAction ;
89
+
40
90
/**
41
91
* NavigationState is a tree of routes for a single navigator, where each child
42
92
* route may either be a NavigationScreenRoute or a NavigationRouterRoute.
@@ -88,6 +138,10 @@ export type NavigationStateRoute = {
88
138
routes : Array < NavigationRoute > ,
89
139
} ;
90
140
141
+ /**
142
+ * Router
143
+ */
144
+
91
145
export type NavigationScreenOptionsGetter < Options , Action > = (
92
146
navigation : NavigationScreenProp < NavigationRoute , Action > ,
93
147
screenProps ? : { }
@@ -132,13 +186,6 @@ export type NavigationRouter<State, Action, Options> = {
132
186
getScreenOptions : NavigationScreenOptionsGetter < Options , Action > ,
133
187
} ;
134
188
135
- export type NavigationScreenOption < T > =
136
- | T
137
- | ( (
138
- navigation : NavigationScreenProp < NavigationRoute , NavigationAction > ,
139
- config : T
140
- ) => T ) ;
141
-
142
189
export type NavigationScreenDetails < T > = {
143
190
options : T ,
144
191
state : NavigationRoute ,
@@ -151,18 +198,18 @@ export type NavigationScreenOptions = {
151
198
152
199
export type NavigationScreenConfigProps = {
153
200
navigation : NavigationScreenProp < NavigationRoute , NavigationAction> ,
154
- screenProps : Object ,
201
+ screenProps : { } ,
155
202
} ;
156
203
157
204
export type NavigationScreenConfig < Options > =
158
205
| Options
159
- | ( NavigationScreenConfigProps &
160
- ( ( {
161
- navigationOptions : NavigationScreenProp <
162
- NavigationRoute ,
163
- NavigationAction
164
- > ,
165
- } ) => Options ) ) ;
206
+ | ( ( {
207
+ ... $Exact < NavigationScreenConfigProps > ,
208
+ navigationOptions : NavigationScreenProp <
209
+ NavigationRoute ,
210
+ NavigationAction
211
+ > ,
212
+ } ) => Options ) ;
166
213
167
214
export type NavigationComponent =
168
215
| NavigationScreenComponent < * , * >
@@ -177,59 +224,51 @@ export type NavigationNavigator<T, State, Action, Options> = ReactClass<T> & {
177
224
navigationOptions ?: NavigationScreenConfig < Options > ,
178
225
} ;
179
226
180
- export type NavigationParams = {
181
- [ key : string ] : mixed ,
227
+ export type NavigationRouteConfig < T : { } > = {
228
+ ...$Exact < T > ,
229
+ navigationOptions ?: NavigationScreenConfig < * > ,
230
+ path ?: string ,
182
231
} ;
183
232
184
- export type NavigationNavigateAction = {
185
- type : 'Navigation/NAVIGATE' ,
186
- routeName : string ,
187
- params ?: NavigationParams ,
188
-
189
- // The action to run inside the sub-router
190
- action ?: NavigationNavigateAction ,
191
- } ;
233
+ export type NavigationScreenRouteConfig =
234
+ | {
235
+ screen : NavigationComponent ,
236
+ }
237
+ | {
238
+ getScreen : ( ) => NavigationComponent ,
239
+ } ;
192
240
193
- export type NavigationBackAction = {
194
- type : 'Navigation/BACK' ,
195
- key ?: ?string ,
241
+ export type NavigationPathsConfig = {
242
+ [ routeName : string ] : string ,
196
243
} ;
197
244
198
- export type NavigationSetParamsAction = {
199
- type : 'Navigation/SET_PARAMS' ,
200
-
201
- // The key of the route where the params should be set
202
- key : string ,
203
-
204
- // The new params to merge into the existing route params
205
- params ?: NavigationParams ,
245
+ export type NavigationRouteConfigMap = {
246
+ [ routeName : string ] : NavigationRouteConfig < * > ,
206
247
} ;
207
248
208
- export type NavigationInitAction = {
209
- type : 'Navigation/INIT' ,
210
- params ?: NavigationParams ,
211
- } ;
249
+ /**
250
+ * Header
251
+ */
212
252
213
- export type NavigationResetAction = {
214
- type : 'Navigation/RESET' ,
215
- index : number ,
216
- key ?: ?string ,
217
- actions : Array < NavigationNavigateAction > ,
218
- } ;
253
+ export type HeaderMode = 'float' | 'screen' | 'none' ;
219
254
220
- export type NavigationUriAction = {
221
- type : 'Navigation/URI' ,
222
- uri : string ,
255
+ export type HeaderProps = {
256
+ ...$Exact < NavigationSceneRendererProps > ,
257
+ mode : HeaderMode ,
258
+ router : NavigationRouter <
259
+ NavigationState ,
260
+ NavigationAction,
261
+ NavigationStackScreenOptions
262
+ > ,
263
+ getScreenDetails : NavigationScene => NavigationScreenDetails <
264
+ NavigationStackScreenOptions
265
+ > ,
266
+ style : ViewStyleProp ,
223
267
} ;
224
268
225
- export type NavigationStackViewConfig = {
226
- mode ?: 'card' | 'modal' ,
227
- headerMode ?: HeaderMode ,
228
- cardStyle ?: ViewStyleProp ,
229
- transitionConfig ?: ( ) => TransitionConfig ,
230
- onTransitionStart ?: ( ) => void ,
231
- onTransitionEnd ?: ( ) => void ,
232
- } ;
269
+ /**
270
+ * Stack Navigator
271
+ */
233
272
234
273
export type NavigationStackScreenOptions = {
235
274
...$Exact < NavigationScreenOptions > ,
@@ -254,40 +293,24 @@ export type NavigationStackRouterConfig = {
254
293
navigationOptions ?: NavigationScreenConfig < NavigationStackScreenOptions > ,
255
294
} ;
256
295
257
- export type NavigationStackAction =
258
- | NavigationInitAction
259
- | NavigationNavigateAction
260
- | NavigationBackAction
261
- | NavigationSetParamsAction
262
- | NavigationResetAction ;
263
-
264
- export type NavigationTabAction =
265
- | NavigationInitAction
266
- | NavigationNavigateAction
267
- | NavigationBackAction ;
268
-
269
- export type NavigationAction =
270
- | NavigationInitAction
271
- | NavigationStackAction
272
- | NavigationTabAction ;
273
-
274
- export type NavigationRouteConfig < T > = T & {
275
- navigationOptions ?: NavigationScreenConfig < * > ,
276
- path ?: string ,
296
+ export type NavigationStackViewConfig = {
297
+ mode ?: 'card' | 'modal' ,
298
+ headerMode ?: HeaderMode ,
299
+ cardStyle ?: ViewStyleProp ,
300
+ transitionConfig ?: ( ) => TransitionConfig ,
301
+ onTransitionStart ?: ( ) => void ,
302
+ onTransitionEnd ?: ( ) => void ,
277
303
} ;
278
304
279
- export type NavigationScreenRouteConfig =
280
- | {
281
- screen : NavigationComponent ,
282
- }
283
- | {
284
- getScreen : ( ) => NavigationComponent ,
285
- } ;
286
-
287
- export type NavigationPathsConfig = {
288
- [ routeName : string ] : string ,
305
+ export type StackNavigatorConfig = {
306
+ ...$Exact < NavigationStackViewConfig > ,
307
+ ...$Exact < NavigationStackRouterConfig > ,
289
308
} ;
290
309
310
+ /**
311
+ * Tab Navigator
312
+ */
313
+
291
314
export type NavigationTabRouterConfig = {
292
315
initialRouteName ?: string ,
293
316
paths ?: NavigationPathsConfig ,
@@ -298,7 +321,8 @@ export type NavigationTabRouterConfig = {
298
321
backBehavior ?: 'none' | 'initialRoute' , // defaults `initialRoute`
299
322
} ;
300
323
301
- export type NavigationTabScreenOptions = NavigationScreenOptions & {
324
+ export type NavigationTabScreenOptions = {
325
+ ...$Exact < NavigationScreenOptions > ,
302
326
tabBarIcon ?:
303
327
| React . Element < * >
304
328
| ( ( options : { tintColor : ?string , focused : boolean } ) => ?React . Element <
@@ -313,7 +337,12 @@ export type NavigationTabScreenOptions = NavigationScreenOptions & {
313
337
tabBarVisible ?: boolean ,
314
338
} ;
315
339
316
- export type NavigationDrawerScreenOptions = NavigationScreenOptions & {
340
+ /**
341
+ * Drawer
342
+ */
343
+
344
+ export type NavigationDrawerScreenOptions = {
345
+ ...$Exact < NavigationScreenOptions > ,
317
346
drawerIcon ?:
318
347
| React . Element < * >
319
348
| ( ( options : { tintColor : ?string , focused : boolean } ) => ?React . Element <
@@ -326,9 +355,9 @@ export type NavigationDrawerScreenOptions = NavigationScreenOptions & {
326
355
> ) ,
327
356
} ;
328
357
329
- export type NavigationRouteConfigMap = {
330
- [ routeName : string ] : NavigationRouteConfig < * > ,
331
- } ;
358
+ /**
359
+ * Navigator Prop
360
+ */
332
361
333
362
export type NavigationDispatch < A > = ( action : A ) => boolean ;
334
363
@@ -349,10 +378,10 @@ export type NavigationScreenProp<S, A> = {
349
378
setParams : ( newParams : NavigationParams ) => boolean ,
350
379
} ;
351
380
352
- export type NavigationNavigatorProps < T > = {
353
- navigation : NavigationProp < T , NavigationAction> ,
381
+ export type NavigationNavigatorProps < O , S > = {
382
+ navigation : NavigationProp < S , NavigationAction> ,
354
383
screenProps : * ,
355
- navigationOptions : * ,
384
+ navigationOptions : O ,
356
385
} ;
357
386
358
387
/**
@@ -429,7 +458,7 @@ export type TransitionConfig = {
429
458
transitionSpec ?: NavigationTransitionSpec ,
430
459
// How to animate position and opacity of the screen
431
460
// based on the value generated by the transitionSpec
432
- screenInterpolator ?: ( props : NavigationSceneRendererProps ) => Object ,
461
+ screenInterpolator ?: ( props : NavigationSceneRendererProps ) => { } ,
433
462
// The style of the container. Useful when a scene doesn't have
434
463
// 100% opacity and the underlying container is visible.
435
464
containerStyle ?: $PropertyType < ViewProps , 'style' > ,
0 commit comments