-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathtypes.ts
More file actions
145 lines (127 loc) · 3.49 KB
/
types.ts
File metadata and controls
145 lines (127 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import type {
Descriptor,
NavigationHelpers,
NavigationProp,
ParamListBase,
RouteProp,
TabActionHelpers,
TabNavigationState,
} from '@react-navigation/native';
import type { ImageSourcePropType } from 'react-native';
import type TabView from 'react-native-bottom-tabs';
import type { AppleIcon, TabRole } from 'react-native-bottom-tabs';
export type NativeBottomTabNavigationEventMap = {
/**
* Event which fires on tapping on the tab in the tab bar.
*/
tabPress: { data: undefined; canPreventDefault: true };
/**
* Event which fires on long press on tab bar.
*/
tabLongPress: { data: undefined };
};
export type NativeBottomTabNavigationHelpers = NavigationHelpers<
ParamListBase,
NativeBottomTabNavigationEventMap
> &
TabActionHelpers<ParamListBase>;
export type NativeBottomTabNavigationProp<
ParamList extends ParamListBase,
RouteName extends keyof ParamList = keyof ParamList,
NavigatorID extends string | undefined = undefined,
> = NavigationProp<
ParamList,
RouteName,
NavigatorID,
TabNavigationState<ParamList>,
NativeBottomTabNavigationOptions,
NativeBottomTabNavigationEventMap
> &
TabActionHelpers<ParamList>;
export type NativeBottomTabScreenProps<
ParamList extends ParamListBase,
RouteName extends keyof ParamList = keyof ParamList,
NavigatorID extends string | undefined = undefined,
> = {
navigation: NativeBottomTabNavigationProp<ParamList, RouteName, NavigatorID>;
route: RouteProp<ParamList, RouteName>;
};
export type NativeBottomTabNavigationOptions = {
/**
* Title text for the screen.
*/
title?: string;
/**
* Label text of the tab displayed in the navigation bar. When undefined, scene title is used.
*/
tabBarLabel?: string;
/**
* Function that given { focused: boolean } returns ImageSource or AppleIcon to display in the navigation bar.
*/
tabBarIcon?: (props: { focused: boolean }) => ImageSourcePropType | AppleIcon;
/**
* Whether the tab bar item is visible. Defaults to true.
*/
tabBarItemHidden?: boolean;
/**
* Badge to show on the tab icon.
*/
tabBarBadge?: string;
/**
* Whether this screens should render the first time it's accessed. Defaults to true. Set it to false if you want to render the screen on initial render.
*/
lazy?: boolean;
/**
* Active tab color.
*/
tabBarActiveTintColor?: string;
/**
* TestID for the tab.
*/
tabBarButtonTestID?: string;
/**
* Role for the tab. (iOS only)
*/
role?: TabRole;
/**
* Whether inactive screens should be suspended from re-rendering. Defaults to `false`.
*/
freezeOnBlur?: boolean;
};
export type NativeBottomTabDescriptor = Descriptor<
NativeBottomTabNavigationOptions,
NativeBottomTabNavigationProp<ParamListBase>,
RouteProp<ParamListBase>
>;
export type NativeBottomTabDescriptorMap = Record<
string,
NativeBottomTabDescriptor
>;
export type BottomTabBarProps = {
state: TabNavigationState<ParamListBase>;
descriptors: NativeBottomTabDescriptorMap;
navigation: NavigationHelpers<
ParamListBase,
NativeBottomTabNavigationEventMap
>;
};
export type NativeBottomTabNavigationConfig = Partial<
Omit<
React.ComponentProps<typeof TabView>,
| 'navigationState'
| 'onIndexChange'
| 'renderScene'
| 'getLazy'
| 'getIcon'
| 'getLabelText'
| 'getBadge'
| 'onTabLongPress'
| 'getActiveTintColor'
| 'getTestID'
| 'getRole'
| 'tabBar'
| 'getFreezeOnBlur'
>
> & {
tabBar?: (props: BottomTabBarProps) => React.ReactNode;
};