|
1 | | -import { NavigationAction } from 'react-navigation'; |
2 | | - |
3 | | -export type Route = { |
4 | | - key: string; |
5 | | - routeName: string; |
6 | | -}; |
| 1 | +import { |
| 2 | + NavigationScreenProp, |
| 3 | + NavigationState, |
| 4 | + NavigationRoute, |
| 5 | + NavigationParams, |
| 6 | + NavigationProp, |
| 7 | + NavigationDescriptor, |
| 8 | +} from 'react-navigation'; |
| 9 | +import { StyleProp, ViewStyle, TextStyle } from 'react-native'; |
| 10 | +import Animated from 'react-native-reanimated'; |
7 | 11 |
|
8 | 12 | export type Scene = { |
9 | | - route: Route; |
| 13 | + route: NavigationRoute; |
10 | 14 | index: number; |
11 | 15 | focused: boolean; |
12 | 16 | tintColor?: string; |
13 | 17 | }; |
14 | 18 |
|
15 | | -export type Navigation = { |
16 | | - state: { |
17 | | - key: string; |
18 | | - index: number; |
19 | | - routes: Route[]; |
20 | | - isDrawerOpen: boolean; |
21 | | - }; |
| 19 | +export type NavigationDrawerState = NavigationState & { |
| 20 | + isDrawerOpen: boolean; |
| 21 | +}; |
| 22 | + |
| 23 | +export type NavigationDrawerProp< |
| 24 | + State = NavigationRoute, |
| 25 | + Params = NavigationParams |
| 26 | +> = NavigationScreenProp<State, Params> & { |
22 | 27 | openDrawer: () => void; |
23 | 28 | closeDrawer: () => void; |
24 | | - dispatch: (action: NavigationAction) => boolean; |
| 29 | + toggleDrawer: () => void; |
| 30 | + jumpTo: (routeName: string, key?: string) => void; |
| 31 | +}; |
| 32 | + |
| 33 | +export type NavigationDrawerOptions = { |
| 34 | + title?: string; |
| 35 | + drawerLabel?: |
| 36 | + | React.ReactNode |
| 37 | + | ((props: { tintColor?: string; focused: boolean }) => React.ReactNode); |
| 38 | + drawerIcon?: |
| 39 | + | React.ReactNode |
| 40 | + | ((props: { tintColor?: string; focused: boolean }) => React.ReactNode); |
| 41 | + drawerLockMode?: 'locked-closed' | 'locked-open'; |
| 42 | +}; |
| 43 | + |
| 44 | +export type NavigationDrawerConfig = { |
| 45 | + drawerWidth?: number | (() => number); |
| 46 | + contentComponent?: React.ComponentType<ContentComponentProps>; |
| 47 | + drawerPosition?: 'left' | 'right'; |
| 48 | + drawerType?: 'front' | 'back' | 'slide'; |
| 49 | + keyboardDismissMode?: 'none' | 'on-drag'; |
| 50 | + swipeEdgeWidth?: number; |
| 51 | + swipeDistanceThreshold?: number; |
| 52 | + swipeVelocityThreshold?: number; |
| 53 | + hideStatusBar?: boolean; |
| 54 | + statusBarAnimation?: 'slide' | 'none' | 'fade'; |
| 55 | + drawerBackgroundColor?: ThemedColor; |
| 56 | + overlayColor?: ThemedColor; |
| 57 | +}; |
| 58 | + |
| 59 | +export type NavigationDrawerRouterConfig = { |
| 60 | + unmountInactiveRoutes?: boolean; |
| 61 | + resetOnBlur?: boolean; |
| 62 | + initialRouteName?: string; |
| 63 | + contentComponent?: React.ComponentType<ContentComponentProps>; |
| 64 | + contentOptions?: object; |
| 65 | +}; |
| 66 | + |
| 67 | +export type ThemedColor = { |
| 68 | + light: string; |
| 69 | + dark: string; |
| 70 | +}; |
| 71 | + |
| 72 | +export type DrawerNavigatorItemsProps = { |
| 73 | + items: NavigationRoute[]; |
| 74 | + activeItemKey?: string | null; |
| 75 | + activeTintColor?: string | ThemedColor; |
| 76 | + activeBackgroundColor?: string | ThemedColor; |
| 77 | + inactiveTintColor?: string | ThemedColor; |
| 78 | + inactiveBackgroundColor?: string | ThemedColor; |
| 79 | + getLabel: (scene: Scene) => React.ReactNode; |
| 80 | + renderIcon: (scene: Scene) => React.ReactNode; |
| 81 | + onItemPress: (scene: { route: NavigationRoute; focused: boolean }) => void; |
| 82 | + itemsContainerStyle?: StyleProp<ViewStyle>; |
| 83 | + itemStyle?: StyleProp<ViewStyle>; |
| 84 | + labelStyle?: StyleProp<TextStyle>; |
| 85 | + activeLabelStyle?: StyleProp<TextStyle>; |
| 86 | + inactiveLabelStyle?: StyleProp<TextStyle>; |
| 87 | + iconContainerStyle?: StyleProp<ViewStyle>; |
| 88 | + drawerPosition: 'left' | 'right'; |
| 89 | +}; |
| 90 | + |
| 91 | +export type ContentComponentProps = DrawerNavigatorItemsProps & { |
| 92 | + navigation: NavigationProp<NavigationDrawerState>; |
| 93 | + descriptors: { [key: string]: any }; |
| 94 | + drawerOpenProgress: Animated.Node<number>; |
| 95 | + screenProps: unknown; |
| 96 | +}; |
| 97 | + |
| 98 | +export type SceneDescriptorMap = { |
| 99 | + [key: string]: NavigationDescriptor< |
| 100 | + NavigationParams, |
| 101 | + NavigationDrawerOptions, |
| 102 | + NavigationDrawerProp |
| 103 | + >; |
25 | 104 | }; |
0 commit comments