@@ -8,41 +8,21 @@ import {
88} from 'react-native' ;
99import SafeAreaView from 'react-native-safe-area-view' ;
1010import Animated from 'react-native-reanimated' ;
11-
12- export type Route = {
13- key : string ;
14- routeName : string ;
15- } & ( NavigationState | undefined ) ;
16-
17- export type NavigationEventName =
18- | 'willFocus'
19- | 'didFocus'
20- | 'willBlur'
21- | 'didBlur' ;
22-
23- export type NavigationState = {
24- key : string ;
25- index : number ;
26- routes : Route [ ] ;
27- isTransitioning ?: boolean ;
28- params ?: { [ key : string ] : unknown } ;
29- } ;
30-
31- export type NavigationProp < RouteName = string , Params = object > = {
32- emit ( eventName : string ) : void ;
33- navigate ( routeName : RouteName ) : void ;
34- goBack ( ) : void ;
35- goBack ( key : string | null ) : void ;
36- addListener : (
37- event : NavigationEventName ,
38- callback : ( ) => void
39- ) => { remove : ( ) => void } ;
40- isFocused ( ) : boolean ;
41- state : NavigationState ;
42- setParams ( params : Params ) : void ;
43- getParam ( ) : Params ;
44- dispatch ( action : { type : string } ) : boolean ;
45- dangerouslyGetParent ( ) : NavigationProp | undefined ;
11+ import {
12+ NavigationRoute ,
13+ NavigationState ,
14+ NavigationScreenProp ,
15+ NavigationParams ,
16+ NavigationDescriptor ,
17+ } from 'react-navigation' ;
18+
19+ export type NavigationTabState = NavigationState ;
20+
21+ export type NavigationTabProp <
22+ State = NavigationRoute ,
23+ Params = NavigationParams
24+ > = NavigationScreenProp < State , Params > & {
25+ jumpTo ( routeName : string , key ?: string ) : void ;
4626} ;
4727
4828export type ThemedColor =
@@ -75,22 +55,24 @@ export type BottomTabBarOptions = {
7555} ;
7656
7757export type BottomTabBarProps = BottomTabBarOptions & {
78- navigation : NavigationProp ;
79- onTabPress : ( props : { route : Route } ) => void ;
80- onTabLongPress : ( props : { route : Route } ) => void ;
81- getAccessibilityLabel : ( props : { route : Route } ) => string | undefined ;
58+ navigation : NavigationTabProp ;
59+ onTabPress : ( props : { route : NavigationRoute } ) => void ;
60+ onTabLongPress : ( props : { route : NavigationRoute } ) => void ;
61+ getAccessibilityLabel : ( props : {
62+ route : NavigationRoute ;
63+ } ) => string | undefined ;
8264 getAccessibilityRole : ( props : {
83- route : Route ;
65+ route : NavigationRoute ;
8466 } ) => AccessibilityRole | undefined ;
8567 getAccessibilityStates : ( props : {
86- route : Route ;
68+ route : NavigationRoute ;
8769 focused : boolean ;
8870 } ) => AccessibilityState [ ] ;
8971 getButtonComponent : ( props : {
90- route : Route ;
72+ route : NavigationRoute ;
9173 } ) => React . ComponentType < any > | undefined ;
9274 getLabelText : ( props : {
93- route : Route ;
75+ route : NavigationRoute ;
9476 } ) =>
9577 | ( ( scene : {
9678 focused : boolean ;
@@ -99,9 +81,9 @@ export type BottomTabBarProps = BottomTabBarOptions & {
9981 } ) => string | undefined )
10082 | string
10183 | undefined ;
102- getTestID : ( props : { route : Route } ) => string | undefined ;
84+ getTestID : ( props : { route : NavigationRoute } ) => string | undefined ;
10385 renderIcon : ( props : {
104- route : Route ;
86+ route : NavigationRoute ;
10587 focused : boolean ;
10688 tintColor ?: string ;
10789 horizontal ?: boolean ;
@@ -140,26 +122,28 @@ export type MaterialTabBarProps = MaterialTabBarOptions & {
140122 position : Animated . Node < number > ;
141123 jumpTo : ( key : string ) => void ;
142124 getLabelText : ( scene : {
143- route : Route ;
125+ route : NavigationRoute ;
144126 } ) =>
145127 | ( ( scene : { focused : boolean ; tintColor : string } ) => string | undefined )
146128 | string
147129 | undefined ;
148- getAccessible ?: ( scene : { route : Route } ) => boolean | undefined ;
149- getAccessibilityLabel : ( scene : { route : Route } ) => string | undefined ;
150- getTestID : ( scene : { route : Route } ) => string | undefined ;
130+ getAccessible ?: ( scene : { route : NavigationRoute } ) => boolean | undefined ;
131+ getAccessibilityLabel : ( scene : {
132+ route : NavigationRoute ;
133+ } ) => string | undefined ;
134+ getTestID : ( scene : { route : NavigationRoute } ) => string | undefined ;
151135 renderIcon : ( scene : {
152- route : Route ;
136+ route : NavigationRoute ;
153137 focused : boolean ;
154138 tintColor : string ;
155139 horizontal ?: boolean ;
156140 } ) => React . ReactNode ;
157- renderBadge ?: ( scene : { route : Route } ) => React . ReactNode ;
158- onTabPress ?: ( scene : { route : Route } ) => void ;
159- onTabLongPress ?: ( scene : { route : Route } ) => void ;
141+ renderBadge ?: ( scene : { route : NavigationRoute } ) => React . ReactNode ;
142+ onTabPress ?: ( scene : { route : NavigationRoute } ) => void ;
143+ onTabLongPress ?: ( scene : { route : NavigationRoute } ) => void ;
160144 tabBarPosition ?: 'top' | 'bottom' ;
161145 screenProps : unknown ;
162- navigation : NavigationProp ;
146+ navigation : NavigationTabProp ;
163147} ;
164148
165149export type NavigationCommonTabOptions = {
@@ -176,11 +160,11 @@ export type NavigationCommonTabOptions = {
176160 horizontal ?: boolean ;
177161 } ) => React . ReactNode ) ;
178162 tabBarOnPress ?: ( props : {
179- navigation : NavigationProp ;
163+ navigation : NavigationTabProp ;
180164 defaultHandler : ( ) => void ;
181165 } ) => void ;
182166 tabBarOnLongPress ?: ( props : {
183- navigation : NavigationProp ;
167+ navigation : NavigationTabProp ;
184168 defaultHandler : ( ) => void ;
185169 } ) => void ;
186170} ;
@@ -194,17 +178,10 @@ export type NavigationMaterialTabOptions = NavigationCommonTabOptions & {
194178 swipeEnabled ?: boolean | ( ( state : NavigationState ) => boolean ) ;
195179} ;
196180
197- export type SceneDescriptor < Options extends NavigationCommonTabOptions > = {
198- key : string ;
199- options : Options ;
200- navigation : NavigationProp ;
201- getComponent ( ) : React . ComponentType ;
202- } ;
203-
204- export type Screen <
205- Options extends NavigationCommonTabOptions
206- > = React . ComponentType < any > & {
207- navigationOptions ?: Options & {
208- [ key : string ] : any ;
209- } ;
181+ export type SceneDescriptorMap = {
182+ [ key : string ] : NavigationDescriptor <
183+ NavigationParams ,
184+ NavigationBottomTabOptions | NavigationMaterialTabOptions ,
185+ NavigationTabProp
186+ > ;
210187} ;
0 commit comments