@momo-kits/foundation 0.76.1-beta.2 → 0.77.1-optimize.3

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 (100) hide show
  1. package/Application/BottomTab/BottomTabBar.tsx +478 -0
  2. package/Application/BottomTab/index.tsx +134 -0
  3. package/Application/Components.tsx +339 -161
  4. package/Application/ModalScreen.tsx +113 -99
  5. package/Application/Navigation.ts +22 -16
  6. package/Application/NavigationContainer.tsx +99 -48
  7. package/Application/Navigator.ts +110 -41
  8. package/Application/StackScreen.tsx +129 -8
  9. package/Application/index.ts +23 -4
  10. package/Application/types.ts +84 -33
  11. package/Application/utils.tsx +71 -49
  12. package/Assets/DotAnimation.json +256 -0
  13. package/Assets/SpinnerAnimation.json +1027 -0
  14. package/Assets/icon.json +83 -5
  15. package/Assets/icon_bank.json +506 -0
  16. package/Assets/language.json +202 -0
  17. package/Badge/Badge.tsx +56 -0
  18. package/Badge/BadgeDot.tsx +11 -0
  19. package/Badge/BadgeRibbon.tsx +125 -0
  20. package/Badge/Shape.tsx +29 -0
  21. package/Badge/index.tsx +7 -0
  22. package/Badge/styles.ts +58 -0
  23. package/Badge/types.ts +63 -0
  24. package/Button/index.tsx +90 -39
  25. package/Button/styles.ts +19 -0
  26. package/CheckBox/index.tsx +58 -43
  27. package/CheckBox/styles.ts +1 -1
  28. package/CheckBox/types.ts +6 -4
  29. package/Consts/colors+spacing+radius.ts +18 -0
  30. package/Consts/styles.ts +0 -26
  31. package/Consts/theme.ts +4 -0
  32. package/Divider/index.tsx +2 -0
  33. package/Icon/index.tsx +14 -9
  34. package/Icon/types.ts +4 -3
  35. package/IconButton/index.tsx +24 -15
  36. package/Image/index.tsx +63 -47
  37. package/Image/styles.ts +1 -9
  38. package/Image/types.ts +5 -1
  39. package/Input/Input.tsx +227 -116
  40. package/Input/InputDropDown.tsx +132 -0
  41. package/Input/InputMoney.tsx +174 -111
  42. package/Input/InputOTP.tsx +257 -0
  43. package/Input/InputSearch.tsx +160 -132
  44. package/Input/InputTextArea.tsx +150 -123
  45. package/Input/common.tsx +42 -17
  46. package/Input/index.tsx +204 -18
  47. package/Input/styles.ts +44 -7
  48. package/Input/utils.ts +2 -2
  49. package/Layout/Card.tsx +67 -29
  50. package/Layout/FloatingButton.tsx +149 -0
  51. package/Layout/GridSystem.tsx +31 -21
  52. package/Layout/Item.tsx +21 -25
  53. package/Layout/ItemList.tsx +55 -0
  54. package/Layout/ItemSectionList.tsx +39 -0
  55. package/Layout/Screen.tsx +343 -153
  56. package/Layout/Section.tsx +66 -34
  57. package/Layout/index.ts +13 -3
  58. package/Layout/styles.ts +101 -0
  59. package/Layout/types.ts +1 -39
  60. package/Layout/utils.ts +27 -52
  61. package/Loader/DotLoader.tsx +37 -0
  62. package/Loader/Loader.tsx +13 -0
  63. package/Loader/ProgressBar.tsx +44 -0
  64. package/Loader/Spinner.tsx +29 -0
  65. package/Loader/index.tsx +4 -0
  66. package/Loader/styles.ts +10 -0
  67. package/Loader/types.ts +35 -0
  68. package/Loader/utils.ts +25 -0
  69. package/Pagination/PaginationDot.tsx +7 -2
  70. package/Pagination/PaginationNumber.tsx +8 -6
  71. package/Pagination/PaginationScroll.tsx +0 -1
  72. package/Pagination/PaginationWhiteDot.tsx +8 -5
  73. package/Pagination/styles.ts +3 -0
  74. package/Pagination/types.ts +2 -0
  75. package/Popup/PopupNotify.tsx +108 -46
  76. package/Popup/PopupPromotion.tsx +63 -22
  77. package/Popup/types.ts +15 -4
  78. package/Radio/index.tsx +35 -21
  79. package/Radio/types.ts +7 -5
  80. package/Skeleton/index.tsx +1 -1
  81. package/Skeleton/types.ts +3 -0
  82. package/Switch/index.tsx +35 -24
  83. package/Switch/types.ts +5 -3
  84. package/Tag/index.tsx +2 -4
  85. package/Text/index.tsx +27 -22
  86. package/Text/styles.ts +38 -0
  87. package/Text/types.ts +25 -13
  88. package/Text/utils.ts +1 -1
  89. package/Title/index.tsx +186 -0
  90. package/Title/styles.ts +79 -0
  91. package/Title/types.ts +20 -0
  92. package/code-scanner.js +143 -0
  93. package/index.ts +6 -0
  94. package/migrate_typo.js +56 -0
  95. package/package.json +14 -9
  96. package/tsconfig.json +24 -0
  97. package/verify.js +47 -0
  98. package/Application/BottomTab.tsx +0 -52
  99. package/Application/NavigationButton.tsx +0 -54
  100. package/Assets/header-background.png +0 -0
@@ -0,0 +1,478 @@
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
+
32
+ type Props = BottomTabBarProps & {
33
+ activeTintColor?: string;
34
+ inactiveTintColor?: string;
35
+ floatingButton?: FloatingButtonProps;
36
+ accessibilityLabel?: string;
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
+ />
321
+ </NavigationRouteContext.Provider>
322
+ </NavigationContext.Provider>
323
+ );
324
+ });
325
+ },
326
+ [JSON.stringify(routes), state, descriptors, focusedTab],
327
+ );
328
+
329
+ const renderCenterComponent = useCallback(() => {
330
+ const renderFloatingButton = () => {
331
+ if (typeof floatingButton?.icon == 'string') {
332
+ return <Icon source={floatingButton?.icon} size={32} color={'white'} />;
333
+ } else if (floatingButton?.icon) {
334
+ return floatingButton?.icon;
335
+ } else {
336
+ return null;
337
+ }
338
+ };
339
+ if (floatingButton?.icon && state.routes.length !== 4) {
340
+ console.warn(
341
+ "Can't render floating button with icon when routes length is not 4",
342
+ );
343
+ return null;
344
+ }
345
+ return (
346
+ <View style={{flex: 1}}>
347
+ <TouchableOpacity
348
+ onPress={floatingButton?.onPress}
349
+ style={styles.floatingContainer}>
350
+ <View
351
+ style={{
352
+ ...styles.floatingContent,
353
+ backgroundColor: activeTintColor ?? colors.primary,
354
+ }}>
355
+ {renderFloatingButton()}
356
+ </View>
357
+ <View
358
+ style={{
359
+ top: -6,
360
+ backgroundColor: activeTintColor ?? colors.primary,
361
+ borderRadius: Radius.XL,
362
+ paddingHorizontal: 6,
363
+ }}>
364
+ <Text
365
+ numberOfLines={1}
366
+ typography={'description_xs_regular'}
367
+ color={'white'}>
368
+ {floatingButton?.label}
369
+ </Text>
370
+ </View>
371
+ </TouchableOpacity>
372
+ </View>
373
+ );
374
+ }, [floatingButton]);
375
+
376
+ React.useEffect(() => {
377
+ Animated.timing(indicatorAnimated, {
378
+ toValue:
379
+ isFloating && state.index > 1
380
+ ? itemWidth * (state.index + 1)
381
+ : itemWidth * state.index,
382
+ useNativeDriver: false,
383
+ duration: 200,
384
+ }).start();
385
+ }, [state.index, itemWidth, indicatorAnimated, isFloating]);
386
+
387
+ return (
388
+ <Animated.View
389
+ style={[
390
+ styles.tabBar,
391
+ {
392
+ backgroundColor: colors.card,
393
+ borderTopColor: colors.border,
394
+ },
395
+ {
396
+ transform: [
397
+ {
398
+ translateY: visible.interpolate({
399
+ inputRange: [0, 1],
400
+ outputRange: [
401
+ layout.height + paddingBottom + StyleSheet.hairlineWidth,
402
+ 0,
403
+ ],
404
+ }),
405
+ },
406
+ ],
407
+ // Absolutely position the tab bar so that the content is below it
408
+ // This is needed to avoid gap at bottom when the tab bar is hidden
409
+ position: isTabBarHidden ? 'absolute' : (null as any),
410
+ },
411
+ {
412
+ paddingBottom: paddingBottom - 0,
413
+ paddingHorizontal: Math.max(insets.left, insets.right),
414
+ },
415
+ style,
416
+ ]}
417
+ pointerEvents={isTabBarHidden ? 'none' : 'auto'}
418
+ onLayout={handleLayout}>
419
+ <View style={styles.content}>
420
+ {isFloating && floatingButton?.container}
421
+ <Animated.View
422
+ style={{
423
+ width: itemWidth,
424
+ position: 'absolute',
425
+ top: 0,
426
+ transform: [{translateX: indicatorAnimated}],
427
+ }}>
428
+ <View
429
+ style={[
430
+ styles.indicator,
431
+ {backgroundColor: activeTintColor ?? colors.primary},
432
+ ]}
433
+ />
434
+ </Animated.View>
435
+ {isFloating ? renderTabItem(leftArr) : renderTabItem(routes)}
436
+ {isFloating && renderCenterComponent()}
437
+ {isFloating && renderTabItem(rightArr)}
438
+ </View>
439
+ </Animated.View>
440
+ );
441
+ }
442
+
443
+ const styles = StyleSheet.create({
444
+ content: {
445
+ flex: 1,
446
+ flexDirection: 'row',
447
+ },
448
+ tabBar: {
449
+ left: 0,
450
+ right: 0,
451
+ bottom: 0,
452
+ borderTopWidth: StyleSheet.hairlineWidth,
453
+ elevation: 8,
454
+ },
455
+ floatingContainer: {
456
+ position: 'absolute',
457
+ alignItems: 'center',
458
+ left: 0,
459
+ right: 0,
460
+ bottom: Platform.OS === 'ios' ? -6 : 0,
461
+ },
462
+ floatingContent: {
463
+ alignItems: 'center',
464
+ justifyContent: 'center',
465
+ height: 48,
466
+ width: 48,
467
+
468
+ borderRadius: 100,
469
+ top: -12,
470
+ },
471
+ indicator: {
472
+ height: 2,
473
+ width: 44,
474
+ alignSelf: 'center',
475
+ borderBottomLeftRadius: 1,
476
+ borderBottomRightRadius: 1,
477
+ },
478
+ });
@@ -0,0 +1,134 @@
1
+ import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
2
+ import {NavigationContainer} from '@react-navigation/native';
3
+ import {createStackNavigator} from '@react-navigation/stack';
4
+ import React, {useContext, useEffect} from 'react';
5
+ import {Platform} from 'react-native';
6
+ import {useSafeAreaInsets} from 'react-native-safe-area-context';
7
+ import {Colors} from '../../Consts';
8
+ import {Icon} from '../../Icon';
9
+ import {Text} from '../../Text';
10
+ import {ApplicationContext} from '../index';
11
+ import StackScreen from '../StackScreen';
12
+ import {BottomTabProps, NavigationScreenProps} from '../types';
13
+ import {getStackOptions} from '../utils';
14
+ import BottomTabBar from './BottomTabBar';
15
+
16
+ const Tab = createBottomTabNavigator();
17
+ const Stack = createStackNavigator();
18
+
19
+ const TabScreen: React.FC<NavigationScreenProps> = ({route}) => {
20
+ if (route.params?.nested) {
21
+ return (
22
+ <Stack.Navigator>
23
+ <Stack.Screen
24
+ name="Stack"
25
+ component={StackScreen}
26
+ initialParams={{screen: route.params?.screen}}
27
+ options={{...getStackOptions(), ...route.params?.options}}
28
+ />
29
+ </Stack.Navigator>
30
+ );
31
+ }
32
+ return (
33
+ <NavigationContainer independent={true}>
34
+ <Stack.Navigator>
35
+ <Stack.Screen
36
+ name="Stack"
37
+ component={StackScreen}
38
+ initialParams={{screen: route.params?.screen}}
39
+ options={{...getStackOptions(), ...route.params?.options}}
40
+ />
41
+ </Stack.Navigator>
42
+ </NavigationContainer>
43
+ );
44
+ };
45
+
46
+ const BottomTab: React.FC<BottomTabProps> = ({
47
+ nested,
48
+ tabs,
49
+ listeners,
50
+ navigation,
51
+ initialRouteName,
52
+ floatingButton,
53
+ }) => {
54
+ const {theme} = useContext(ApplicationContext);
55
+ const insets = useSafeAreaInsets();
56
+
57
+ useEffect(() => {
58
+ navigation?.setOptions({
59
+ headerShown: false,
60
+ headerTransparent: true,
61
+ headerBackground: undefined,
62
+ });
63
+ }, []);
64
+
65
+ return (
66
+ <Tab.Navigator
67
+ initialRouteName={initialRouteName}
68
+ backBehavior={'firstRoute'}
69
+ tabBar={props => (
70
+ <BottomTabBar
71
+ {...props}
72
+ accessibilityLabel={'BottomTabBar'}
73
+ floatingButton={floatingButton}
74
+ />
75
+ )}
76
+ tabBarOptions={{
77
+ style: {
78
+ height: 68 + Math.min(insets.bottom, 21),
79
+ },
80
+ tabStyle: {
81
+ height: 68,
82
+ paddingVertical: 8,
83
+ },
84
+ }}>
85
+ {tabs.map(item => {
86
+ return (
87
+ <Tab.Screen
88
+ key={item.name}
89
+ name={item.name}
90
+ component={TabScreen}
91
+ initialParams={{...item, nested}}
92
+ listeners={listeners}
93
+ options={{
94
+ tabBarLabel: ({color, focused}) => {
95
+ return (
96
+ <Text
97
+ numberOfLines={1}
98
+ typography={
99
+ focused ? 'label_xs_medium' : 'description_xs_regular'
100
+ }
101
+ color={color}
102
+ style={{width: '90%', textAlign: 'center'}}>
103
+ {item.label}
104
+ </Text>
105
+ );
106
+ },
107
+ tabBarBadge: item?.badgeLabel,
108
+ tabBarBadgeStyle: {
109
+ borderColor: 'white',
110
+ borderWidth: 2,
111
+ fontSize: 10,
112
+ lineHeight: Platform.OS === 'android' ? 17 : 14,
113
+ fontWeight: 'bold',
114
+ alignSelf: 'center',
115
+ fontFamily: `${theme.font}-Bold`,
116
+ left: item?.showDot ? 8 : 4,
117
+ top: item?.showDot ? -2 : -6,
118
+ backgroundColor:
119
+ typeof item?.badgeLabel === 'string'
120
+ ? Colors.orange_03
121
+ : Colors.red_03,
122
+ },
123
+ tabBarIcon: ({color}) => (
124
+ <Icon source={item.icon} color={color} size={28} />
125
+ ),
126
+ }}
127
+ />
128
+ );
129
+ })}
130
+ </Tab.Navigator>
131
+ );
132
+ };
133
+
134
+ export default BottomTab;