@momo-kits/foundation 0.89.6 → 0.92.1-beta.16
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/Application/BottomTab/BottomTabBar.tsx +479 -0
- package/Application/{BottomTab.tsx → BottomTab/index.tsx} +19 -9
- package/Application/Components.tsx +26 -10
- package/Application/NavigationContainer.tsx +15 -3
- package/Application/StackScreen.tsx +73 -14
- package/Application/types.ts +12 -2
- package/Application/utils.tsx +70 -2
- package/Badge/Badge.tsx +1 -1
- package/Button/index.tsx +54 -14
- package/CheckBox/index.tsx +53 -20
- package/CheckBox/types.ts +4 -0
- package/Consts/colors+spacing+radius.ts +14 -0
- package/IconButton/index.tsx +30 -7
- package/Image/index.tsx +3 -1
- package/Input/Input.tsx +68 -5
- package/Input/InputDropDown.tsx +44 -5
- package/Input/InputMoney.tsx +53 -5
- package/Input/InputOTP.tsx +39 -7
- package/Input/InputSearch.tsx +61 -25
- package/Input/InputTextArea.tsx +23 -0
- package/Input/index.tsx +29 -2
- package/Popup/PopupNotify.tsx +13 -2
- package/Popup/PopupPromotion.tsx +11 -4
- package/Radio/index.tsx +52 -19
- package/Radio/types.ts +5 -0
- package/Switch/index.tsx +39 -14
- package/Switch/types.ts +4 -0
- package/Text/index.tsx +22 -0
- package/Text/styles.ts +1 -1
- package/Text/types.ts +19 -1
- package/Title/index.tsx +148 -102
- package/Title/styles.ts +33 -9
- package/Title/types.ts +12 -48
- package/index.ts +2 -1
- package/package.json +3 -1
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import {BottomTabBarProps} from '@react-navigation/bottom-tabs';
|
|
2
|
+
import {LabelPosition} from '@react-navigation/bottom-tabs/src/types';
|
|
3
|
+
import BottomTabBarHeightCallbackContext from '@react-navigation/bottom-tabs/src/utils/BottomTabBarHeightCallbackContext';
|
|
4
|
+
import BottomTabBarItem from '@react-navigation/bottom-tabs/src/views/BottomTabItem';
|
|
5
|
+
import {
|
|
6
|
+
CommonActions,
|
|
7
|
+
NavigationContext,
|
|
8
|
+
NavigationRouteContext,
|
|
9
|
+
ParamListBase,
|
|
10
|
+
TabNavigationState,
|
|
11
|
+
useLinkBuilder,
|
|
12
|
+
useTheme,
|
|
13
|
+
} from '@react-navigation/native';
|
|
14
|
+
import React, {useCallback} from 'react';
|
|
15
|
+
import {
|
|
16
|
+
Animated,
|
|
17
|
+
LayoutChangeEvent,
|
|
18
|
+
Platform,
|
|
19
|
+
StyleProp,
|
|
20
|
+
StyleSheet,
|
|
21
|
+
TouchableOpacity,
|
|
22
|
+
useWindowDimensions,
|
|
23
|
+
View,
|
|
24
|
+
ViewStyle,
|
|
25
|
+
} from 'react-native';
|
|
26
|
+
import {EdgeInsets, useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
27
|
+
import {Radius} from '../../Consts';
|
|
28
|
+
import {Icon} from '../../Icon';
|
|
29
|
+
import {Text} from '../../Text';
|
|
30
|
+
import {FloatingButtonProps} from '../types';
|
|
31
|
+
import {getAccessibilityID} from '../utils';
|
|
32
|
+
|
|
33
|
+
type Props = BottomTabBarProps & {
|
|
34
|
+
activeTintColor?: string;
|
|
35
|
+
inactiveTintColor?: string;
|
|
36
|
+
floatingButton?: FloatingButtonProps;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type Options = {
|
|
40
|
+
state: TabNavigationState<ParamListBase>;
|
|
41
|
+
layout: {height: number; width: number};
|
|
42
|
+
dimensions: {height: number; width: number};
|
|
43
|
+
tabStyle: StyleProp<ViewStyle>;
|
|
44
|
+
labelPosition: LabelPosition | undefined;
|
|
45
|
+
adaptive: boolean | undefined;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const DEFAULT_MAX_TAB_ITEM_WIDTH = 125;
|
|
49
|
+
const DEFAULT_TABBAR_HEIGHT = 49;
|
|
50
|
+
const COMPACT_TABBAR_HEIGHT = 32;
|
|
51
|
+
|
|
52
|
+
const shouldUseHorizontalLabels = ({
|
|
53
|
+
state,
|
|
54
|
+
layout,
|
|
55
|
+
dimensions,
|
|
56
|
+
adaptive = true,
|
|
57
|
+
labelPosition,
|
|
58
|
+
tabStyle,
|
|
59
|
+
}: Options) => {
|
|
60
|
+
if (labelPosition) {
|
|
61
|
+
return labelPosition === 'beside-icon';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!adaptive) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (layout.width >= 768) {
|
|
69
|
+
// Screen size matches a tablet
|
|
70
|
+
let maxTabItemWidth = DEFAULT_MAX_TAB_ITEM_WIDTH;
|
|
71
|
+
|
|
72
|
+
const flattenedStyle = StyleSheet.flatten(tabStyle);
|
|
73
|
+
|
|
74
|
+
if (flattenedStyle) {
|
|
75
|
+
if (typeof flattenedStyle.width === 'number') {
|
|
76
|
+
maxTabItemWidth = flattenedStyle.width;
|
|
77
|
+
} else if (typeof flattenedStyle.maxWidth === 'number') {
|
|
78
|
+
maxTabItemWidth = flattenedStyle.maxWidth;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return state.routes.length * maxTabItemWidth <= layout.width;
|
|
83
|
+
} else {
|
|
84
|
+
return dimensions.width > dimensions.height;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const getPaddingBottom = (insets: EdgeInsets) =>
|
|
88
|
+
Math.max(insets.bottom - Platform.select({ios: 4, default: 0}), 0);
|
|
89
|
+
|
|
90
|
+
export const getTabBarHeight = ({
|
|
91
|
+
dimensions,
|
|
92
|
+
insets,
|
|
93
|
+
style,
|
|
94
|
+
...rest
|
|
95
|
+
}: Options & {
|
|
96
|
+
insets: EdgeInsets;
|
|
97
|
+
style: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
98
|
+
}) => {
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
const customHeight = StyleSheet.flatten(style)?.height;
|
|
101
|
+
|
|
102
|
+
if (typeof customHeight === 'number') {
|
|
103
|
+
return customHeight;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const isLandscape = dimensions.width > dimensions.height;
|
|
107
|
+
const horizontalLabels = shouldUseHorizontalLabels({dimensions, ...rest});
|
|
108
|
+
const paddingBottom = getPaddingBottom(insets);
|
|
109
|
+
|
|
110
|
+
if (
|
|
111
|
+
Platform.OS === 'ios' &&
|
|
112
|
+
!Platform.isPad &&
|
|
113
|
+
isLandscape &&
|
|
114
|
+
horizontalLabels
|
|
115
|
+
) {
|
|
116
|
+
return COMPACT_TABBAR_HEIGHT + paddingBottom;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return DEFAULT_TABBAR_HEIGHT + paddingBottom;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default function BottomTabBar({
|
|
123
|
+
state,
|
|
124
|
+
navigation,
|
|
125
|
+
descriptors,
|
|
126
|
+
activeBackgroundColor,
|
|
127
|
+
activeTintColor,
|
|
128
|
+
adaptive,
|
|
129
|
+
allowFontScaling,
|
|
130
|
+
inactiveBackgroundColor,
|
|
131
|
+
inactiveTintColor,
|
|
132
|
+
keyboardHidesTabBar = false,
|
|
133
|
+
labelPosition,
|
|
134
|
+
labelStyle,
|
|
135
|
+
iconStyle,
|
|
136
|
+
safeAreaInsets,
|
|
137
|
+
showLabel,
|
|
138
|
+
style,
|
|
139
|
+
tabStyle,
|
|
140
|
+
floatingButton,
|
|
141
|
+
}: Props) {
|
|
142
|
+
const {routes} = state;
|
|
143
|
+
const dimensions = useWindowDimensions();
|
|
144
|
+
const isFloating = floatingButton?.icon && state.routes.length == 4;
|
|
145
|
+
const itemWidth = isFloating
|
|
146
|
+
? dimensions.width / 5
|
|
147
|
+
: dimensions.width / state.routes.length;
|
|
148
|
+
|
|
149
|
+
const [layout, setLayout] = React.useState({
|
|
150
|
+
height: 0,
|
|
151
|
+
width: dimensions.width,
|
|
152
|
+
});
|
|
153
|
+
const buildLink = useLinkBuilder();
|
|
154
|
+
const {colors} = useTheme();
|
|
155
|
+
|
|
156
|
+
const hasHorizontalLabels = shouldUseHorizontalLabels({
|
|
157
|
+
state,
|
|
158
|
+
dimensions,
|
|
159
|
+
layout,
|
|
160
|
+
adaptive,
|
|
161
|
+
labelPosition,
|
|
162
|
+
tabStyle,
|
|
163
|
+
});
|
|
164
|
+
const focusedRoute = state.routes[state.index] as any;
|
|
165
|
+
const focusedDescriptor = descriptors[focusedRoute?.key] as any;
|
|
166
|
+
const focusedOptions = focusedDescriptor?.options;
|
|
167
|
+
const shouldShowTabBar =
|
|
168
|
+
focusedOptions?.tabBarVisible !== false && !keyboardHidesTabBar;
|
|
169
|
+
const [visible] = React.useState(
|
|
170
|
+
() => new Animated.Value(shouldShowTabBar ? 1 : 0),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const indicatorAnimated = React.useRef(new Animated.Value(0)).current;
|
|
174
|
+
|
|
175
|
+
const visibilityAnimationConfigRef = React.useRef(
|
|
176
|
+
focusedOptions?.tabBarVisibilityAnimationConfig,
|
|
177
|
+
);
|
|
178
|
+
const onHeightChange = React.useContext(BottomTabBarHeightCallbackContext);
|
|
179
|
+
const [isTabBarHidden, setIsTabBarHidden] = React.useState(!shouldShowTabBar);
|
|
180
|
+
React.useEffect(() => {
|
|
181
|
+
visibilityAnimationConfigRef.current =
|
|
182
|
+
focusedOptions?.tabBarVisibilityAnimationConfig;
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const handleLayout = (e: LayoutChangeEvent) => {
|
|
186
|
+
const {height, width} = e.nativeEvent.layout;
|
|
187
|
+
|
|
188
|
+
onHeightChange?.(height);
|
|
189
|
+
|
|
190
|
+
setLayout(layout => {
|
|
191
|
+
if (height === layout.height && width === layout.width) {
|
|
192
|
+
return layout;
|
|
193
|
+
} else {
|
|
194
|
+
return {
|
|
195
|
+
height,
|
|
196
|
+
width,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
React.useEffect(() => {
|
|
203
|
+
const visibilityAnimationConfig = visibilityAnimationConfigRef.current;
|
|
204
|
+
|
|
205
|
+
if (shouldShowTabBar) {
|
|
206
|
+
const animation =
|
|
207
|
+
visibilityAnimationConfig?.show?.animation === 'spring'
|
|
208
|
+
? Animated.spring
|
|
209
|
+
: Animated.timing;
|
|
210
|
+
|
|
211
|
+
animation(visible, {
|
|
212
|
+
toValue: 1,
|
|
213
|
+
useNativeDriver: true,
|
|
214
|
+
duration: 250,
|
|
215
|
+
...visibilityAnimationConfig?.show?.config,
|
|
216
|
+
}).start(({finished}) => {
|
|
217
|
+
if (finished) {
|
|
218
|
+
setIsTabBarHidden(false);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
setIsTabBarHidden(true);
|
|
223
|
+
|
|
224
|
+
const animation =
|
|
225
|
+
visibilityAnimationConfig?.hide?.animation === 'spring'
|
|
226
|
+
? Animated.spring
|
|
227
|
+
: Animated.timing;
|
|
228
|
+
|
|
229
|
+
animation(visible, {
|
|
230
|
+
toValue: 0,
|
|
231
|
+
useNativeDriver: true,
|
|
232
|
+
duration: 200,
|
|
233
|
+
...visibilityAnimationConfig?.hide?.config,
|
|
234
|
+
}).start();
|
|
235
|
+
}
|
|
236
|
+
}, [visible, shouldShowTabBar]);
|
|
237
|
+
const defaultInsets = useSafeAreaInsets();
|
|
238
|
+
|
|
239
|
+
const insets = {
|
|
240
|
+
top: safeAreaInsets?.top ?? defaultInsets.top,
|
|
241
|
+
right: safeAreaInsets?.right ?? defaultInsets.right,
|
|
242
|
+
bottom: safeAreaInsets?.bottom ?? defaultInsets.bottom,
|
|
243
|
+
left: safeAreaInsets?.left ?? defaultInsets.left,
|
|
244
|
+
};
|
|
245
|
+
const paddingBottom = getPaddingBottom(insets);
|
|
246
|
+
|
|
247
|
+
const leftArr = routes.slice(0, 2);
|
|
248
|
+
const rightArr = routes.slice(2, routes.length);
|
|
249
|
+
const focusedTab = state?.routes[state.index]?.name || routes[0]?.params;
|
|
250
|
+
|
|
251
|
+
const renderTabItem = useCallback(
|
|
252
|
+
(data: any[]) => {
|
|
253
|
+
return data?.map((route, index) => {
|
|
254
|
+
const focused = route.params.name === focusedTab;
|
|
255
|
+
const {options} = descriptors[route?.key] as any;
|
|
256
|
+
const onPress = () => {
|
|
257
|
+
const event = navigation.emit({
|
|
258
|
+
type: 'tabPress',
|
|
259
|
+
target: route.key,
|
|
260
|
+
canPreventDefault: true,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
if (!focused && !event.defaultPrevented) {
|
|
264
|
+
navigation.dispatch({
|
|
265
|
+
...CommonActions.navigate(route.name),
|
|
266
|
+
target: state.key,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const onLongPress = () => {
|
|
272
|
+
navigation.emit({
|
|
273
|
+
type: 'tabLongPress',
|
|
274
|
+
target: route.key,
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const label =
|
|
279
|
+
options.tabBarLabel !== undefined
|
|
280
|
+
? options.tabBarLabel
|
|
281
|
+
: options.title !== undefined
|
|
282
|
+
? options.title
|
|
283
|
+
: route.name;
|
|
284
|
+
|
|
285
|
+
const accessibilityLabel =
|
|
286
|
+
options.tabBarAccessibilityLabel !== undefined
|
|
287
|
+
? options.tabBarAccessibilityLabel
|
|
288
|
+
: typeof label === 'string'
|
|
289
|
+
? `${label}, tab, ${index + 1} of ${routes.length}`
|
|
290
|
+
: undefined;
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<NavigationContext.Provider
|
|
294
|
+
key={route.key}
|
|
295
|
+
value={(descriptors as any)[route.key].navigation}>
|
|
296
|
+
<NavigationRouteContext.Provider value={route}>
|
|
297
|
+
<BottomTabBarItem
|
|
298
|
+
route={route}
|
|
299
|
+
focused={focused}
|
|
300
|
+
horizontal={hasHorizontalLabels}
|
|
301
|
+
onPress={onPress}
|
|
302
|
+
onLongPress={onLongPress}
|
|
303
|
+
accessibilityLabel={accessibilityLabel}
|
|
304
|
+
to={buildLink(route.name, route.params)}
|
|
305
|
+
testID={options.tabBarTestID}
|
|
306
|
+
allowFontScaling={allowFontScaling}
|
|
307
|
+
activeTintColor={activeTintColor}
|
|
308
|
+
inactiveTintColor={inactiveTintColor}
|
|
309
|
+
activeBackgroundColor={activeBackgroundColor}
|
|
310
|
+
inactiveBackgroundColor={inactiveBackgroundColor}
|
|
311
|
+
button={options.tabBarButton}
|
|
312
|
+
icon={options.tabBarIcon}
|
|
313
|
+
badge={options.tabBarBadge}
|
|
314
|
+
badgeStyle={options.tabBarBadgeStyle}
|
|
315
|
+
label={label}
|
|
316
|
+
showLabel={showLabel}
|
|
317
|
+
labelStyle={labelStyle}
|
|
318
|
+
iconStyle={iconStyle}
|
|
319
|
+
style={tabStyle}
|
|
320
|
+
{...getAccessibilityID(`btn_tabbar_${route.name}`)}
|
|
321
|
+
/>
|
|
322
|
+
</NavigationRouteContext.Provider>
|
|
323
|
+
</NavigationContext.Provider>
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
},
|
|
327
|
+
[JSON.stringify(routes), state, descriptors, focusedTab],
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
const renderCenterComponent = useCallback(() => {
|
|
331
|
+
const renderFloatingButton = () => {
|
|
332
|
+
if (typeof floatingButton?.icon == 'string') {
|
|
333
|
+
return <Icon source={floatingButton?.icon} size={32} color={'white'} />;
|
|
334
|
+
} else if (floatingButton?.icon) {
|
|
335
|
+
return floatingButton?.icon;
|
|
336
|
+
} else {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
if (floatingButton?.icon && state.routes.length !== 4) {
|
|
341
|
+
console.warn(
|
|
342
|
+
"Can't render floating button with icon when routes length is not 4",
|
|
343
|
+
);
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
return (
|
|
347
|
+
<View style={{flex: 1}}>
|
|
348
|
+
<TouchableOpacity
|
|
349
|
+
onPress={floatingButton?.onPress}
|
|
350
|
+
style={styles.floatingContainer}>
|
|
351
|
+
<View
|
|
352
|
+
style={{
|
|
353
|
+
...styles.floatingContent,
|
|
354
|
+
backgroundColor: activeTintColor ?? colors.primary,
|
|
355
|
+
}}>
|
|
356
|
+
{renderFloatingButton()}
|
|
357
|
+
</View>
|
|
358
|
+
<View
|
|
359
|
+
style={{
|
|
360
|
+
top: -6,
|
|
361
|
+
backgroundColor: activeTintColor ?? colors.primary,
|
|
362
|
+
borderRadius: Radius.XL,
|
|
363
|
+
paddingHorizontal: 6,
|
|
364
|
+
}}>
|
|
365
|
+
<Text
|
|
366
|
+
numberOfLines={1}
|
|
367
|
+
typography={'description_xs_regular'}
|
|
368
|
+
color={'white'}>
|
|
369
|
+
{floatingButton?.label}
|
|
370
|
+
</Text>
|
|
371
|
+
</View>
|
|
372
|
+
</TouchableOpacity>
|
|
373
|
+
</View>
|
|
374
|
+
);
|
|
375
|
+
}, [floatingButton]);
|
|
376
|
+
|
|
377
|
+
React.useEffect(() => {
|
|
378
|
+
Animated.timing(indicatorAnimated, {
|
|
379
|
+
toValue:
|
|
380
|
+
isFloating && state.index > 1
|
|
381
|
+
? itemWidth * (state.index + 1)
|
|
382
|
+
: itemWidth * state.index,
|
|
383
|
+
useNativeDriver: false,
|
|
384
|
+
duration: 200,
|
|
385
|
+
}).start();
|
|
386
|
+
}, [state.index, itemWidth, indicatorAnimated, isFloating]);
|
|
387
|
+
|
|
388
|
+
return (
|
|
389
|
+
<Animated.View
|
|
390
|
+
style={[
|
|
391
|
+
styles.tabBar,
|
|
392
|
+
{
|
|
393
|
+
backgroundColor: colors.card,
|
|
394
|
+
borderTopColor: colors.border,
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
transform: [
|
|
398
|
+
{
|
|
399
|
+
translateY: visible.interpolate({
|
|
400
|
+
inputRange: [0, 1],
|
|
401
|
+
outputRange: [
|
|
402
|
+
layout.height + paddingBottom + StyleSheet.hairlineWidth,
|
|
403
|
+
0,
|
|
404
|
+
],
|
|
405
|
+
}),
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
// Absolutely position the tab bar so that the content is below it
|
|
409
|
+
// This is needed to avoid gap at bottom when the tab bar is hidden
|
|
410
|
+
position: isTabBarHidden ? 'absolute' : (null as any),
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
paddingBottom: paddingBottom - 0,
|
|
414
|
+
paddingHorizontal: Math.max(insets.left, insets.right),
|
|
415
|
+
},
|
|
416
|
+
style,
|
|
417
|
+
]}
|
|
418
|
+
pointerEvents={isTabBarHidden ? 'none' : 'auto'}
|
|
419
|
+
onLayout={handleLayout}>
|
|
420
|
+
<View style={styles.content}>
|
|
421
|
+
{isFloating && floatingButton?.container}
|
|
422
|
+
<Animated.View
|
|
423
|
+
style={{
|
|
424
|
+
width: itemWidth,
|
|
425
|
+
position: 'absolute',
|
|
426
|
+
top: 0,
|
|
427
|
+
transform: [{translateX: indicatorAnimated}],
|
|
428
|
+
}}>
|
|
429
|
+
<View
|
|
430
|
+
style={[
|
|
431
|
+
styles.indicator,
|
|
432
|
+
{backgroundColor: activeTintColor ?? colors.primary},
|
|
433
|
+
]}
|
|
434
|
+
/>
|
|
435
|
+
</Animated.View>
|
|
436
|
+
{isFloating ? renderTabItem(leftArr) : renderTabItem(routes)}
|
|
437
|
+
{isFloating && renderCenterComponent()}
|
|
438
|
+
{isFloating && renderTabItem(rightArr)}
|
|
439
|
+
</View>
|
|
440
|
+
</Animated.View>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const styles = StyleSheet.create({
|
|
445
|
+
content: {
|
|
446
|
+
flex: 1,
|
|
447
|
+
flexDirection: 'row',
|
|
448
|
+
},
|
|
449
|
+
tabBar: {
|
|
450
|
+
left: 0,
|
|
451
|
+
right: 0,
|
|
452
|
+
bottom: 0,
|
|
453
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
454
|
+
elevation: 8,
|
|
455
|
+
},
|
|
456
|
+
floatingContainer: {
|
|
457
|
+
position: 'absolute',
|
|
458
|
+
alignItems: 'center',
|
|
459
|
+
left: 0,
|
|
460
|
+
right: 0,
|
|
461
|
+
bottom: Platform.OS === 'ios' ? -6 : 0,
|
|
462
|
+
},
|
|
463
|
+
floatingContent: {
|
|
464
|
+
alignItems: 'center',
|
|
465
|
+
justifyContent: 'center',
|
|
466
|
+
height: 48,
|
|
467
|
+
width: 48,
|
|
468
|
+
|
|
469
|
+
borderRadius: 100,
|
|
470
|
+
top: -12,
|
|
471
|
+
},
|
|
472
|
+
indicator: {
|
|
473
|
+
height: 2,
|
|
474
|
+
width: 44,
|
|
475
|
+
alignSelf: 'center',
|
|
476
|
+
borderBottomLeftRadius: 1,
|
|
477
|
+
borderBottomRightRadius: 1,
|
|
478
|
+
},
|
|
479
|
+
});
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import React, {useContext, useEffect} from 'react';
|
|
2
|
-
import {Platform} from 'react-native';
|
|
3
|
-
import {BottomTabProps, NavigationScreenProps} from './types';
|
|
4
1
|
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
|
2
|
+
import {NavigationContainer} from '@react-navigation/native';
|
|
5
3
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
4
|
+
import React, {useContext, useEffect} from 'react';
|
|
5
|
+
import {Platform} from 'react-native';
|
|
6
6
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
7
|
+
import {Icon} from '../../Icon';
|
|
8
|
+
import {Text} from '../../Text';
|
|
9
|
+
import {ApplicationContext} from '../index';
|
|
10
|
+
import StackScreen from '../StackScreen';
|
|
11
|
+
import {BottomTabProps, NavigationScreenProps} from '../types';
|
|
12
|
+
import {getAccessibilityID, getStackOptions} from '../utils';
|
|
13
|
+
import BottomTabBar from './BottomTabBar';
|
|
13
14
|
|
|
14
15
|
const Tab = createBottomTabNavigator();
|
|
15
16
|
const Stack = createStackNavigator();
|
|
@@ -40,12 +41,14 @@ const TabScreen: React.FC<NavigationScreenProps> = ({route}) => {
|
|
|
40
41
|
</NavigationContainer>
|
|
41
42
|
);
|
|
42
43
|
};
|
|
44
|
+
|
|
43
45
|
const BottomTab: React.FC<BottomTabProps> = ({
|
|
44
46
|
nested,
|
|
45
47
|
tabs,
|
|
46
48
|
listeners,
|
|
47
49
|
navigation,
|
|
48
50
|
initialRouteName,
|
|
51
|
+
floatingButton,
|
|
49
52
|
}) => {
|
|
50
53
|
const {theme} = useContext(ApplicationContext);
|
|
51
54
|
const insets = useSafeAreaInsets();
|
|
@@ -62,6 +65,13 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
62
65
|
<Tab.Navigator
|
|
63
66
|
initialRouteName={initialRouteName}
|
|
64
67
|
backBehavior={'firstRoute'}
|
|
68
|
+
tabBar={props => (
|
|
69
|
+
<BottomTabBar
|
|
70
|
+
{...getAccessibilityID('tbr_main_bottom')}
|
|
71
|
+
{...props}
|
|
72
|
+
floatingButton={floatingButton}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
65
75
|
tabBarOptions={{
|
|
66
76
|
style: {
|
|
67
77
|
height: 68 + Math.min(insets.bottom, 21),
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
View,
|
|
16
16
|
ViewStyle,
|
|
17
17
|
} from 'react-native';
|
|
18
|
-
import {ApplicationContext
|
|
18
|
+
import {ApplicationContext} from './index';
|
|
19
19
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
20
20
|
import {Image} from '../Image';
|
|
21
21
|
import {
|
|
@@ -29,6 +29,11 @@ import {scaleSize, Text} from '../Text';
|
|
|
29
29
|
import {Icon} from '../Icon';
|
|
30
30
|
import {PopupNotify} from '../Popup';
|
|
31
31
|
import {Badge, BadgeDot} from '../Badge';
|
|
32
|
+
import {getAccessibilityID} from './utils';
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
MiniAppContext,
|
|
36
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
32
37
|
|
|
33
38
|
const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
34
39
|
icon,
|
|
@@ -37,6 +42,7 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
37
42
|
useBorder = true,
|
|
38
43
|
badgeType,
|
|
39
44
|
badgeValue,
|
|
45
|
+
accessibilityID = '',
|
|
40
46
|
}) => {
|
|
41
47
|
const {theme} = useContext(ApplicationContext);
|
|
42
48
|
let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
|
|
@@ -64,7 +70,9 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
64
70
|
}, [badgeType, badgeValue]);
|
|
65
71
|
|
|
66
72
|
return (
|
|
67
|
-
<View
|
|
73
|
+
<View
|
|
74
|
+
{...getAccessibilityID(accessibilityID)}
|
|
75
|
+
style={{width: scaleSize(28)}}>
|
|
68
76
|
<TouchableOpacity
|
|
69
77
|
style={[styles.navigationButton, buttonStyle]}
|
|
70
78
|
onPress={onPress}>
|
|
@@ -90,6 +98,7 @@ const HeaderTitle: React.FC<any> = props => {
|
|
|
90
98
|
return (
|
|
91
99
|
<Animated.Text
|
|
92
100
|
{...props}
|
|
101
|
+
{...getAccessibilityID('title_navigation_header')}
|
|
93
102
|
style={[
|
|
94
103
|
styles.title,
|
|
95
104
|
{fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
|
|
@@ -104,7 +113,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
104
113
|
onPressLeftHeader,
|
|
105
114
|
useBorder,
|
|
106
115
|
}) => {
|
|
107
|
-
const context = useContext(MiniAppContext);
|
|
116
|
+
const context = useContext<any>(MiniAppContext);
|
|
108
117
|
const {navigator} = useContext(ApplicationContext);
|
|
109
118
|
|
|
110
119
|
useEffect(() => {
|
|
@@ -128,7 +137,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
128
137
|
icon_name: 'back',
|
|
129
138
|
};
|
|
130
139
|
navigator?.maxApi?.showToastDebug?.({
|
|
131
|
-
appId: context.appId
|
|
140
|
+
appId: `auto - ${context.appId}`,
|
|
132
141
|
message: 'service_icon_clicked',
|
|
133
142
|
params,
|
|
134
143
|
});
|
|
@@ -166,10 +175,10 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
166
175
|
}
|
|
167
176
|
return true;
|
|
168
177
|
};
|
|
169
|
-
|
|
170
178
|
return (
|
|
171
179
|
<View style={styles.headerLeft}>
|
|
172
180
|
<NavigationButton
|
|
181
|
+
accessibilityID="btn_navigation_back"
|
|
173
182
|
icon="ic_back"
|
|
174
183
|
tintColor={tintColor}
|
|
175
184
|
onPress={goBackSafe}
|
|
@@ -243,7 +252,10 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
243
252
|
)}
|
|
244
253
|
</View>
|
|
245
254
|
<View style={[Styles.flex, {paddingHorizontal: 8}]}>
|
|
246
|
-
<Text
|
|
255
|
+
<Text
|
|
256
|
+
{...getAccessibilityID('title_navigation_header')}
|
|
257
|
+
typography="header_default_bold"
|
|
258
|
+
color={tintColor}>
|
|
247
259
|
{title}
|
|
248
260
|
</Text>
|
|
249
261
|
<Text typography="description_default_regular" color={tintColor}>
|
|
@@ -293,7 +305,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
293
305
|
preventClose,
|
|
294
306
|
}) => {
|
|
295
307
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
296
|
-
const miniContext = useContext(MiniAppContext);
|
|
308
|
+
const miniContext = useContext<any>(MiniAppContext);
|
|
297
309
|
const [toolConfig, setToolConfig] = useState<any>();
|
|
298
310
|
const {onAction} = toolConfig ?? {};
|
|
299
311
|
|
|
@@ -369,6 +381,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
369
381
|
if (pinTool)
|
|
370
382
|
return (
|
|
371
383
|
<NavigationButton
|
|
384
|
+
accessibilityID="btn_navigation_pin"
|
|
372
385
|
icon={pinTool.icon as string}
|
|
373
386
|
tintColor={tintColor}
|
|
374
387
|
badgeValue={badgeValue}
|
|
@@ -386,7 +399,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
386
399
|
/>
|
|
387
400
|
);
|
|
388
401
|
};
|
|
389
|
-
|
|
390
402
|
if (toolConfig) {
|
|
391
403
|
return (
|
|
392
404
|
<View style={styles.headerRightButton}>
|
|
@@ -399,11 +411,15 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
399
411
|
borderWidth: backgroundColor ? 0.5 : 0,
|
|
400
412
|
},
|
|
401
413
|
]}>
|
|
402
|
-
<TouchableOpacity
|
|
414
|
+
<TouchableOpacity
|
|
415
|
+
{...getAccessibilityID('btn_navigation_more')}
|
|
416
|
+
onPress={onMore}>
|
|
403
417
|
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
404
418
|
</TouchableOpacity>
|
|
405
419
|
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
406
|
-
<TouchableOpacity
|
|
420
|
+
<TouchableOpacity
|
|
421
|
+
{...getAccessibilityID('btn_navigation_close')}
|
|
422
|
+
onPress={onClose}>
|
|
407
423
|
<Icon
|
|
408
424
|
color={tintColor}
|
|
409
425
|
source="16_navigation_close_circle"
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
NavigationContainer as ReactNavigationContainer,
|
|
5
5
|
NavigationContainerRef,
|
|
6
6
|
} from '@react-navigation/native';
|
|
7
|
+
import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
|
|
7
8
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
8
9
|
import {DeviceEventEmitter} from 'react-native';
|
|
9
10
|
import StackScreen from './StackScreen';
|
|
@@ -11,9 +12,19 @@ import ModalScreen from './ModalScreen';
|
|
|
11
12
|
import Navigator from './Navigator';
|
|
12
13
|
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
13
14
|
import {LocalizationObject, NavigationContainerProps} from './types';
|
|
14
|
-
import {ApplicationContext
|
|
15
|
+
import {ApplicationContext} from './index';
|
|
15
16
|
import kitLocalization from '../Assets/language.json';
|
|
16
17
|
|
|
18
|
+
const {
|
|
19
|
+
MiniAppContext,
|
|
20
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* link for deprecated
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
console.log(typeof BottomSheetModalProvider);
|
|
27
|
+
|
|
17
28
|
const Stack = createStackNavigator();
|
|
18
29
|
|
|
19
30
|
const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
@@ -22,8 +33,9 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
22
33
|
options,
|
|
23
34
|
maxApi,
|
|
24
35
|
localization,
|
|
36
|
+
initialParams,
|
|
25
37
|
}) => {
|
|
26
|
-
const context = useContext(MiniAppContext);
|
|
38
|
+
const context = useContext<any>(MiniAppContext);
|
|
27
39
|
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
28
40
|
const isReady = useRef(false);
|
|
29
41
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
@@ -96,7 +108,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
96
108
|
<Stack.Screen
|
|
97
109
|
name="Stack"
|
|
98
110
|
component={StackScreen}
|
|
99
|
-
initialParams={{screen}}
|
|
111
|
+
initialParams={{screen, initialParams}}
|
|
100
112
|
options={{...getStackOptions(), ...options}}
|
|
101
113
|
/>
|
|
102
114
|
<Stack.Screen
|