UNPKG

6.15 kBTypeScriptView Raw
1/// <reference types="react" />
2import { NavigationScreenProp, NavigationState, NavigationRoute, NavigationParams, NavigationDescriptor, SupportedThemes, NavigationScreenConfig } from 'react-navigation';
3import { StyleProp, ViewStyle, TextStyle } from 'react-native';
4import Animated from 'react-native-reanimated';
5export declare type Scene = {
6 route: NavigationRoute;
7 index: number;
8 focused: boolean;
9 tintColor?: string;
10};
11export declare type NavigationDrawerState = NavigationState & {
12 isDrawerOpen: boolean;
13};
14export declare type NavigationDrawerProp<State = NavigationRoute, Params = NavigationParams> = NavigationScreenProp<State, Params> & {
15 openDrawer: () => void;
16 closeDrawer: () => void;
17 toggleDrawer: () => void;
18 jumpTo: (routeName: string, key?: string) => void;
19};
20export declare type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';
21export declare type DrawerIconProps = {
22 tintColor?: string;
23 focused: boolean;
24};
25export declare type DrawerLabelProps = {
26 tintColor?: string;
27 focused: boolean;
28};
29export declare type NavigationDrawerOptions = {
30 title?: string;
31 drawerLabel?: React.ReactNode | ((props: DrawerLabelProps) => React.ReactNode);
32 drawerIcon?: React.ReactNode | ((props: DrawerIconProps) => React.ReactNode);
33 drawerLockMode?: DrawerLockMode;
34};
35export declare type NavigationDrawerConfig = {
36 contentComponent?: React.ComponentType<DrawerContentComponentProps>;
37 edgeWidth?: number;
38 minSwipeDistance?: number;
39 drawerWidth?: number | (() => number);
40 drawerPosition?: 'left' | 'right';
41 drawerType?: 'front' | 'back' | 'slide';
42 drawerLockMode?: DrawerLockMode;
43 keyboardDismissMode?: 'none' | 'on-drag';
44 swipeEdgeWidth?: number;
45 swipeDistanceThreshold?: number;
46 swipeVelocityThreshold?: number;
47 hideStatusBar?: boolean;
48 statusBarAnimation?: 'slide' | 'none' | 'fade';
49 drawerBackgroundColor?: ThemedColor;
50 overlayColor?: ThemedColor;
51 screenContainerStyle?: StyleProp<ViewStyle>;
52 detachInactiveScreens?: boolean;
53};
54export declare type NavigationDrawerRouterConfig = {
55 unmountInactiveRoutes?: boolean;
56 resetOnBlur?: boolean;
57 initialRouteName?: string;
58 contentComponent?: React.ComponentType<DrawerContentComponentProps>;
59 contentOptions?: {
60 /**
61 * the array of routes, can be modified or overridden
62 */
63 items?: NavigationRoute[];
64 /**
65 * key identifying the active route
66 */
67 activeItemKey?: string;
68 /**
69 * label and icon color of the active label
70 */
71 activeTintColor?: string;
72 /**
73 * background color of the active label
74 */
75 activeBackgroundColor?: string;
76 /**
77 * label and icon color of the inactive label
78 */
79 inactiveTintColor?: string;
80 /**
81 * background color of the inactive label
82 */
83 inactiveBackgroundColor?: string;
84 /**
85 * function to be invoked when an item is pressed
86 */
87 onItemPress?: (info: DrawerItem) => void;
88 /**
89 * style object for the content section
90 */
91 itemsContainerStyle?: StyleProp<ViewStyle>;
92 /**
93 * style object for the single item, which can contain an Icon and/or a Label
94 */
95 itemStyle?: StyleProp<ViewStyle>;
96 /**
97 * style object to overwrite Text style inside content section, when your label is a string
98 */
99 labelStyle?: StyleProp<TextStyle>;
100 /**
101 * style object to overwrite Text style of the active label, when your label is a string (merged with labelStyle)
102 */
103 activeLabelStyle?: StyleProp<TextStyle>;
104 /**
105 * style object to overwrite Text style of the inactive label, when your label is a string (merged with labelStyle)
106 */
107 inactiveLabelStyle?: StyleProp<TextStyle>;
108 /**
109 * style object to overwrite View icon container styles
110 */
111 iconContainerStyle?: StyleProp<ViewStyle>;
112 };
113 backBehavior?: 'none' | 'initialRoute' | 'history';
114};
115export interface DrawerItem {
116 route: NavigationRoute;
117 focused: boolean;
118}
119export declare type ThemedColor = string | {
120 light: string;
121 dark: string;
122};
123export declare type DrawerNavigatorItemsProps = {
124 items: NavigationRoute[];
125 activeItemKey?: string | null;
126 activeTintColor?: string | ThemedColor;
127 activeBackgroundColor?: string | ThemedColor;
128 inactiveTintColor?: string | ThemedColor;
129 inactiveBackgroundColor?: string | ThemedColor;
130 getLabel: (scene: Scene) => React.ReactNode;
131 renderIcon: (scene: Scene) => React.ReactNode;
132 onItemPress: (scene: {
133 route: NavigationRoute;
134 focused: boolean;
135 }) => void;
136 itemsContainerStyle?: StyleProp<ViewStyle>;
137 itemStyle?: StyleProp<ViewStyle>;
138 labelStyle?: StyleProp<TextStyle>;
139 activeLabelStyle?: StyleProp<TextStyle>;
140 inactiveLabelStyle?: StyleProp<TextStyle>;
141 iconContainerStyle?: StyleProp<ViewStyle>;
142 drawerPosition: 'left' | 'right';
143 screenProps: unknown;
144};
145export declare type DrawerContentComponentProps = DrawerNavigatorItemsProps & {
146 navigation: NavigationScreenProp<NavigationDrawerState>;
147 descriptors: SceneDescriptorMap;
148 drawerOpenProgress: Animated.Node<number>;
149 screenProps: unknown;
150};
151export declare type NavigationDrawerScreenProps<Params = NavigationParams, ScreenProps = unknown> = {
152 theme: SupportedThemes;
153 navigation: NavigationDrawerProp<NavigationRoute, Params>;
154 screenProps: ScreenProps;
155};
156export declare type NavigationDrawerScreenComponent<Params = NavigationParams, ScreenProps = unknown> = React.ComponentType<NavigationDrawerScreenProps<Params, ScreenProps>> & {
157 navigationOptions?: NavigationScreenConfig<NavigationDrawerOptions, NavigationDrawerProp<NavigationRoute, Params>, ScreenProps>;
158};
159export declare type SceneDescriptorMap = {
160 [key: string]: NavigationDescriptor<NavigationParams, NavigationDrawerOptions, NavigationDrawerProp<NavigationRoute, any>>;
161};