UNPKG

4.05 kBTypeScriptView Raw
1import {
2 NavigationScreenProp,
3 NavigationState,
4 NavigationRoute,
5 NavigationParams,
6 NavigationDescriptor,
7 SupportedThemes,
8 NavigationScreenConfig,
9} from 'react-navigation';
10import { StyleProp, ViewStyle, TextStyle } from 'react-native';
11import Animated from 'react-native-reanimated';
12
13export type Scene = {
14 route: NavigationRoute;
15 index: number;
16 focused: boolean;
17 tintColor?: string;
18};
19
20export type NavigationDrawerState = NavigationState & {
21 isDrawerOpen: boolean;
22};
23
24export 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
34export type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';
35
36export type DrawerIconProps = {
37 tintColor?: string;
38 focused: boolean;
39};
40
41export type DrawerLabelProps = {
42 tintColor?: string;
43 focused: boolean;
44};
45
46export 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
55export 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
74export 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
83export type ThemedColor =
84 | string
85 | {
86 light: string;
87 dark: string;
88 };
89
90export 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
110export type DrawerContentComponentProps = DrawerNavigatorItemsProps & {
111 navigation: NavigationScreenProp<NavigationDrawerState>;
112 descriptors: SceneDescriptorMap;
113 drawerOpenProgress: Animated.Node<number>;
114 screenProps: unknown;
115};
116
117export type NavigationDrawerScreenProps<
118 Params = NavigationParams,
119 ScreenProps = unknown
120> = {
121 theme: SupportedThemes;
122 navigation: NavigationDrawerProp<NavigationRoute, Params>;
123 screenProps: ScreenProps;
124};
125
126export 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
137export type SceneDescriptorMap = {
138 [key: string]: NavigationDescriptor<
139 NavigationParams,
140 NavigationDrawerOptions,
141 NavigationDrawerProp<NavigationRoute, any>
142 >;
143};