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.
- package/{LICENSE.md → LICENSE} +0 -0
- package/README.md +5 -36
- package/lib/commonjs/PagerViewAdapter.js +2 -1
- package/lib/commonjs/PagerViewAdapter.js.map +1 -1
- package/lib/commonjs/PanResponderAdapter.js +2 -1
- package/lib/commonjs/PanResponderAdapter.js.map +1 -1
- package/lib/commonjs/SceneMap.js +9 -12
- package/lib/commonjs/SceneMap.js.map +1 -1
- package/lib/commonjs/SceneView.js +54 -101
- package/lib/commonjs/SceneView.js.map +1 -1
- package/lib/commonjs/TabBar.js +358 -325
- package/lib/commonjs/TabBar.js.map +1 -1
- package/lib/commonjs/TabBarIndicator.js +81 -99
- package/lib/commonjs/TabBarIndicator.js.map +1 -1
- package/lib/commonjs/TabBarItem.js +184 -161
- package/lib/commonjs/TabBarItem.js.map +1 -1
- package/lib/commonjs/TabView.js +2 -2
- package/lib/commonjs/TabView.js.map +1 -1
- package/lib/commonjs/index.js +3 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/PagerViewAdapter.js +2 -1
- package/lib/module/PagerViewAdapter.js.map +1 -1
- package/lib/module/PanResponderAdapter.js +3 -2
- package/lib/module/PanResponderAdapter.js.map +1 -1
- package/lib/module/SceneMap.js +9 -14
- package/lib/module/SceneMap.js.map +1 -1
- package/lib/module/SceneView.js +54 -99
- package/lib/module/SceneView.js.map +1 -1
- package/lib/module/TabBar.js +355 -324
- package/lib/module/TabBar.js.map +1 -1
- package/lib/module/TabBarIndicator.js +75 -93
- package/lib/module/TabBarIndicator.js.map +1 -1
- package/lib/module/TabBarItem.js +178 -154
- package/lib/module/TabBarItem.js.map +1 -1
- package/lib/module/TabView.js +2 -2
- package/lib/module/TabView.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/{Pager.android.d.ts → src/Pager.android.d.ts} +0 -0
- package/lib/typescript/{Pager.d.ts → src/Pager.d.ts} +0 -0
- package/lib/typescript/{Pager.ios.d.ts → src/Pager.ios.d.ts} +0 -0
- package/lib/typescript/{PagerViewAdapter.d.ts → src/PagerViewAdapter.d.ts} +1 -1
- package/lib/typescript/{PanResponderAdapter.d.ts → src/PanResponderAdapter.d.ts} +1 -1
- package/lib/typescript/{PlatformPressable.d.ts → src/PlatformPressable.d.ts} +0 -0
- package/lib/typescript/{SceneMap.d.ts → src/SceneMap.d.ts} +5 -3
- package/lib/typescript/src/SceneView.d.ts +15 -0
- package/lib/typescript/src/TabBar.d.ts +42 -0
- package/lib/typescript/src/TabBarIndicator.d.ts +12 -0
- package/lib/typescript/{TabBarItem.d.ts → src/TabBarItem.d.ts} +5 -7
- package/lib/typescript/{TabView.d.ts → src/TabView.d.ts} +1 -1
- package/lib/typescript/{index.d.ts → src/index.d.ts} +7 -7
- package/lib/typescript/{types.d.ts → src/types.d.ts} +0 -0
- package/lib/typescript/{useAnimatedValue.d.ts → src/useAnimatedValue.d.ts} +0 -0
- package/package.json +28 -58
- package/src/PagerViewAdapter.tsx +11 -5
- package/src/PanResponderAdapter.tsx +16 -12
- package/src/SceneMap.tsx +12 -7
- package/src/SceneView.tsx +73 -108
- package/src/TabBar.tsx +506 -401
- package/src/TabBarIndicator.tsx +114 -117
- package/src/TabBarItem.tsx +230 -200
- package/src/TabView.tsx +6 -5
- package/src/index.tsx +7 -12
- package/lib/typescript/SceneView.d.ts +0 -32
- package/lib/typescript/TabBar.d.ts +0 -72
- package/lib/typescript/TabBarIndicator.d.ts +0 -20
package/src/TabBarItem.tsx
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
{
|
|
154
|
+
{inactiveIcon}
|
|
207
155
|
</Animated.View>
|
|
208
156
|
<Animated.View
|
|
209
157
|
style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}
|
|
210
158
|
>
|
|
211
|
-
{
|
|
159
|
+
{activeIcon}
|
|
212
160
|
</Animated.View>
|
|
213
161
|
</View>
|
|
214
162
|
);
|
|
215
163
|
}
|
|
164
|
+
}
|
|
216
165
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
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
|
|
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 {
|
|
14
|
-
|
|
15
|
-
export type {
|
|
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
|
-
}
|