1 | import {
|
2 | NavigationScreenProp,
|
3 | NavigationState,
|
4 | NavigationRoute,
|
5 | NavigationParams,
|
6 | NavigationDescriptor,
|
7 | SupportedThemes,
|
8 | NavigationScreenConfig,
|
9 | } from 'react-navigation';
|
10 | import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
11 | import Animated from 'react-native-reanimated';
|
12 |
|
13 | export type Scene = {
|
14 | route: NavigationRoute;
|
15 | index: number;
|
16 | focused: boolean;
|
17 | tintColor?: string;
|
18 | };
|
19 |
|
20 | export type NavigationDrawerState = NavigationState & {
|
21 | isDrawerOpen: boolean;
|
22 | };
|
23 |
|
24 | export type NavigationDrawerProp<
|
25 | State = NavigationRoute,
|
26 | Params = NavigationParams
|
27 | > = NavigationScreenProp<State, Params> & {
|
28 | openDrawer: () => void;
|
29 | closeDrawer: () => void;
|
30 | toggleDrawer: () => void;
|
31 | jumpTo: (routeName: string, key?: string) => void;
|
32 | };
|
33 |
|
34 | export type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';
|
35 |
|
36 | export type DrawerIconProps = {
|
37 | tintColor?: string;
|
38 | focused: boolean;
|
39 | };
|
40 |
|
41 | export type DrawerLabelProps = {
|
42 | tintColor?: string;
|
43 | focused: boolean;
|
44 | };
|
45 |
|
46 | export type NavigationDrawerOptions = {
|
47 | title?: string;
|
48 | drawerLabel?:
|
49 | | React.ReactNode
|
50 | | ((props: DrawerLabelProps) => React.ReactNode);
|
51 | drawerIcon?: React.ReactNode | ((props: DrawerIconProps) => React.ReactNode);
|
52 | drawerLockMode?: DrawerLockMode;
|
53 | };
|
54 |
|
55 | export type NavigationDrawerConfig = {
|
56 | contentComponent?: React.ComponentType<DrawerContentComponentProps>;
|
57 | edgeWidth?: number;
|
58 | minSwipeDistance?: number;
|
59 | drawerWidth?: number | (() => number);
|
60 | drawerPosition?: 'left' | 'right';
|
61 | drawerType?: 'front' | 'back' | 'slide';
|
62 | drawerLockMode?: DrawerLockMode;
|
63 | keyboardDismissMode?: 'none' | 'on-drag';
|
64 | swipeEdgeWidth?: number;
|
65 | swipeDistanceThreshold?: number;
|
66 | swipeVelocityThreshold?: number;
|
67 | hideStatusBar?: boolean;
|
68 | statusBarAnimation?: 'slide' | 'none' | 'fade';
|
69 | drawerBackgroundColor?: ThemedColor;
|
70 | overlayColor?: ThemedColor;
|
71 | screenContainerStyle?: StyleProp<ViewStyle>;
|
72 | };
|
73 |
|
74 | export type NavigationDrawerRouterConfig = {
|
75 | unmountInactiveRoutes?: boolean;
|
76 | resetOnBlur?: boolean;
|
77 | initialRouteName?: string;
|
78 | contentComponent?: React.ComponentType<DrawerContentComponentProps>;
|
79 | contentOptions?: object;
|
80 | backBehavior?: 'none' | 'initialRoute' | 'history';
|
81 | };
|
82 |
|
83 | export type ThemedColor =
|
84 | | string
|
85 | | {
|
86 | light: string;
|
87 | dark: string;
|
88 | };
|
89 |
|
90 | export type DrawerNavigatorItemsProps = {
|
91 | items: NavigationRoute[];
|
92 | activeItemKey?: string | null;
|
93 | activeTintColor?: string | ThemedColor;
|
94 | activeBackgroundColor?: string | ThemedColor;
|
95 | inactiveTintColor?: string | ThemedColor;
|
96 | inactiveBackgroundColor?: string | ThemedColor;
|
97 | getLabel: (scene: Scene) => React.ReactNode;
|
98 | renderIcon: (scene: Scene) => React.ReactNode;
|
99 | onItemPress: (scene: { route: NavigationRoute; focused: boolean }) => void;
|
100 | itemsContainerStyle?: StyleProp<ViewStyle>;
|
101 | itemStyle?: StyleProp<ViewStyle>;
|
102 | labelStyle?: StyleProp<TextStyle>;
|
103 | activeLabelStyle?: StyleProp<TextStyle>;
|
104 | inactiveLabelStyle?: StyleProp<TextStyle>;
|
105 | iconContainerStyle?: StyleProp<ViewStyle>;
|
106 | drawerPosition: 'left' | 'right';
|
107 | screenProps: unknown;
|
108 | };
|
109 |
|
110 | export type DrawerContentComponentProps = DrawerNavigatorItemsProps & {
|
111 | navigation: NavigationScreenProp<NavigationDrawerState>;
|
112 | descriptors: SceneDescriptorMap;
|
113 | drawerOpenProgress: Animated.Node<number>;
|
114 | screenProps: unknown;
|
115 | };
|
116 |
|
117 | export type NavigationDrawerScreenProps<
|
118 | Params = NavigationParams,
|
119 | ScreenProps = unknown
|
120 | > = {
|
121 | theme: SupportedThemes;
|
122 | navigation: NavigationDrawerProp<NavigationRoute, Params>;
|
123 | screenProps: ScreenProps;
|
124 | };
|
125 |
|
126 | export type NavigationDrawerScreenComponent<
|
127 | Params = NavigationParams,
|
128 | ScreenProps = unknown
|
129 | > = React.ComponentType<NavigationDrawerScreenProps<Params, ScreenProps>> & {
|
130 | navigationOptions?: NavigationScreenConfig<
|
131 | NavigationDrawerOptions,
|
132 | NavigationDrawerProp<NavigationRoute, Params>,
|
133 | ScreenProps
|
134 | >;
|
135 | };
|
136 |
|
137 | export type SceneDescriptorMap = {
|
138 | [key: string]: NavigationDescriptor<
|
139 | NavigationParams,
|
140 | NavigationDrawerOptions,
|
141 | NavigationDrawerProp<NavigationRoute, any>
|
142 | >;
|
143 | };
|