react-native-tab-view 3.2.1 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/{LICENSE.md → LICENSE} +0 -0
  2. package/README.md +5 -36
  3. package/lib/commonjs/PagerViewAdapter.js +2 -1
  4. package/lib/commonjs/PagerViewAdapter.js.map +1 -1
  5. package/lib/commonjs/PanResponderAdapter.js +2 -1
  6. package/lib/commonjs/PanResponderAdapter.js.map +1 -1
  7. package/lib/commonjs/SceneMap.js +9 -12
  8. package/lib/commonjs/SceneMap.js.map +1 -1
  9. package/lib/commonjs/SceneView.js +54 -101
  10. package/lib/commonjs/SceneView.js.map +1 -1
  11. package/lib/commonjs/TabBar.js +358 -325
  12. package/lib/commonjs/TabBar.js.map +1 -1
  13. package/lib/commonjs/TabBarIndicator.js +81 -99
  14. package/lib/commonjs/TabBarIndicator.js.map +1 -1
  15. package/lib/commonjs/TabBarItem.js +184 -161
  16. package/lib/commonjs/TabBarItem.js.map +1 -1
  17. package/lib/commonjs/TabView.js +2 -2
  18. package/lib/commonjs/TabView.js.map +1 -1
  19. package/lib/commonjs/index.js +3 -3
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/module/PagerViewAdapter.js +2 -1
  22. package/lib/module/PagerViewAdapter.js.map +1 -1
  23. package/lib/module/PanResponderAdapter.js +3 -2
  24. package/lib/module/PanResponderAdapter.js.map +1 -1
  25. package/lib/module/SceneMap.js +9 -14
  26. package/lib/module/SceneMap.js.map +1 -1
  27. package/lib/module/SceneView.js +54 -99
  28. package/lib/module/SceneView.js.map +1 -1
  29. package/lib/module/TabBar.js +355 -324
  30. package/lib/module/TabBar.js.map +1 -1
  31. package/lib/module/TabBarIndicator.js +75 -93
  32. package/lib/module/TabBarIndicator.js.map +1 -1
  33. package/lib/module/TabBarItem.js +178 -154
  34. package/lib/module/TabBarItem.js.map +1 -1
  35. package/lib/module/TabView.js +2 -2
  36. package/lib/module/TabView.js.map +1 -1
  37. package/lib/module/index.js +2 -2
  38. package/lib/module/index.js.map +1 -1
  39. package/lib/typescript/{Pager.android.d.ts → src/Pager.android.d.ts} +0 -0
  40. package/lib/typescript/{Pager.d.ts → src/Pager.d.ts} +0 -0
  41. package/lib/typescript/{Pager.ios.d.ts → src/Pager.ios.d.ts} +0 -0
  42. package/lib/typescript/{PagerViewAdapter.d.ts → src/PagerViewAdapter.d.ts} +1 -1
  43. package/lib/typescript/{PanResponderAdapter.d.ts → src/PanResponderAdapter.d.ts} +1 -1
  44. package/lib/typescript/{PlatformPressable.d.ts → src/PlatformPressable.d.ts} +0 -0
  45. package/lib/typescript/{SceneMap.d.ts → src/SceneMap.d.ts} +5 -3
  46. package/lib/typescript/src/SceneView.d.ts +15 -0
  47. package/lib/typescript/src/TabBar.d.ts +42 -0
  48. package/lib/typescript/src/TabBarIndicator.d.ts +12 -0
  49. package/lib/typescript/{TabBarItem.d.ts → src/TabBarItem.d.ts} +5 -7
  50. package/lib/typescript/{TabView.d.ts → src/TabView.d.ts} +1 -1
  51. package/lib/typescript/{index.d.ts → src/index.d.ts} +7 -7
  52. package/lib/typescript/{types.d.ts → src/types.d.ts} +0 -0
  53. package/lib/typescript/{useAnimatedValue.d.ts → src/useAnimatedValue.d.ts} +0 -0
  54. package/package.json +28 -58
  55. package/src/PagerViewAdapter.tsx +11 -5
  56. package/src/PanResponderAdapter.tsx +16 -12
  57. package/src/SceneMap.tsx +12 -7
  58. package/src/SceneView.tsx +73 -108
  59. package/src/TabBar.tsx +506 -401
  60. package/src/TabBarIndicator.tsx +114 -117
  61. package/src/TabBarItem.tsx +230 -200
  62. package/src/TabView.tsx +6 -5
  63. package/src/index.tsx +7 -12
  64. package/lib/typescript/SceneView.d.ts +0 -32
  65. package/lib/typescript/TabBar.d.ts +0 -72
  66. package/lib/typescript/TabBarIndicator.d.ts +0 -20
@@ -1,15 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import {
3
3
  Animated,
4
- StyleSheet,
5
- View,
6
- StyleProp,
7
4
  LayoutChangeEvent,
5
+ StyleProp,
6
+ StyleSheet,
8
7
  TextStyle,
8
+ View,
9
9
  ViewStyle,
10
10
  } from 'react-native';
11
+ import useLatestCallback from 'use-latest-callback';
12
+
11
13
  import PlatformPressable from './PlatformPressable';
12
- import type { Scene, Route, NavigationState } from './types';
14
+ import type { NavigationState, Route, Scene } from './types';
13
15
 
14
16
  export type Props<T extends Route> = {
15
17
  position: Animated.AnimatedInterpolation;
@@ -37,6 +39,7 @@ export type Props<T extends Route> = {
37
39
  onLayout?: (event: LayoutChangeEvent) => void;
38
40
  onPress: () => void;
39
41
  onLongPress: () => void;
42
+ defaultTabWidth?: number;
40
43
  labelStyle?: StyleProp<TextStyle>;
41
44
  style: StyleProp<ViewStyle>;
42
45
  };
@@ -44,219 +47,246 @@ export type Props<T extends Route> = {
44
47
  const DEFAULT_ACTIVE_COLOR = 'rgba(255, 255, 255, 1)';
45
48
  const DEFAULT_INACTIVE_COLOR = 'rgba(255, 255, 255, 0.7)';
46
49
 
47
- export default class TabBarItem<T extends Route> extends React.Component<
48
- Props<T>
49
- > {
50
- private getActiveOpacity = (
51
- position: Animated.AnimatedInterpolation,
52
- routes: Route[],
53
- tabIndex: number
54
- ) => {
55
- if (routes.length > 1) {
56
- const inputRange = routes.map((_, i) => i);
57
-
58
- return position.interpolate({
59
- inputRange,
60
- outputRange: inputRange.map((i) => (i === tabIndex ? 1 : 0)),
61
- });
62
- } else {
63
- return 1;
64
- }
65
- };
66
-
67
- private getInactiveOpacity = (
68
- position: Animated.AnimatedInterpolation,
69
- routes: Route[],
70
- tabIndex: number
71
- ) => {
72
- if (routes.length > 1) {
73
- const inputRange = routes.map((_: Route, i: number) => i);
74
-
75
- return position.interpolate({
76
- inputRange,
77
- outputRange: inputRange.map((i: number) => (i === tabIndex ? 0 : 1)),
78
- });
79
- } else {
80
- return 0;
81
- }
82
- };
50
+ const getActiveOpacity = (
51
+ position: Animated.AnimatedInterpolation,
52
+ routesLength: number,
53
+ tabIndex: number
54
+ ) => {
55
+ if (routesLength > 1) {
56
+ const inputRange = Array.from({ length: routesLength }, (_, i) => i);
83
57
 
84
- render() {
85
- const {
86
- route,
87
- position,
88
- navigationState,
89
- renderLabel: renderLabelCustom,
90
- renderIcon,
91
- renderBadge,
92
- getLabelText,
93
- getTestID,
94
- getAccessibilityLabel,
95
- getAccessible,
96
- activeColor: activeColorCustom,
97
- inactiveColor: inactiveColorCustom,
98
- pressColor,
99
- pressOpacity,
100
- labelStyle,
101
- style,
102
- onLayout,
103
- onPress,
104
- onLongPress,
105
- } = this.props;
106
-
107
- const tabIndex = navigationState.routes.indexOf(route);
108
- const isFocused = navigationState.index === tabIndex;
109
-
110
- const labelColorFromStyle = StyleSheet.flatten(labelStyle || {}).color;
111
-
112
- const activeColor =
113
- activeColorCustom !== undefined
114
- ? activeColorCustom
115
- : typeof labelColorFromStyle === 'string'
116
- ? labelColorFromStyle
117
- : DEFAULT_ACTIVE_COLOR;
118
- const inactiveColor =
119
- inactiveColorCustom !== undefined
120
- ? inactiveColorCustom
121
- : typeof labelColorFromStyle === 'string'
122
- ? labelColorFromStyle
123
- : DEFAULT_INACTIVE_COLOR;
124
-
125
- const activeOpacity = this.getActiveOpacity(
126
- position,
127
- navigationState.routes,
128
- tabIndex
129
- );
130
- const inactiveOpacity = this.getInactiveOpacity(
131
- position,
132
- navigationState.routes,
133
- tabIndex
134
- );
58
+ return position.interpolate({
59
+ inputRange,
60
+ outputRange: inputRange.map((i) => (i === tabIndex ? 1 : 0)),
61
+ });
62
+ } else {
63
+ return 1;
64
+ }
65
+ };
135
66
 
136
- let icon: React.ReactNode | null = null;
137
- let label: React.ReactNode | null = null;
138
-
139
- if (renderIcon) {
140
- const activeIcon = renderIcon({
141
- route,
142
- focused: true,
143
- color: activeColor,
144
- });
145
- const inactiveIcon = renderIcon({
146
- route,
147
- focused: false,
148
- color: inactiveColor,
149
- });
150
-
151
- if (inactiveIcon != null && activeIcon != null) {
152
- icon = (
153
- <View style={styles.icon}>
154
- <Animated.View style={{ opacity: inactiveOpacity }}>
155
- {inactiveIcon}
156
- </Animated.View>
157
- <Animated.View
158
- style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}
159
- >
160
- {activeIcon}
161
- </Animated.View>
162
- </View>
163
- );
164
- }
165
- }
67
+ const getInactiveOpacity = (
68
+ position: Animated.AnimatedInterpolation,
69
+ routesLength: number,
70
+ tabIndex: number
71
+ ) => {
72
+ if (routesLength > 1) {
73
+ const inputRange = Array.from({ length: routesLength }, (_, i) => i);
74
+
75
+ return position.interpolate({
76
+ inputRange,
77
+ outputRange: inputRange.map((i: number) => (i === tabIndex ? 0 : 1)),
78
+ });
79
+ } else {
80
+ return 0;
81
+ }
82
+ };
83
+
84
+ type TabBarItemInternalProps<T extends Route> = Omit<
85
+ Props<T>,
86
+ 'navigationState'
87
+ > & {
88
+ isFocused: boolean;
89
+ index: number;
90
+ routesLength: number;
91
+ };
92
+
93
+ const TabBarItemInternal = <T extends Route>({
94
+ getAccessibilityLabel,
95
+ getAccessible,
96
+ getLabelText,
97
+ getTestID,
98
+ onLongPress,
99
+ onPress,
100
+ isFocused,
101
+ position,
102
+ route,
103
+ style,
104
+ inactiveColor: inactiveColorCustom,
105
+ activeColor: activeColorCustom,
106
+ labelStyle,
107
+ onLayout,
108
+ index: tabIndex,
109
+ pressColor,
110
+ pressOpacity,
111
+ renderBadge,
112
+ renderIcon,
113
+ defaultTabWidth,
114
+ routesLength,
115
+ renderLabel: renderLabelCustom,
116
+ }: TabBarItemInternalProps<T>) => {
117
+ const labelColorFromStyle = StyleSheet.flatten(labelStyle || {}).color;
118
+
119
+ const activeColor =
120
+ activeColorCustom !== undefined
121
+ ? activeColorCustom
122
+ : typeof labelColorFromStyle === 'string'
123
+ ? labelColorFromStyle
124
+ : DEFAULT_ACTIVE_COLOR;
125
+ const inactiveColor =
126
+ inactiveColorCustom !== undefined
127
+ ? inactiveColorCustom
128
+ : typeof labelColorFromStyle === 'string'
129
+ ? labelColorFromStyle
130
+ : DEFAULT_INACTIVE_COLOR;
131
+
132
+ const activeOpacity = getActiveOpacity(position, routesLength, tabIndex);
133
+ const inactiveOpacity = getInactiveOpacity(position, routesLength, tabIndex);
134
+
135
+ let icon: React.ReactNode | null = null;
136
+ let label: React.ReactNode | null = null;
166
137
 
167
- const renderLabel =
168
- renderLabelCustom !== undefined
169
- ? renderLabelCustom
170
- : ({ route, color }: { route: T; color: string }) => {
171
- const labelText = getLabelText({ route });
172
-
173
- if (typeof labelText === 'string') {
174
- return (
175
- <Animated.Text
176
- style={[
177
- styles.label,
178
- icon ? { marginTop: 0 } : null,
179
- labelStyle,
180
- { color },
181
- ]}
182
- >
183
- {labelText}
184
- </Animated.Text>
185
- );
186
- }
187
-
188
- return labelText;
189
- };
190
-
191
- if (renderLabel) {
192
- const activeLabel = renderLabel({
193
- route,
194
- focused: true,
195
- color: activeColor,
196
- });
197
- const inactiveLabel = renderLabel({
198
- route,
199
- focused: false,
200
- color: inactiveColor,
201
- });
202
-
203
- label = (
204
- <View>
138
+ if (renderIcon) {
139
+ const activeIcon = renderIcon({
140
+ route,
141
+ focused: true,
142
+ color: activeColor,
143
+ });
144
+ const inactiveIcon = renderIcon({
145
+ route,
146
+ focused: false,
147
+ color: inactiveColor,
148
+ });
149
+
150
+ if (inactiveIcon != null && activeIcon != null) {
151
+ icon = (
152
+ <View style={styles.icon}>
205
153
  <Animated.View style={{ opacity: inactiveOpacity }}>
206
- {inactiveLabel}
154
+ {inactiveIcon}
207
155
  </Animated.View>
208
156
  <Animated.View
209
157
  style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}
210
158
  >
211
- {activeLabel}
159
+ {activeIcon}
212
160
  </Animated.View>
213
161
  </View>
214
162
  );
215
163
  }
164
+ }
216
165
 
217
- const tabStyle = StyleSheet.flatten(style);
218
- const isWidthSet = tabStyle?.width !== undefined;
219
- const tabContainerStyle: ViewStyle | null = isWidthSet ? null : { flex: 1 };
220
-
221
- const scene = { route };
222
-
223
- let accessibilityLabel = getAccessibilityLabel(scene);
224
-
225
- accessibilityLabel =
226
- typeof accessibilityLabel !== 'undefined'
227
- ? accessibilityLabel
228
- : getLabelText(scene);
229
-
230
- const badge = renderBadge ? renderBadge(scene) : null;
231
-
232
- return (
233
- <PlatformPressable
234
- android_ripple={{ borderless: true }}
235
- testID={getTestID(scene)}
236
- accessible={getAccessible(scene)}
237
- accessibilityLabel={accessibilityLabel}
238
- accessibilityRole="tab"
239
- accessibilityState={{ selected: isFocused }}
240
- // @ts-ignore: this is to support older React Native versions
241
- accessibilityStates={isFocused ? ['selected'] : []}
242
- pressColor={pressColor}
243
- pressOpacity={pressOpacity}
244
- delayPressIn={0}
245
- onLayout={onLayout}
246
- onPress={onPress}
247
- onLongPress={onLongPress}
248
- style={[styles.pressable, tabContainerStyle]}
249
- >
250
- <View pointerEvents="none" style={[styles.item, tabStyle]}>
251
- {icon}
252
- {label}
253
- {badge != null ? <View style={styles.badge}>{badge}</View> : null}
254
- </View>
255
- </PlatformPressable>
166
+ const renderLabel =
167
+ renderLabelCustom !== undefined
168
+ ? renderLabelCustom
169
+ : (labelProps: { route: T; color: string }) => {
170
+ const labelText = getLabelText({ route: labelProps.route });
171
+
172
+ if (typeof labelText === 'string') {
173
+ return (
174
+ <Animated.Text
175
+ style={[
176
+ styles.label,
177
+ icon ? { marginTop: 0 } : null,
178
+ labelStyle,
179
+ { color: labelProps.color },
180
+ ]}
181
+ >
182
+ {labelText}
183
+ </Animated.Text>
184
+ );
185
+ }
186
+
187
+ return labelText;
188
+ };
189
+
190
+ if (renderLabel) {
191
+ const activeLabel = renderLabel({
192
+ route,
193
+ focused: true,
194
+ color: activeColor,
195
+ });
196
+ const inactiveLabel = renderLabel({
197
+ route,
198
+ focused: false,
199
+ color: inactiveColor,
200
+ });
201
+
202
+ label = (
203
+ <View>
204
+ <Animated.View style={{ opacity: inactiveOpacity }}>
205
+ {inactiveLabel}
206
+ </Animated.View>
207
+ <Animated.View
208
+ style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}
209
+ >
210
+ {activeLabel}
211
+ </Animated.View>
212
+ </View>
256
213
  );
257
214
  }
215
+
216
+ const tabStyle = StyleSheet.flatten(style);
217
+ const isWidthSet = tabStyle?.width !== undefined;
218
+
219
+ const tabContainerStyle: ViewStyle | null = isWidthSet
220
+ ? null
221
+ : { width: defaultTabWidth };
222
+
223
+ const scene = { route };
224
+
225
+ let accessibilityLabel = getAccessibilityLabel(scene);
226
+
227
+ accessibilityLabel =
228
+ typeof accessibilityLabel !== 'undefined'
229
+ ? accessibilityLabel
230
+ : getLabelText(scene);
231
+
232
+ const badge = renderBadge ? renderBadge(scene) : null;
233
+
234
+ return (
235
+ <PlatformPressable
236
+ android_ripple={{ borderless: true }}
237
+ testID={getTestID(scene)}
238
+ accessible={getAccessible(scene)}
239
+ accessibilityLabel={accessibilityLabel}
240
+ accessibilityRole="tab"
241
+ accessibilityState={{ selected: isFocused }}
242
+ // @ts-ignore: this is to support older React Native versions
243
+ accessibilityStates={isFocused ? ['selected'] : []}
244
+ pressColor={pressColor}
245
+ pressOpacity={pressOpacity}
246
+ delayPressIn={0}
247
+ onLayout={onLayout}
248
+ onPress={onPress}
249
+ onLongPress={onLongPress}
250
+ style={[styles.pressable, tabContainerStyle]}
251
+ >
252
+ <View pointerEvents="none" style={[styles.item, tabStyle]}>
253
+ {icon}
254
+ {label}
255
+ {badge != null ? <View style={styles.badge}>{badge}</View> : null}
256
+ </View>
257
+ </PlatformPressable>
258
+ );
259
+ };
260
+
261
+ const MemoizedTabBarItemInternal = React.memo(
262
+ TabBarItemInternal
263
+ ) as typeof TabBarItemInternal;
264
+
265
+ function TabBarItem<T extends Route>(props: Props<T>) {
266
+ const { onPress, onLongPress, onLayout, navigationState, route, ...rest } =
267
+ props;
268
+ const onPressLatest = useLatestCallback(onPress);
269
+ const onLongPressLatest = useLatestCallback(onLongPress);
270
+ const onLayoutLatest = useLatestCallback(onLayout ? onLayout : () => {});
271
+
272
+ const tabIndex = navigationState.routes.indexOf(route);
273
+
274
+ return (
275
+ <MemoizedTabBarItemInternal
276
+ {...rest}
277
+ onPress={onPressLatest}
278
+ onLayout={onLayoutLatest}
279
+ onLongPress={onLongPressLatest}
280
+ isFocused={navigationState.index === tabIndex}
281
+ route={route}
282
+ index={tabIndex}
283
+ routesLength={navigationState.routes.length}
284
+ />
285
+ );
258
286
  }
259
287
 
288
+ export default TabBarItem;
289
+
260
290
  const styles = StyleSheet.create({
261
291
  label: {
262
292
  margin: 4,
package/src/TabView.tsx CHANGED
@@ -1,20 +1,21 @@
1
1
  import * as React from 'react';
2
2
  import {
3
+ LayoutChangeEvent,
4
+ StyleProp,
3
5
  StyleSheet,
4
6
  View,
5
- StyleProp,
6
7
  ViewStyle,
7
- LayoutChangeEvent,
8
8
  } from 'react-native';
9
- import TabBar from './TabBar';
10
- import SceneView from './SceneView';
9
+
11
10
  import Pager from './Pager';
11
+ import SceneView from './SceneView';
12
+ import TabBar from './TabBar';
12
13
  import type {
13
14
  Layout,
14
15
  NavigationState,
16
+ PagerProps,
15
17
  Route,
16
18
  SceneRendererProps,
17
- PagerProps,
18
19
  } from './types';
19
20
 
20
21
  export type Props<T extends Route> = PagerProps & {
package/src/index.tsx CHANGED
@@ -1,15 +1,10 @@
1
- export { default as TabBar } from './TabBar';
1
+ export { default as SceneMap } from './SceneMap';
2
2
  export type { Props as TabBarProps } from './TabBar';
3
-
4
- export { default as TabView } from './TabView';
5
- export type { Props as TabViewProps } from './TabView';
6
-
7
- export { default as TabBarIndicator } from './TabBarIndicator';
3
+ export { default as TabBar } from './TabBar';
8
4
  export type { Props as TabBarIndicatorProps } from './TabBarIndicator';
9
-
10
- export { default as TabBarItem } from './TabBarItem';
5
+ export { default as TabBarIndicator } from './TabBarIndicator';
11
6
  export type { Props as TabBarItemProps } from './TabBarItem';
12
-
13
- export { default as SceneMap } from './SceneMap';
14
-
15
- export type { Route, NavigationState, SceneRendererProps } from './types';
7
+ export { default as TabBarItem } from './TabBarItem';
8
+ export type { Props as TabViewProps } from './TabView';
9
+ export { default as TabView } from './TabView';
10
+ export type { NavigationState, Route, SceneRendererProps } from './types';
@@ -1,32 +0,0 @@
1
- import * as React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
3
- import type { SceneRendererProps, EventEmitterProps, NavigationState, Route } from './types';
4
- declare type Props<T extends Route> = SceneRendererProps & EventEmitterProps & {
5
- navigationState: NavigationState<T>;
6
- lazy: boolean;
7
- lazyPreloadDistance: number;
8
- index: number;
9
- children: (props: {
10
- loading: boolean;
11
- }) => React.ReactNode;
12
- style?: StyleProp<ViewStyle>;
13
- };
14
- declare type State = {
15
- loading: boolean;
16
- };
17
- export default class SceneView<T extends Route> extends React.Component<Props<T>, State> {
18
- static getDerivedStateFromProps(props: Props<Route>, state: State): {
19
- loading: boolean;
20
- } | null;
21
- state: {
22
- loading: boolean;
23
- };
24
- componentDidMount(): void;
25
- componentDidUpdate(prevProps: Props<T>, prevState: State): void;
26
- componentWillUnmount(): void;
27
- private timerHandler;
28
- private unsubscribe;
29
- private handleEnter;
30
- render(): JSX.Element;
31
- }
32
- export {};
@@ -1,72 +0,0 @@
1
- import * as React from 'react';
2
- import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
- import { Props as TabBarItemProps } from './TabBarItem';
4
- import { Props as IndicatorProps } from './TabBarIndicator';
5
- import type { Route, Scene, SceneRendererProps, NavigationState, Layout, Event } from './types';
6
- export declare type Props<T extends Route> = SceneRendererProps & {
7
- navigationState: NavigationState<T>;
8
- scrollEnabled?: boolean;
9
- bounces?: boolean;
10
- activeColor?: string;
11
- inactiveColor?: string;
12
- pressColor?: string;
13
- pressOpacity?: number;
14
- getLabelText: (scene: Scene<T>) => string | undefined;
15
- getAccessible: (scene: Scene<T>) => boolean | undefined;
16
- getAccessibilityLabel: (scene: Scene<T>) => string | undefined;
17
- getTestID: (scene: Scene<T>) => string | undefined;
18
- renderLabel?: (scene: Scene<T> & {
19
- focused: boolean;
20
- color: string;
21
- }) => React.ReactNode;
22
- renderIcon?: (scene: Scene<T> & {
23
- focused: boolean;
24
- color: string;
25
- }) => React.ReactNode;
26
- renderBadge?: (scene: Scene<T>) => React.ReactNode;
27
- renderIndicator: (props: IndicatorProps<T>) => React.ReactNode;
28
- renderTabBarItem?: (props: TabBarItemProps<T> & {
29
- key: string;
30
- }) => React.ReactElement;
31
- onTabPress?: (scene: Scene<T> & Event) => void;
32
- onTabLongPress?: (scene: Scene<T>) => void;
33
- tabStyle?: StyleProp<ViewStyle>;
34
- indicatorStyle?: StyleProp<ViewStyle>;
35
- indicatorContainerStyle?: StyleProp<ViewStyle>;
36
- labelStyle?: StyleProp<TextStyle>;
37
- contentContainerStyle?: StyleProp<ViewStyle>;
38
- style?: StyleProp<ViewStyle>;
39
- gap?: number;
40
- };
41
- declare type State = {
42
- layout: Layout;
43
- tabWidths: {
44
- [key: string]: number;
45
- };
46
- };
47
- export default class TabBar<T extends Route> extends React.Component<Props<T>, State> {
48
- static defaultProps: {
49
- getLabelText: ({ route }: Scene<Route>) => string | undefined;
50
- getAccessible: ({ route }: Scene<Route>) => boolean;
51
- getAccessibilityLabel: ({ route }: Scene<Route>) => string | undefined;
52
- getTestID: ({ route }: Scene<Route>) => string | undefined;
53
- renderIndicator: (props: IndicatorProps<Route>) => JSX.Element;
54
- gap: number;
55
- };
56
- state: State;
57
- componentDidUpdate(prevProps: Props<T>, prevState: State): void;
58
- private measuredTabWidths;
59
- private scrollAmount;
60
- private flatListRef;
61
- private getFlattenedTabWidth;
62
- private getComputedTabWidth;
63
- private getMaxScrollDistance;
64
- private getTabBarWidth;
65
- private normalizeScrollValue;
66
- private getScrollAmount;
67
- private resetScroll;
68
- private handleLayout;
69
- private getTranslateX;
70
- render(): JSX.Element;
71
- }
72
- export {};
@@ -1,20 +0,0 @@
1
- import * as React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
3
- import type { Route, SceneRendererProps, NavigationState } from './types';
4
- export declare type GetTabWidth = (index: number) => number;
5
- export declare type Props<T extends Route> = SceneRendererProps & {
6
- navigationState: NavigationState<T>;
7
- width: string | number;
8
- style?: StyleProp<ViewStyle>;
9
- getTabWidth: GetTabWidth;
10
- gap?: number;
11
- };
12
- export default class TabBarIndicator<T extends Route> extends React.Component<Props<T>> {
13
- componentDidMount(): void;
14
- componentDidUpdate(): void;
15
- private fadeInIndicator;
16
- private isIndicatorShown;
17
- private opacity;
18
- private getTranslateX;
19
- render(): JSX.Element;
20
- }