1 | import * as React from 'react';
|
2 | import {
|
3 | AccessibilityRole,
|
4 | AccessibilityState,
|
5 | StyleProp,
|
6 | TextStyle,
|
7 | ViewStyle,
|
8 | } from 'react-native';
|
9 | import Animated from 'react-native-reanimated';
|
10 | import {
|
11 | NavigationRoute,
|
12 | NavigationState,
|
13 | NavigationScreenProp,
|
14 | NavigationParams,
|
15 | NavigationDescriptor,
|
16 | NavigationScreenConfig,
|
17 | SupportedThemes,
|
18 | } from 'react-navigation';
|
19 |
|
20 | export type NavigationTabState = NavigationState;
|
21 |
|
22 | export type NavigationTabProp<
|
23 | State = NavigationRoute,
|
24 | Params = NavigationParams
|
25 | > = NavigationScreenProp<State, Params> & {
|
26 | jumpTo(routeName: string, key?: string): void;
|
27 | };
|
28 |
|
29 | export type ThemedColor =
|
30 | | string
|
31 | | {
|
32 | light: string;
|
33 | dark: string;
|
34 | };
|
35 |
|
36 | export type Orientation = 'horizontal' | 'vertical';
|
37 |
|
38 | export type LabelPosition = 'beside-icon' | 'below-icon';
|
39 |
|
40 | interface BaseAnimation {
|
41 | useNativeDriver?: boolean;
|
42 | }
|
43 | interface TimingAnimation extends BaseAnimation {
|
44 | easing?: (value: number) => number;
|
45 | duration?: number;
|
46 | delay?: number;
|
47 | }
|
48 | interface SpringAnimation extends BaseAnimation {
|
49 | overshootClamping?: boolean;
|
50 | restDisplacementThreshold?: number;
|
51 | restSpeedThreshold?: number;
|
52 | velocity?: number | { x: number; y: number };
|
53 | bounciness?: number;
|
54 | speed?: number;
|
55 | tension?: number;
|
56 | friction?: number;
|
57 | stiffness?: number;
|
58 | mass?: number;
|
59 | damping?: number;
|
60 | delay?: number;
|
61 | }
|
62 | export type TimingKeyboardAnimationConfig = {
|
63 | animation: 'timing';
|
64 | config?: TimingAnimation;
|
65 | };
|
66 | export type SpringKeyboardAnimationConfig = {
|
67 | animation: 'spring';
|
68 | config?: SpringAnimation;
|
69 | };
|
70 | export type KeyboardAnimationConfig =
|
71 | | TimingKeyboardAnimationConfig
|
72 | | SpringKeyboardAnimationConfig;
|
73 | export type KeyboardHidesTabBarAnimationConfig = {
|
74 | show: KeyboardAnimationConfig;
|
75 | hide: KeyboardAnimationConfig;
|
76 | };
|
77 |
|
78 | export type BottomTabBarOptions = {
|
79 | keyboardHidesTabBar?: boolean;
|
80 | keyboardHidesTabBarAnimationConfig?: Partial<
|
81 | KeyboardHidesTabBarAnimationConfig
|
82 | >;
|
83 | activeTintColor?: ThemedColor;
|
84 | inactiveTintColor?: ThemedColor;
|
85 | activeBackgroundColor?: ThemedColor;
|
86 | inactiveBackgroundColor?: ThemedColor;
|
87 | allowFontScaling?: boolean;
|
88 | showLabel?: boolean;
|
89 | showIcon?: boolean;
|
90 | labelStyle?: StyleProp<TextStyle>;
|
91 | tabStyle?: StyleProp<ViewStyle>;
|
92 | labelPosition?:
|
93 | | LabelPosition
|
94 | | ((options: { deviceOrientation: Orientation }) => LabelPosition);
|
95 | adaptive?: boolean;
|
96 | safeAreaInset?: {
|
97 | top?: 'always' | 'never' | number;
|
98 | right?: 'always' | 'never' | number;
|
99 | bottom?: 'always' | 'never' | number;
|
100 | left?: 'always' | 'never' | number;
|
101 | };
|
102 | style?: StyleProp<ViewStyle>;
|
103 | };
|
104 |
|
105 | export type ButtonComponentProps = {
|
106 | route: NavigationRoute;
|
107 | focused: boolean;
|
108 | onPress: () => void;
|
109 | onLongPress: () => void;
|
110 | testID?: string;
|
111 | accessibilityLabel?: string;
|
112 | accessibilityRole?: AccessibilityRole;
|
113 | accessibilityState?: AccessibilityState;
|
114 | accessibilityStates?: string[];
|
115 | style?: StyleProp<ViewStyle>;
|
116 | };
|
117 |
|
118 | export type BottomTabBarProps = BottomTabBarOptions & {
|
119 | navigation: NavigationTabProp;
|
120 | onTabPress: (props: { route: NavigationRoute }) => void;
|
121 | onTabLongPress: (props: { route: NavigationRoute }) => void;
|
122 | getAccessibilityLabel: (props: {
|
123 | route: NavigationRoute;
|
124 | }) => string | undefined;
|
125 | getAccessibilityRole: (props: {
|
126 | route: NavigationRoute;
|
127 | }) => AccessibilityRole | undefined;
|
128 | getAccessibilityStates: (props: {
|
129 | route: NavigationRoute;
|
130 | focused: boolean;
|
131 | }) => string[];
|
132 | getButtonComponent: (props: {
|
133 | route: NavigationRoute;
|
134 | }) => React.ComponentType<ButtonComponentProps> | undefined;
|
135 | getLabelText: (props: {
|
136 | route: NavigationRoute;
|
137 | }) =>
|
138 | | ((scene: {
|
139 | focused: boolean;
|
140 | tintColor?: string;
|
141 | orientation?: 'horizontal' | 'vertical';
|
142 | }) => string | undefined)
|
143 | | string
|
144 | | undefined;
|
145 | getTestID: (props: { route: NavigationRoute }) => string | undefined;
|
146 | renderIcon: (props: {
|
147 | route: NavigationRoute;
|
148 | focused: boolean;
|
149 | tintColor?: string;
|
150 | horizontal?: boolean;
|
151 | }) => React.ReactNode;
|
152 | dimensions: { width: number; height: number };
|
153 | isLandscape: boolean;
|
154 | jumpTo: (key: string) => void;
|
155 | screenProps: unknown;
|
156 | detachInactiveScreens?: boolean;
|
157 | };
|
158 |
|
159 | export type MaterialTabBarOptions = {
|
160 | activeTintColor?: string;
|
161 | allowFontScaling?: boolean;
|
162 | bounces?: boolean;
|
163 | inactiveTintColor?: string;
|
164 | pressColor?: string;
|
165 | pressOpacity?: number;
|
166 | scrollEnabled?: boolean;
|
167 | showIcon?: boolean;
|
168 | showLabel?: boolean;
|
169 | upperCaseLabel?: boolean;
|
170 | tabStyle?: StyleProp<ViewStyle>;
|
171 | indicatorStyle?: StyleProp<ViewStyle>;
|
172 | iconStyle?: StyleProp<ViewStyle>;
|
173 | labelStyle?: StyleProp<TextStyle>;
|
174 | contentContainerStyle?: StyleProp<ViewStyle>;
|
175 | style?: StyleProp<ViewStyle>;
|
176 | };
|
177 |
|
178 | export type MaterialTabBarProps = MaterialTabBarOptions & {
|
179 | layout: {
|
180 | width: number;
|
181 | height: number;
|
182 | };
|
183 | position: Animated.Node<number>;
|
184 | jumpTo: (key: string) => void;
|
185 | getLabelText: (scene: {
|
186 | route: NavigationRoute;
|
187 | }) =>
|
188 | | ((scene: { focused: boolean; tintColor: string }) => string | undefined)
|
189 | | string
|
190 | | undefined;
|
191 | getAccessible?: (scene: { route: NavigationRoute }) => boolean | undefined;
|
192 | getAccessibilityLabel: (scene: {
|
193 | route: NavigationRoute;
|
194 | }) => string | undefined;
|
195 | getTestID: (scene: { route: NavigationRoute }) => string | undefined;
|
196 | renderIcon: (scene: {
|
197 | route: NavigationRoute;
|
198 | focused: boolean;
|
199 | tintColor: string;
|
200 | horizontal?: boolean;
|
201 | }) => React.ReactNode;
|
202 | renderBadge?: (scene: { route: NavigationRoute }) => React.ReactNode;
|
203 | onTabPress?: (scene: { route: NavigationRoute }) => void;
|
204 | onTabLongPress?: (scene: { route: NavigationRoute }) => void;
|
205 | tabBarPosition?: 'top' | 'bottom';
|
206 | screenProps: unknown;
|
207 | navigation: NavigationTabProp;
|
208 | };
|
209 |
|
210 | export type NavigationCommonTabOptions = {
|
211 | title?: string;
|
212 | tabBarLabel?: React.ReactNode;
|
213 | tabBarVisible?: boolean;
|
214 | tabBarAccessibilityLabel?: string;
|
215 | tabBarTestID?: string;
|
216 | tabBarIcon?:
|
217 | | React.ReactNode
|
218 | | ((props: {
|
219 | focused: boolean;
|
220 | tintColor?: string;
|
221 | horizontal?: boolean;
|
222 | }) => React.ReactNode);
|
223 | tabBarOnPress?: (props: {
|
224 | navigation: NavigationTabProp;
|
225 | defaultHandler: () => void;
|
226 | }) => void;
|
227 | tabBarOnLongPress?: (props: {
|
228 | navigation: NavigationTabProp;
|
229 | defaultHandler: () => void;
|
230 | }) => void;
|
231 | };
|
232 |
|
233 | export type NavigationBottomTabOptions = NavigationCommonTabOptions & {
|
234 | tabBarButtonComponent?: React.ComponentType<ButtonComponentProps>;
|
235 | };
|
236 |
|
237 | export type NavigationMaterialTabOptions = NavigationCommonTabOptions & {
|
238 | tabBarButtonComponent?: React.ComponentType<any>;
|
239 | swipeEnabled?: boolean | ((state: NavigationState) => boolean);
|
240 | };
|
241 |
|
242 | export type NavigationTabScreenProps<
|
243 | Params = NavigationParams,
|
244 | ScreenProps = unknown
|
245 | > = {
|
246 | theme: SupportedThemes;
|
247 | navigation: NavigationTabProp<NavigationRoute, Params>;
|
248 | screenProps: ScreenProps;
|
249 | };
|
250 |
|
251 | export type NavigationMaterialTabScreenComponent<
|
252 | Params = NavigationParams,
|
253 | ScreenProps = unknown
|
254 | > = React.ComponentType<NavigationTabScreenProps<Params, ScreenProps>> & {
|
255 | navigationOptions?: NavigationScreenConfig<
|
256 | NavigationMaterialTabOptions,
|
257 | NavigationTabProp<NavigationRoute, Params>,
|
258 | ScreenProps
|
259 | >;
|
260 | };
|
261 |
|
262 | export type NavigationBottomTabScreenComponent<
|
263 | Params = NavigationParams,
|
264 | ScreenProps = unknown
|
265 | > = React.ComponentType<NavigationTabScreenProps<Params, ScreenProps>> & {
|
266 | navigationOptions?: NavigationScreenConfig<
|
267 | NavigationBottomTabOptions,
|
268 | NavigationTabProp<NavigationRoute, Params>,
|
269 | ScreenProps
|
270 | >;
|
271 | };
|
272 |
|
273 | export type SceneDescriptorMap = {
|
274 | [key: string]: NavigationDescriptor<
|
275 | NavigationParams,
|
276 | NavigationBottomTabOptions | NavigationMaterialTabOptions,
|
277 | NavigationTabProp
|
278 | >;
|
279 | };
|
280 |
|
\ | No newline at end of file |