@bigbinary/neetoui-rn 0.0.268 → 0.0.270

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/package.json +2 -3
  2. package/src/components/Accordion.jsx +0 -266
  3. package/src/components/ActionIcon.jsx +0 -76
  4. package/src/components/Alert.jsx +0 -262
  5. package/src/components/AnimatedImage.jsx +0 -140
  6. package/src/components/Avatar.jsx +0 -144
  7. package/src/components/Badge.jsx +0 -97
  8. package/src/components/BottomSheet.jsx +0 -487
  9. package/src/components/BottomTabBar.jsx +0 -232
  10. package/src/components/Button.jsx +0 -275
  11. package/src/components/ButtonGroup.jsx +0 -120
  12. package/src/components/Calendar.jsx +0 -128
  13. package/src/components/Card.jsx +0 -90
  14. package/src/components/Carousel.jsx +0 -116
  15. package/src/components/ChatInput/AttachmentsView.jsx +0 -51
  16. package/src/components/ChatInput/Badge.jsx +0 -24
  17. package/src/components/ChatInput/ChatInput.jsx +0 -564
  18. package/src/components/ChatInput/EmailFields.jsx +0 -122
  19. package/src/components/ChatInput/IconButton.jsx +0 -34
  20. package/src/components/ChatInput/MentionsInputWrapper.jsx +0 -155
  21. package/src/components/CheckBox.jsx +0 -150
  22. package/src/components/Chip.jsx +0 -180
  23. package/src/components/Container.jsx +0 -31
  24. package/src/components/Divider.jsx +0 -79
  25. package/src/components/FAB.jsx +0 -113
  26. package/src/components/FlashList.jsx +0 -189
  27. package/src/components/FlatList.js +0 -10
  28. package/src/components/Input.jsx +0 -357
  29. package/src/components/InputEmailChip.jsx +0 -246
  30. package/src/components/LineLoader.jsx +0 -46
  31. package/src/components/ListItem.jsx +0 -68
  32. package/src/components/Loader.jsx +0 -122
  33. package/src/components/MultiSelect.jsx +0 -631
  34. package/src/components/NotificationIcon.jsx +0 -38
  35. package/src/components/NotificationPreferenceList.jsx +0 -208
  36. package/src/components/OnBoarding.jsx +0 -134
  37. package/src/components/OrganizationItem.jsx +0 -110
  38. package/src/components/OtpInputs.jsx +0 -194
  39. package/src/components/ParentView.jsx +0 -139
  40. package/src/components/Popover.jsx +0 -221
  41. package/src/components/RadioButton.jsx +0 -155
  42. package/src/components/RichTextEditor.jsx +0 -163
  43. package/src/components/Ripple.jsx +0 -281
  44. package/src/components/ScrollView.js +0 -14
  45. package/src/components/SearchBar.jsx +0 -207
  46. package/src/components/SegmentedTopBar/Indicator.jsx +0 -77
  47. package/src/components/SegmentedTopBar/Tab.jsx +0 -37
  48. package/src/components/SegmentedTopBar/index.jsx +0 -128
  49. package/src/components/SocialButton.jsx +0 -106
  50. package/src/components/Toast.jsx +0 -195
  51. package/src/components/ToggleSwitch.jsx +0 -112
  52. package/src/components/TopBar.jsx +0 -147
  53. package/src/components/Touchable.jsx +0 -133
  54. package/src/components/TouchableWithoutFeedback.jsx +0 -51
  55. package/src/components/Typography.jsx +0 -93
  56. package/src/components/index.js +0 -45
  57. package/src/config/index.js +0 -1
  58. package/src/config/toasterConfig.jsx +0 -142
  59. package/src/contexts/index.js +0 -3
  60. package/src/hooks/index.js +0 -3
  61. package/src/hooks/useDebounce.js +0 -17
  62. package/src/hooks/useKeyboard.js +0 -33
  63. package/src/hooks/useRefreshByUser.js +0 -20
  64. package/src/index.js +0 -2
  65. package/src/theme/index.js +0 -181
  66. package/src/utils/utils.js +0 -56
@@ -1,487 +0,0 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from "react";
2
- import { StyleSheet, FlatList, Keyboard } from "react-native";
3
-
4
- import PropTypes from "prop-types";
5
- import Modal from "react-native-modal";
6
- import { SafeAreaView } from "react-native-safe-area-context";
7
- import { moderateScale } from "react-native-size-matters";
8
-
9
- import {
10
- Typography,
11
- Container,
12
- Touchable,
13
- SearchBar,
14
- Loader,
15
- } from "@components";
16
-
17
- import { Divider } from "./Divider";
18
-
19
- import { theme } from "../theme";
20
-
21
- const Title = ({
22
- title,
23
- bg,
24
- isVisible,
25
- hide,
26
- titleContainerStyle,
27
- titleTextStyle,
28
- contentType,
29
- canSearch,
30
- setSearchText,
31
- onDonePress,
32
- searchBarProps,
33
- }) => {
34
- let touchY;
35
-
36
- useEffect(() => {
37
- setSearchText("");
38
- }, [isVisible, setSearchText]);
39
-
40
- return (
41
- <Container
42
- bg={bg}
43
- borderRadius={moderateScale(20)}
44
- pb={moderateScale(12)}
45
- onTouchStart={e => (touchY = e.nativeEvent.pageY)}
46
- onTouchEnd={e => {
47
- // Swipe Down Detection
48
- if (e.nativeEvent.pageY - touchY > 20) hide();
49
- }}
50
- {...titleContainerStyle}
51
- >
52
- <Container flexDirection="row" justifyContent="space-between">
53
- {title && (
54
- <Typography textStyle="modalHeader" {...titleTextStyle}>
55
- {title}
56
- </Typography>
57
- )}
58
- {contentType && (
59
- <Touchable
60
- onPress={() => {
61
- hide();
62
- onDonePress();
63
- }}
64
- >
65
- <Typography color="font.purple500" textStyle="modalHeader">
66
- Done
67
- </Typography>
68
- </Touchable>
69
- )}
70
- </Container>
71
- {canSearch && (
72
- <SearchBar
73
- containerProps={{ mt: moderateScale(16) }}
74
- debounceDelay={200}
75
- placeholder="Search"
76
- showCancelButton={false}
77
- onChangeText={setSearchText}
78
- onCancel={() => {
79
- setSearchText("");
80
- }}
81
- {...searchBarProps}
82
- />
83
- )}
84
- </Container>
85
- );
86
- };
87
-
88
- Title.propTypes = {
89
- title: PropTypes.string,
90
- isVisible: PropTypes.bool,
91
- hide: PropTypes.func,
92
- bg: PropTypes.string,
93
- titleContainerStyle: PropTypes.object,
94
- titleTextStyle: PropTypes.object,
95
- contentType: PropTypes.oneOf(["checkbox", null]),
96
- canSearch: PropTypes.bool,
97
- setSearchText: PropTypes.func,
98
- onDonePress: PropTypes.func,
99
- searchBarProps: PropTypes.object,
100
- };
101
-
102
- /**
103
- * BottomSheet can be used to select an item from list of items. Like a DropDown
104
- *
105
- * <div class="screenshots">
106
- * <img src="screenshots/bottomsheet/bottomsheet.png" />
107
- * </div>
108
- *
109
- * ## Usage
110
- * ```js
111
- * import React, { useState } from 'react';
112
- * import { Container, BottomSheet } from '@bigbinary/neetoui-rn';
113
- *
114
- * export default function Main() {
115
- * const [isBottomSheetVisible, setBottomSheetVisibility] = useState(false);
116
- * const [selectedItem, setSelectedItem] = useState(null);
117
- * const data = ["neeto-ui-rn", "neeto-desk-rn", "neeto-hq"];
118
- *
119
- * return (
120
- * <Container>
121
- * <BottomSheet
122
- * maxHeight={moderateScale(200)}
123
- * isVisible={isBottomSheetVisible}
124
- * hide={() => {
125
- * setBottomSheetVisibility(false);
126
- * }}
127
- * onItemPress={({item}) => {
128
- * setSelectedItem(item);
129
- * }}
130
- * title="PROJECT"
131
- * data={data}
132
- * selectedItem={selectedItem}
133
- * ContentRow={() => <CustomComponent />}
134
- * />
135
- * </Container>
136
- * );
137
- * }
138
- * ```
139
- *
140
- * @extends StyledSystems props /styled-system
141
- */
142
-
143
- export const BottomSheet = ({
144
- showCreateOption,
145
- CreateItemComponent,
146
- showCreateOptionLoader,
147
- createSearchedOptionLabelStyle,
148
- createOptionLabel,
149
- onPressCreateOption,
150
- createSearchedOptionContainerStyle,
151
- data = [],
152
- title,
153
- hide,
154
- isVisible,
155
- onItemPress,
156
- bg,
157
- children,
158
- titleContainerStyle,
159
- titleTextStyle,
160
- modalParams,
161
- HeaderComponent,
162
- ContentRow,
163
- contentType,
164
- canSearch,
165
- onDonePress,
166
- disabled,
167
- noResultsLabelContainerStyle,
168
- noResultsLabelStyle,
169
- noResultsLabel,
170
- NoResultsComponent,
171
- labelExtractor,
172
- valueExtractor,
173
- selectedItem,
174
- onBackdropPress,
175
- searchBarProps,
176
- shouldHideKeyboardOnScrollBegin = true,
177
- shouldShowItemSeparator = true,
178
- flatListRef,
179
- ...rest
180
- }) => {
181
- const [searchText, setSearchText] = useState("");
182
-
183
- const getLabel = useCallback(
184
- (item, index) => item?.label || labelExtractor(item, index) || item,
185
- [labelExtractor]
186
- );
187
-
188
- const generatedData = useMemo(() => {
189
- if (searchText.length) {
190
- return data.filter(item =>
191
- getLabel(item).toLowerCase().includes(searchText.toLowerCase())
192
- );
193
- }
194
-
195
- return data;
196
- }, [data, getLabel, searchText]);
197
-
198
- const shouldHideCreateComponent = useMemo(() => {
199
- const filteredItemCount = generatedData.filter(
200
- data =>
201
- getLabel(data).toLocaleLowerCase() === searchText.toLocaleLowerCase()
202
- ).length;
203
-
204
- return filteredItemCount > 0;
205
- }, [generatedData, getLabel, searchText]);
206
-
207
- const checkIsSelected = item => {
208
- const itemValue = item?.value || valueExtractor(item) || item;
209
- const selectedItemValue =
210
- selectedItem?.value || valueExtractor(selectedItem) || selectedItem;
211
-
212
- return itemValue === selectedItemValue;
213
- };
214
-
215
- return (
216
- <Modal
217
- avoidKeyboard
218
- hideModalContentWhileAnimating
219
- useNativeDriver
220
- isVisible={isVisible}
221
- style={styles.modalStyle}
222
- onRequestClose={hide}
223
- onBackdropPress={() => {
224
- onBackdropPress();
225
- hide();
226
- }}
227
- {...modalParams}
228
- >
229
- <SafeAreaView style={styles.safeAreaView}>
230
- <Container
231
- bg={bg}
232
- borderTopLeftRadius={moderateScale(20)}
233
- borderTopRightRadius={moderateScale(20)}
234
- flexShrink={1}
235
- p={moderateScale(16)}
236
- {...rest}
237
- >
238
- {title && (
239
- <Title
240
- HeaderComponent={HeaderComponent}
241
- bg={bg}
242
- canSearch={canSearch}
243
- contentType={contentType}
244
- hide={hide}
245
- isVisible={isVisible}
246
- searchBarProps={searchBarProps}
247
- searchText={searchText}
248
- setSearchText={setSearchText}
249
- title={title}
250
- titleContainerStyle={titleContainerStyle}
251
- titleTextStyle={titleTextStyle}
252
- onDonePress={onDonePress}
253
- />
254
- )}
255
- {data && (
256
- <FlatList
257
- data={generatedData}
258
- initialNumToRender={data.length}
259
- keyExtractor={(_item, index) => index}
260
- keyboardShouldPersistTaps="handled"
261
- ref={flatListRef}
262
- showsVerticalScrollIndicator={false}
263
- ItemSeparatorComponent={
264
- shouldShowItemSeparator ? (
265
- <Divider bg="background.grey200" />
266
- ) : null
267
- }
268
- ListFooterComponent={
269
- <Container>
270
- {children}
271
- {!!searchText &&
272
- !generatedData.length &&
273
- !showCreateOption &&
274
- (NoResultsComponent ? (
275
- <NoResultsComponent />
276
- ) : (
277
- <Container
278
- alignItems="center"
279
- mb={moderateScale(2)}
280
- py={moderateScale(2)}
281
- {...noResultsLabelContainerStyle}
282
- >
283
- <Typography
284
- color="font.grey"
285
- fontFamily="sf600"
286
- fontSize="s"
287
- {...noResultsLabelStyle}
288
- >
289
- {noResultsLabel || "No options found"}
290
- </Typography>
291
- </Container>
292
- ))}
293
- {!disabled &&
294
- !shouldHideCreateComponent &&
295
- (showCreateOptionLoader ? (
296
- <Loader color={theme.colors.background.base} />
297
- ) : (
298
- !!searchText &&
299
- showCreateOption && (
300
- <Container>
301
- {CreateItemComponent ? (
302
- <CreateItemComponent searchText={searchText} />
303
- ) : (
304
- <Touchable
305
- alignItems="center"
306
- height={moderateScale(40)}
307
- justifyContent="center"
308
- onPress={() => onPressCreateOption(searchText)}
309
- {...createSearchedOptionContainerStyle}
310
- >
311
- <Typography
312
- color="font.grey"
313
- fontFamily="sf400"
314
- fontSize="s"
315
- {...createSearchedOptionLabelStyle}
316
- >
317
- {createOptionLabel ||
318
- `Create ${searchText} option`}
319
- </Typography>
320
- </Touchable>
321
- )}
322
- </Container>
323
- )
324
- ))}
325
- </Container>
326
- }
327
- renderItem={({ item, index }) => (
328
- <ContentRow
329
- index={index}
330
- isSelected={checkIsSelected(item)}
331
- item={item}
332
- key={index}
333
- onPress={() => {
334
- !contentType && hide();
335
- onItemPress({ index, item });
336
- }}
337
- />
338
- )}
339
- onScrollBeginDrag={
340
- shouldHideKeyboardOnScrollBegin && Keyboard.dismiss
341
- }
342
- />
343
- )}
344
- </Container>
345
- </SafeAreaView>
346
- </Modal>
347
- );
348
- };
349
-
350
- BottomSheet.defaultProps = {
351
- bg: "background.primary",
352
- showCreateOption: false,
353
- showCreateOptionLoader: false,
354
- createOptionLabel: null,
355
- onPressCreateOption: () => {},
356
- CreateItemComponent: null,
357
- onDonePress: () => {},
358
- valueExtractor: () => {},
359
- labelExtractor: () => {},
360
- onBackdropPress: () => {},
361
- searchBarProps: {},
362
- };
363
-
364
- BottomSheet.propTypes = {
365
- /**
366
- * List of items.
367
- */
368
- data: PropTypes.array,
369
- /**
370
- * Title to be displayed in the bottom sheet header.
371
- */
372
- title: PropTypes.string,
373
- /**
374
- * If true bottom sheet will be shown.
375
- */
376
- isVisible: PropTypes.bool,
377
- /**
378
- * Callback that will be called on while hiding the bottom sheet.
379
- */
380
- hide: PropTypes.func,
381
- /**
382
- * Callback which returns the index of selected item.
383
- */
384
- onItemPress: PropTypes.func,
385
- /**
386
- * Callback that will be called on Done button press
387
- */
388
- onDonePress: PropTypes.func,
389
- /**
390
- * Background color.
391
- */
392
- bg: PropTypes.string,
393
- /**
394
- * To customize title container styles.
395
- */
396
- titleContainerStyle: PropTypes.object,
397
- /**
398
- * To customize title text styles.
399
- */
400
- titleTextStyle: PropTypes.object,
401
- /**
402
- * Show option to create the searched label if not present in the options list
403
- */
404
- showCreateOption: PropTypes.bool,
405
- /**
406
- * Show loader while creating a searched option not present in the options list
407
- */
408
- showCreateOptionLoader: PropTypes.bool,
409
- /**
410
- * Custom label for creating searched option not present in the options list
411
- */
412
- createOptionLabel: PropTypes.string,
413
- /**
414
- * Callback when create searched option is pressed
415
- */
416
- onPressCreateOption: PropTypes.func,
417
- /**
418
- * Component that renders when searched item doesn't exists
419
- */
420
- CreateItemComponent: PropTypes.func,
421
- /**
422
- * To customize empty options placeholder text style.
423
- */
424
- createSearchedOptionLabelStyle: PropTypes.object,
425
- /**
426
- * Flag will disable create item feature
427
- */
428
- disabled: PropTypes.bool,
429
- /**
430
- * To customize empty options placeholder container style.
431
- */
432
- createSearchedOptionContainerStyle: PropTypes.object,
433
- noResultsLabelContainerStyle: PropTypes.object,
434
- noResultsLabelStyle: PropTypes.object,
435
- noResultsLabel: PropTypes.string,
436
- NoResultsComponent: PropTypes.node,
437
- /**
438
- * Use custom key as label.
439
- */
440
- labelExtractor: PropTypes.func,
441
- /**
442
- * Use custom key as value.
443
- */
444
- valueExtractor: PropTypes.func,
445
- /**
446
- * Function to customize back drop press
447
- */
448
- onBackdropPress: PropTypes.func,
449
- /**
450
- * Currently selected item
451
- */
452
- selectedItem: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
453
- /**
454
- * Object to update the searchbar component
455
- */
456
- searchBarProps: PropTypes.object,
457
- /**
458
- * To support more Modal params.
459
- */
460
- modalParams: PropTypes.object,
461
- children: PropTypes.node,
462
- HeaderComponent: PropTypes.elementType,
463
- ContentRow: PropTypes.elementType,
464
- contentType: PropTypes.oneOf(["checkbox", null]),
465
- canSearch: PropTypes.bool,
466
- shouldHideKeyboardOnScrollBegin: PropTypes.bool,
467
- shouldShowItemSeparator: PropTypes.bool,
468
- flatListRef: PropTypes.object,
469
- };
470
-
471
- const styles = StyleSheet.create({
472
- safeAreaView: {
473
- maxHeight: "70%",
474
- backgroundColor: theme.colors.background.primary,
475
- borderTopRightRadius: moderateScale(20),
476
- borderTopLeftRadius: moderateScale(20),
477
- },
478
- modalStyle: {
479
- margin: 0,
480
- justifyContent: "flex-end",
481
- flex: 1,
482
- },
483
- inputContainerStyle: {
484
- backgroundColor: "white",
485
- borderRadius: moderateScale(10),
486
- },
487
- });
@@ -1,232 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { StyleSheet, TouchableWithoutFeedback } from "react-native";
3
-
4
- import PropTypes from "prop-types";
5
- import Animated, {
6
- useSharedValue,
7
- useAnimatedStyle,
8
- withTiming,
9
- interpolate,
10
- Extrapolation,
11
- } from "react-native-reanimated";
12
- import { useSafeAreaInsets } from "react-native-safe-area-context";
13
- import { moderateScale } from "react-native-size-matters";
14
-
15
- import { Container, Typography } from "@components";
16
-
17
- const TabElement = ({
18
- isFocused,
19
- onPress,
20
- label,
21
- tabBarActiveTintColor,
22
- tabBarInactiveTintColor,
23
- icon: Icon,
24
- size,
25
- }) => {
26
- const offset = useSharedValue(isFocused ? 1 : 0);
27
-
28
- useEffect(() => {
29
- if (isFocused) {
30
- offset.value = withTiming(1, { duration: 500 });
31
- } else {
32
- offset.value = withTiming(0, { duration: 0 });
33
- }
34
- }, [isFocused]);
35
-
36
- const animatedStyles = useAnimatedStyle(() => ({
37
- opacity: interpolate(offset.value, [0, 1], [1, 0], {
38
- extrapolateRight: Extrapolation.CLAMP,
39
- }),
40
- }));
41
-
42
- const animatedStyles2 = useAnimatedStyle(() => ({
43
- opacity: interpolate(offset.value, [0, 0.9, 1], [0, 0.5, 1], {
44
- extrapolateRight: Extrapolation.CLAMP,
45
- }),
46
- transform: [
47
- {
48
- scale: interpolate(offset.value, [0, 0.8, 1], [1, 1.2, 1], {
49
- extrapolateRight: Extrapolation.CLAMP,
50
- }),
51
- },
52
- ],
53
- }));
54
-
55
- return (
56
- <TouchableWithoutFeedback onPress={onPress}>
57
- <Container
58
- alignItems="center"
59
- borderColor="background.grey200"
60
- borderTopWidth={moderateScale(1)}
61
- flex={1}
62
- >
63
- <Container
64
- alignItems="center"
65
- height={moderateScale(35)}
66
- mb={moderateScale(4)}
67
- width={moderateScale(48)}
68
- >
69
- <Animated.View style={[styles.iconContainer, animatedStyles]}>
70
- <Icon
71
- size={size}
72
- color={
73
- isFocused ? tabBarActiveTintColor : tabBarInactiveTintColor
74
- }
75
- />
76
- </Animated.View>
77
- <Animated.View style={[styles.iconContainer, animatedStyles2]}>
78
- <Icon
79
- size={size}
80
- color={
81
- isFocused ? tabBarActiveTintColor : tabBarInactiveTintColor
82
- }
83
- />
84
- </Animated.View>
85
- </Container>
86
- <Typography
87
- color={isFocused ? tabBarActiveTintColor : tabBarInactiveTintColor}
88
- fontFamily="sf500"
89
- fontSize="4xs"
90
- >
91
- {label}
92
- </Typography>
93
- </Container>
94
- </TouchableWithoutFeedback>
95
- );
96
- };
97
-
98
- const styles = StyleSheet.create({
99
- iconContainer: {
100
- position: "absolute",
101
- margin: moderateScale(10),
102
- },
103
- });
104
-
105
- /**
106
- *
107
- * BottomTabBar is animated custom tabbar component which needs to used along with [React Navigation & Bottom Tabs Navigator](https://reactnavigation.org/docs/bottom-tab-navigator/)
108
- * <div class="screenshots">
109
- * <img src="screenshots/bottomTabBar/bottomTabBar-1.png" />
110
- * <img src="screenshots/bottomTabBar/bottomTabBar-2.png" />
111
- * </div>
112
- *
113
- * ## Usage
114
- * ```js
115
- * import * as React from 'react';
116
- * import { Typography, BottomTabBar } from '@bigbinary/neetoui-rn';
117
- * import { NavigationContainer } from '@react-navigation/native';
118
- * import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
119
- * import { ThemeContext } from "styled-components/native";
120
- * import { moderateScale } from "react-native-size-matters";
121
- *
122
- * const Tab = createBottomTabNavigator();
123
- *
124
- * const HomeScreen = () => {
125
- * return (
126
- * <Typography fontSize="14px">Home Screen</Typography>
127
- * )
128
- * }
129
- *
130
- * const SettingsScreen = () => {
131
- * return (
132
- * <Typography fontSize="14px">Settings Screen</Typography>
133
- * )
134
- * }
135
- *
136
- * export default function Main() {
137
- * const theme = useContext(ThemeContext);
138
- * return (
139
- * <Tab.Navigator
140
- * screenOptions={{
141
- * tabBarActiveTintColor: theme.colors.background.base,
142
- * tabBarInactiveTintColor: theme.colors.background.grey500,
143
- * }}
144
- * tabBar={props => <BottomTabBar {...props} />}
145
- * >
146
- * <Tab.Screen name="Home" component={HomeScreen}
147
- * options={{
148
- * customTabBarProps: {
149
- * icon: "home-5-line",
150
- * size: moderateScale(26),
151
- * },
152
- * }}
153
- * />
154
- * <Tab.Screen name="Settings" component={SettingsScreen}
155
- * options={{
156
- * customTabBarProps: {
157
- * icon: "user-3-line",
158
- * size: moderateScale(26),
159
- * },
160
- * }} />
161
- * </Tab.Navigator>
162
- * );
163
- * }
164
- * ```
165
- *
166
- */
167
-
168
- export const BottomTabBar = ({ state, descriptors, navigation }) => {
169
- const { bottom } = useSafeAreaInsets();
170
-
171
- return (
172
- <Container
173
- bg="background.white"
174
- flexDirection="row"
175
- height={bottom === 0 ? moderateScale(63) : moderateScale(83)}
176
- >
177
- {state.routes.map(({ key, name }, index) => {
178
- const { options } = descriptors[key];
179
- const isFocused = state.index === index;
180
- const { icon, size } = options?.customTabBarProps || {};
181
- const { tabBarActiveTintColor, tabBarInactiveTintColor } = options;
182
- const onPress = () => {
183
- const event = navigation.emit({
184
- type: "tabPress",
185
- target: key,
186
- canPreventDefault: true,
187
- });
188
-
189
- if (!isFocused && !event.defaultPrevented) {
190
- navigation.navigate({ name, merge: true });
191
- }
192
- };
193
-
194
- const label =
195
- options.tabBarLabel !== undefined
196
- ? options.tabBarLabel
197
- : options.title !== undefined
198
- ? options.title
199
- : name;
200
-
201
- return (
202
- <TabElement
203
- icon={icon}
204
- isFocused={isFocused}
205
- key={index}
206
- label={label}
207
- size={size}
208
- tabBarActiveTintColor={tabBarActiveTintColor}
209
- tabBarInactiveTintColor={tabBarInactiveTintColor}
210
- onPress={onPress}
211
- />
212
- );
213
- })}
214
- </Container>
215
- );
216
- };
217
-
218
- TabElement.propTypes = {
219
- isFocused: PropTypes.bool,
220
- onPress: PropTypes.func,
221
- label: PropTypes.string,
222
- tabBarActiveTintColor: PropTypes.string,
223
- tabBarInactiveTintColor: PropTypes.string,
224
- icon: PropTypes.elementType,
225
- size: PropTypes.number,
226
- };
227
-
228
- BottomTabBar.propTypes = {
229
- state: PropTypes.object,
230
- descriptors: PropTypes.object,
231
- navigation: PropTypes.object,
232
- };