UNPKG

4.08 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 detachInactiveScreens?: boolean;
73};
74
75export type NavigationDrawerRouterConfig = {
76 unmountInactiveRoutes?: boolean;
77 resetOnBlur?: boolean;
78 initialRouteName?: string;
79 contentComponent?: React.ComponentType<DrawerContentComponentProps>;
80 contentOptions?: object;
81 backBehavior?: 'none' | 'initialRoute' | 'history';
82};
83
84export type ThemedColor =
85 | string
86 | {
87 light: string;
88 dark: string;
89 };
90
91export type DrawerNavigatorItemsProps = {
92 items: NavigationRoute[];
93 activeItemKey?: string | null;
94 activeTintColor?: string | ThemedColor;
95 activeBackgroundColor?: string | ThemedColor;
96 inactiveTintColor?: string | ThemedColor;
97 inactiveBackgroundColor?: string | ThemedColor;
98 getLabel: (scene: Scene) => React.ReactNode;
99 renderIcon: (scene: Scene) => React.ReactNode;
100 onItemPress: (scene: { route: NavigationRoute; focused: boolean }) => void;
101 itemsContainerStyle?: StyleProp<ViewStyle>;
102 itemStyle?: StyleProp<ViewStyle>;
103 labelStyle?: StyleProp<TextStyle>;
104 activeLabelStyle?: StyleProp<TextStyle>;
105 inactiveLabelStyle?: StyleProp<TextStyle>;
106 iconContainerStyle?: StyleProp<ViewStyle>;
107 drawerPosition: 'left' | 'right';
108 screenProps: unknown;
109};
110
111export type DrawerContentComponentProps = DrawerNavigatorItemsProps & {
112 navigation: NavigationScreenProp<NavigationDrawerState>;
113 descriptors: SceneDescriptorMap;
114 drawerOpenProgress: Animated.Node<number>;
115 screenProps: unknown;
116};
117
118export type NavigationDrawerScreenProps<
119 Params = NavigationParams,
120 ScreenProps = unknown
121> = {
122 theme: SupportedThemes;
123 navigation: NavigationDrawerProp<NavigationRoute, Params>;
124 screenProps: ScreenProps;
125};
126
127export type NavigationDrawerScreenComponent<
128 Params = NavigationParams,
129 ScreenProps = unknown
130> = React.ComponentType<NavigationDrawerScreenProps<Params, ScreenProps>> & {
131 navigationOptions?: NavigationScreenConfig<
132 NavigationDrawerOptions,
133 NavigationDrawerProp<NavigationRoute, Params>,
134 ScreenProps
135 >;
136};
137
138export type SceneDescriptorMap = {
139 [key: string]: NavigationDescriptor<
140 NavigationParams,
141 NavigationDrawerOptions,
142 NavigationDrawerProp<NavigationRoute, any>
143 >;
144};