@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40

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 (153) hide show
  1. package/Application/BottomSheet.tsx +398 -86
  2. package/Application/BottomTab/BottomTabBar.tsx +275 -215
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
  4. package/Application/BottomTab/DuoBarCompression.tsx +28 -14
  5. package/Application/BottomTab/DuoTabBar.tsx +540 -32
  6. package/Application/BottomTab/TabBarIcon.tsx +72 -146
  7. package/Application/BottomTab/index.tsx +353 -89
  8. package/Application/BottomTab/useLiquidSelection.ts +374 -0
  9. package/Application/Components/BackgroundImageView.tsx +0 -4
  10. package/Application/Components/DuoGlassBackground.tsx +5 -7
  11. package/Application/Components/HeaderAnimated.tsx +13 -41
  12. package/Application/Components/HeaderBackground.tsx +3 -20
  13. package/Application/Components/HeaderExtendHeader.tsx +46 -66
  14. package/Application/Components/HeaderLeft.tsx +18 -5
  15. package/Application/Components/HeaderRight.tsx +529 -8
  16. package/Application/Components/HeaderTitle.tsx +579 -16
  17. package/Application/Components/NavigationButton.tsx +11 -18
  18. package/Application/Components/SearchHeader.tsx +18 -38
  19. package/Application/Localize.ts +0 -7
  20. package/Application/ModalScreen.tsx +18 -41
  21. package/Application/Navigation.ts +17 -15
  22. package/Application/NavigationContainer.tsx +21 -23
  23. package/Application/Navigator.ts +48 -20
  24. package/Application/ScaleSizeProvider.tsx +6 -13
  25. package/Application/StackScreen.tsx +172 -27
  26. package/Application/TooltipPortal.tsx +5 -12
  27. package/Application/WidgetContainer.tsx +7 -20
  28. package/Application/device.ts +52 -0
  29. package/Application/index.ts +1 -23
  30. package/Application/types.ts +242 -17
  31. package/Application/utils.tsx +493 -0
  32. package/Badge/Badge.tsx +0 -5
  33. package/Badge/BadgeDot.tsx +0 -1
  34. package/Badge/BadgeDotAnimation.tsx +7 -15
  35. package/Badge/BadgeRibbon.tsx +39 -47
  36. package/Badge/Shape.tsx +0 -2
  37. package/Badge/styles.ts +0 -2
  38. package/Badge/types.ts +2 -2
  39. package/Button/index.tsx +152 -21
  40. package/Button/styles.ts +1 -1
  41. package/CheckBox/index.tsx +6 -5
  42. package/Consts/theme.ts +10 -10
  43. package/Context/index.ts +1 -5
  44. package/Divider/DashDivider.tsx +11 -11
  45. package/Divider/index.tsx +7 -21
  46. package/FoundationList/index.tsx +0 -4
  47. package/Icon/index.tsx +6 -6
  48. package/Icon/types.ts +1 -1
  49. package/IconButton/index.tsx +12 -4
  50. package/Image/index.tsx +7 -9
  51. package/Input/Input.tsx +12 -10
  52. package/Input/InputDropDown.tsx +13 -10
  53. package/Input/InputMoney.tsx +152 -45
  54. package/Input/InputOTP.tsx +34 -36
  55. package/Input/InputPhoneNumber.tsx +5 -8
  56. package/Input/InputSearch.tsx +111 -19
  57. package/Input/InputTextArea.tsx +5 -5
  58. package/Input/SystemTextInput.tsx +2 -7
  59. package/Input/TextTyping.tsx +0 -4
  60. package/Input/common.tsx +17 -31
  61. package/Input/index.tsx +21 -24
  62. package/Input/styles.ts +5 -25
  63. package/Input/utils.ts +12 -14
  64. package/Layout/Card.tsx +4 -7
  65. package/Layout/FloatingButton.tsx +21 -26
  66. package/Layout/Item.tsx +2 -6
  67. package/Layout/ItemList.tsx +7 -9
  68. package/Layout/ItemSectionList.tsx +1 -2
  69. package/Layout/ReservedRegions.tsx +17 -34
  70. package/Layout/Screen.tsx +696 -122
  71. package/Layout/Section.tsx +7 -9
  72. package/Layout/TrackingScope.tsx +0 -1
  73. package/Layout/index.ts +4 -10
  74. package/Layout/styles.ts +0 -2
  75. package/Layout/types.ts +4 -2
  76. package/Layout/utils.ts +181 -40
  77. package/Loader/DotLoader.tsx +3 -11
  78. package/Loader/Loader.tsx +0 -4
  79. package/Loader/ProgressBar.tsx +6 -3
  80. package/Loader/Spinner.tsx +3 -11
  81. package/Loader/styles.ts +0 -4
  82. package/Loader/utils.ts +7 -11
  83. package/Pagination/Dot.tsx +0 -4
  84. package/Pagination/PaginationDot.tsx +0 -1
  85. package/Pagination/PaginationNumber.tsx +3 -5
  86. package/Pagination/PaginationScroll.tsx +0 -5
  87. package/Pagination/PaginationWhiteDot.tsx +0 -1
  88. package/Pagination/index.tsx +0 -4
  89. package/Pagination/types.ts +2 -2
  90. package/Popup/PopupNotify.tsx +102 -94
  91. package/Popup/PopupPromotion.tsx +11 -9
  92. package/Popup/types.ts +4 -11
  93. package/Popup/utils.ts +18 -50
  94. package/Radio/index.tsx +10 -6
  95. package/Radio/styles.ts +0 -6
  96. package/Skeleton/index.tsx +9 -9
  97. package/Skeleton/styles.ts +0 -1
  98. package/Switch/index.tsx +0 -1
  99. package/Tag/index.tsx +4 -8
  100. package/Tag/types.ts +3 -3
  101. package/Text/index.tsx +5 -25
  102. package/Text/styles.ts +1 -1
  103. package/Text/types.ts +6 -1
  104. package/Text/utils.ts +4 -20
  105. package/Title/index.tsx +40 -42
  106. package/Title/styles.ts +0 -6
  107. package/ViewBoundary/index.tsx +2 -4
  108. package/index.ts +6 -0
  109. package/package.json +1 -2
  110. package/Application/BottomSheet.hooks.ts +0 -195
  111. package/Application/BottomSheet.parts.tsx +0 -157
  112. package/Application/BottomSheet.styles.ts +0 -43
  113. package/Application/BottomTab/ActiveIndicator.tsx +0 -91
  114. package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
  115. package/Application/BottomTab/BottomTabInset.tsx +0 -18
  116. package/Application/BottomTab/CurvedContainer.tsx +0 -155
  117. package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
  118. package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
  119. package/Application/BottomTab/TabScreen.tsx +0 -160
  120. package/Application/BottomTab/metrics.ts +0 -164
  121. package/Application/BottomTab/tabItems.ts +0 -46
  122. package/Application/BottomTab/usePressLift.ts +0 -32
  123. package/Application/Components/HeaderRight.styles.ts +0 -146
  124. package/Application/Components/HeaderTitle.shared.ts +0 -44
  125. package/Application/Components/HeaderTitle.styles.ts +0 -125
  126. package/Application/Components/HeaderToolkitAction.tsx +0 -180
  127. package/Application/Components/SwipeBackHaptic.tsx +0 -95
  128. package/Application/Components/TitleJourney.tsx +0 -110
  129. package/Application/Components/TitleLocation.tsx +0 -73
  130. package/Application/Components/TitleUser.tsx +0 -304
  131. package/Application/Components/useToolkitActions.tsx +0 -218
  132. package/Application/ModalIconButton.tsx +0 -66
  133. package/Application/StackScreen.tracking.ts +0 -143
  134. package/Application/headerLayout.ts +0 -158
  135. package/Application/hooks.ts +0 -137
  136. package/Application/modalLayout.ts +0 -176
  137. package/Application/navigationOptions.tsx +0 -212
  138. package/Application/types.header.ts +0 -121
  139. package/Application/types.tabs.ts +0 -48
  140. package/Application/types.theme.ts +0 -87
  141. package/Application/utils.ts +0 -107
  142. package/Button/utils.ts +0 -133
  143. package/Input/InputMoneyView.tsx +0 -194
  144. package/Input/SearchTextTyping.tsx +0 -108
  145. package/Input/moneyUtils.ts +0 -23
  146. package/Layout/layoutMetrics.ts +0 -58
  147. package/Layout/layoutTypes.ts +0 -86
  148. package/Layout/screenContent.tsx +0 -92
  149. package/Layout/screenFooter.tsx +0 -63
  150. package/Layout/screenHeader.tsx +0 -321
  151. package/Layout/screenQuickReturn.tsx +0 -64
  152. package/Layout/screenScroll.ts +0 -107
  153. package/Layout/screenTypes.ts +0 -143
@@ -1,304 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import { TouchableOpacity, View } from 'react-native';
3
- import { ApplicationContext } from '../../Context';
4
- import { Text } from '../../Text';
5
- import { Colors, Spacing, Styles } from '../../Consts';
6
- import { TitleUserProps } from '../types';
7
- import { Image } from '../../Image';
8
- import { Skeleton } from '../../Skeleton';
9
- import { styles } from './HeaderTitle.styles';
10
- import { useHeaderFontFamily, useTitleMaxWidth } from './HeaderTitle.shared';
11
-
12
- /**
13
- * Header title for a user or group: avatar (1 to 4 images, a `+N` stack, or name
14
- * initials), title with verified icons and subtitle; a shimmer while `isLoading`.
15
- */
16
- const TitleUser: React.FC<TitleUserProps> = ({
17
- title,
18
- subTitle,
19
- image: image,
20
- tintColor,
21
- dotColor,
22
- onPress,
23
- verify,
24
- icons,
25
- isLoading,
26
- }) => {
27
- const { theme } = useContext(ApplicationContext);
28
- const headerFontFamily = useHeaderFontFamily();
29
- const maxWidth = useTitleMaxWidth();
30
- const getShortName = (name: string) => {
31
- const words = name.split(' ');
32
- const lastTwoWords = words.slice(-2);
33
- return lastTwoWords.map(word => word.charAt(0).toUpperCase()).join('');
34
- };
35
-
36
- const renderImage = () => {
37
- const avatarWidth = Spacing.XXL;
38
- if (Array.isArray(image) && image.length > 0) {
39
- switch (image.length) {
40
- case 1: {
41
- return image.map((i: string) => (
42
- <Image
43
- key={`avatar-${i}`}
44
- source={{ uri: i }}
45
- style={styles.circle}
46
- />
47
- ));
48
- }
49
- case 2: {
50
- return (
51
- <View style={[Styles.flex, styles.groupAvtContainer]}>
52
- <Image
53
- source={{ uri: image[0] }}
54
- style={[
55
- styles.circleMedium,
56
- styles.avatarEdgeTopRight,
57
- styles.layer0,
58
- ]}
59
- />
60
- <Image
61
- source={{ uri: image[1] }}
62
- style={[
63
- styles.circleMedium,
64
- styles.avatarEdgeBottomLeft,
65
- styles.layer1,
66
- ]}
67
- />
68
- </View>
69
- );
70
- }
71
- case 3: {
72
- return (
73
- <View style={[Styles.flex, styles.groupAvtContainer]}>
74
- <Image
75
- source={{ uri: image[0] }}
76
- style={[
77
- styles.circleSmall,
78
- styles.avatarBottomRight,
79
- styles.layer0,
80
- ]}
81
- />
82
- <Image
83
- source={{ uri: image[1] }}
84
- style={[
85
- styles.circleSmall,
86
- styles.avatarTop,
87
- { left: avatarWidth / 2 - 16 / 2 },
88
- styles.layer1,
89
- ]}
90
- />
91
- <Image
92
- source={{ uri: image[2] }}
93
- style={[
94
- styles.circleSmall,
95
- styles.avatarBottomLeft,
96
- styles.layer2,
97
- ]}
98
- />
99
- </View>
100
- );
101
- }
102
- case 4: {
103
- return (
104
- <View style={[Styles.flex, styles.groupAvtContainer]}>
105
- <Image
106
- source={{ uri: image[0] }}
107
- style={[
108
- styles.circleSmall,
109
- styles.avatarBottomLeft,
110
- styles.layer0,
111
- ]}
112
- />
113
- <Image
114
- source={{ uri: image[1] }}
115
- style={[
116
- styles.circleSmall,
117
- styles.avatarBottomRight,
118
- styles.layer1,
119
- ]}
120
- />
121
- <Image
122
- source={{ uri: image[2] }}
123
- style={[
124
- styles.circleSmall,
125
- styles.avatarTopRight,
126
- styles.layer2,
127
- ]}
128
- />
129
- <Image
130
- source={{ uri: image[2] }}
131
- style={[
132
- styles.circleSmall,
133
- styles.avatarTopLeft,
134
- styles.layer3,
135
- ]}
136
- />
137
- </View>
138
- );
139
- }
140
- default: {
141
- return (
142
- <View style={[Styles.flex, styles.groupAvtContainer]}>
143
- <Image
144
- source={{ uri: image[0] }}
145
- style={[
146
- styles.circleSmall,
147
- styles.avatarBottomLeft,
148
- styles.layer0,
149
- ]}
150
- />
151
- <Image
152
- source={{ uri: image[1] }}
153
- style={[
154
- styles.circleSmall,
155
- styles.avatarTopRight,
156
- styles.layer2,
157
- ]}
158
- />
159
- <Image
160
- source={{ uri: image[2] }}
161
- style={[
162
- styles.circleSmall,
163
- styles.avatarTopLeft,
164
- styles.layer3,
165
- ]}
166
- />
167
- <View
168
- style={[
169
- styles.circleSmall,
170
- styles.avatarBottomRight,
171
- styles.layer1,
172
- styles.avatarMore,
173
- ]}
174
- >
175
- <Text
176
- color={Colors.pink_03}
177
- typography={'description_xs_regular'}
178
- >
179
- {`+${image.length - 3}`}
180
- </Text>
181
- </View>
182
- </View>
183
- );
184
- }
185
- }
186
- }
187
-
188
- if (typeof image === 'string' && image) {
189
- return <Image source={{ uri: image }} style={styles.circle} />;
190
- }
191
-
192
- return (
193
- <View
194
- style={[
195
- styles.imageContainer,
196
- { borderColor: theme.colors.border.default },
197
- ]}
198
- >
199
- <Text color={Colors.pink_03} typography={'description_xs_regular'}>
200
- {getShortName(title)}
201
- </Text>
202
- </View>
203
- );
204
- };
205
-
206
- const renderVerifyIcon = () => {
207
- if (icons && icons.length > 0) {
208
- return (
209
- <View style={[Styles.row]}>
210
- {icons.map(icon => (
211
- <Image
212
- key={`verified-icon-${icon}`}
213
- source={{
214
- uri: icon,
215
- }}
216
- style={styles.verifiedIcon}
217
- />
218
- ))}
219
- </View>
220
- );
221
- }
222
- };
223
-
224
- const renderShimmer = () => {
225
- return (
226
- <View style={Styles.row}>
227
- <View
228
- style={[
229
- styles.imageContainer,
230
- {
231
- borderColor: theme.colors.border.default,
232
- marginRight: Spacing.M / 2,
233
- },
234
- ]}
235
- >
236
- <Skeleton />
237
- </View>
238
- <View style={Styles.flex}>
239
- <View style={styles.shimmerTitle}>
240
- <Skeleton />
241
- </View>
242
- <View style={{ height: Spacing.XXS }} />
243
- <View style={styles.shimmerDescription}>
244
- <Skeleton />
245
- </View>
246
- </View>
247
- </View>
248
- );
249
- };
250
-
251
- if (verify) {
252
- console.warn(`Warning: The verify value "${verify}" is deprecated.`);
253
- }
254
-
255
- if (isLoading) {
256
- return renderShimmer();
257
- }
258
-
259
- return (
260
- <TouchableOpacity
261
- style={[
262
- styles.centerContent,
263
- { maxWidth: maxWidth - (icons?.length ?? 0) * 16 },
264
- ]}
265
- onPress={onPress}
266
- disabled={onPress === undefined}
267
- >
268
- <View
269
- style={[Styles.row, { maxWidth: maxWidth - (icons?.length ?? 0) * 16 }]}
270
- >
271
- <View>
272
- {renderImage()}
273
- {!!dotColor && (
274
- <View style={[styles.dotAvatar, { backgroundColor: dotColor }]} />
275
- )}
276
- </View>
277
- <View style={styles.titleInfo}>
278
- <View style={Styles.row}>
279
- <Text
280
- typography="action_xs_bold"
281
- fontFamily={headerFontFamily}
282
- color={tintColor}
283
- numberOfLines={1}
284
- >
285
- {title}
286
- </Text>
287
- {renderVerifyIcon()}
288
- </View>
289
- {!!subTitle && (
290
- <Text
291
- typography="description_xs_regular"
292
- color={tintColor}
293
- numberOfLines={1}
294
- >
295
- {subTitle}
296
- </Text>
297
- )}
298
- </View>
299
- </View>
300
- </TouchableOpacity>
301
- );
302
- };
303
-
304
- export { TitleUser };
@@ -1,218 +0,0 @@
1
- import { useCallback, useContext, useEffect, useState } from 'react';
2
- import { ApplicationContext, MiniAppContext } from '../../Context';
3
- import { PopupNotify } from '../../Popup';
4
- import { Tool, ToolGroup } from '../types';
5
-
6
- const DID_SYNC_NEW_HOME = 'did_sync_new_home';
7
-
8
- type ToolkitActionsParams = {
9
- preventClose?: any;
10
- useSystemTools: boolean;
11
- useShortcut: boolean;
12
- useMore: boolean;
13
- tools: any[];
14
- useCloseIcon: boolean;
15
- };
16
-
17
- /**
18
- * State and handlers behind the header toolkit: the favorite shortcut (kept in sync
19
- * with the home), single tool or "more" shortcut, help center and close.
20
- */
21
- const useToolkitActions = ({
22
- preventClose,
23
- useSystemTools,
24
- useShortcut,
25
- useMore,
26
- tools,
27
- useCloseIcon,
28
- }: ToolkitActionsParams) => {
29
- const { navigator } = useContext(ApplicationContext);
30
- const context = useContext<any>(MiniAppContext);
31
-
32
- const [isFavorite, setIsFavorite] = useState<boolean>(false);
33
- const [isLoading, setIsLoading] = useState(false);
34
-
35
- const checkAppIsFavorite = useCallback(() => {
36
- return navigator?.maxApi?.dispatchFunction?.(
37
- 'isFavoriteApp',
38
- { code: context?.code },
39
- (result: boolean) => {
40
- setIsFavorite(result);
41
- },
42
- );
43
- }, [context?.code, navigator?.maxApi]);
44
-
45
- useEffect(() => {
46
- if (useShortcut) {
47
- checkAppIsFavorite();
48
-
49
- const favoriteObserver = navigator?.maxApi?.observer?.(
50
- DID_SYNC_NEW_HOME,
51
- (updatedData: any) => {
52
- const status = updatedData?.items?.includes(context?.code);
53
- setIsFavorite(status);
54
- },
55
- );
56
- return () => {
57
- favoriteObserver?.remove?.();
58
- };
59
- }
60
- }, [useShortcut, context, checkAppIsFavorite, navigator?.maxApi]);
61
-
62
- const onDismiss = () => {
63
- if (useCloseIcon) {
64
- navigator?.maxApi?.dispatchFunction?.(
65
- 'dismiss',
66
- navigator?.dismissData,
67
- undefined,
68
- );
69
- } else {
70
- navigator?.maxApi?.dispatchFunction?.('dismissAll');
71
- }
72
- };
73
-
74
- const onClose = () => {
75
- const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
76
- context?.autoTracking?.({
77
- ...context,
78
- componentName: 'IconButton',
79
- componentId: 'navigation_close',
80
- screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
81
- });
82
-
83
- if (preventClose) {
84
- navigator?.showModal({
85
- screen: () => (
86
- <PopupNotify
87
- {...preventClose}
88
- primary={{
89
- title: preventClose.primary.title,
90
- onPress: () => {
91
- preventClose?.primary.onPress();
92
- onDismiss();
93
- },
94
- }}
95
- />
96
- ),
97
- });
98
- } else {
99
- onDismiss();
100
- }
101
- };
102
-
103
- const onPressShortcut = () => {
104
- const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
105
- const expected = !isFavorite;
106
- context?.autoTracking?.({
107
- ...context,
108
- componentName: 'IconButton',
109
- componentId: `${expected ? 'pin' : 'unpin'}_shortcut`,
110
- screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
111
- });
112
- setIsLoading(true);
113
- navigator?.maxApi?.dispatchFunction?.(
114
- 'onToolAction',
115
- {
116
- item: {
117
- key: 'onFavorite',
118
- },
119
- context,
120
- },
121
- ({ success }: { success: boolean }) => {
122
- if (success) {
123
- setIsFavorite(expected);
124
- }
125
- },
126
- );
127
- setTimeout(() => {
128
- setIsLoading(false);
129
- }, 1000);
130
- };
131
-
132
- const onPressHelpCenter = () => {
133
- const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
134
- context?.autoTracking?.({
135
- ...context,
136
- componentName: 'IconButton',
137
- componentId: 'navigation_helpcenter',
138
- screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
139
- });
140
-
141
- navigator?.maxApi?.dispatchFunction?.('showHelpCenter', context);
142
- };
143
-
144
- const onPressIconMore = () => {
145
- const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
146
- context?.autoTracking?.({
147
- ...context,
148
- componentName: 'IconButton',
149
- componentId: 'navigation_more',
150
- screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
151
- });
152
-
153
- navigator?.maxApi?.dispatchFunction?.(
154
- 'showTools',
155
- {
156
- useSystemTools,
157
- tools,
158
- context,
159
- },
160
- (key: string) => {
161
- for (const group of tools) {
162
- const pressedTool = group?.items?.find?.(
163
- (tool: Tool) => tool?.key === key,
164
- );
165
- if (pressedTool) {
166
- pressedTool?.onPress();
167
- break;
168
- }
169
- }
170
- },
171
- );
172
- };
173
-
174
- let iconShortcut = isFavorite ? 'pin_star_checked' : 'pin_star';
175
- let shortcutOnPress = onPressShortcut;
176
- const totalTools = tools.reduce(
177
- (count: number, group: ToolGroup) => count + group?.items?.length,
178
- 0,
179
- );
180
- const showIconMore = tools && totalTools > 1;
181
- const isHaveOneTool = tools && totalTools === 1;
182
-
183
- if (showIconMore || useMore) {
184
- iconShortcut = 'navigation_more_icon';
185
- shortcutOnPress = onPressIconMore;
186
- } else if (isHaveOneTool) {
187
- const singleToolGroup = tools.find(
188
- (group: ToolGroup) => group?.items?.length === 1,
189
- );
190
- const singleTool = singleToolGroup?.items[0];
191
- iconShortcut = singleTool?.icon;
192
- shortcutOnPress = () => {
193
- singleTool?.onPress?.();
194
- const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
195
- context?.autoTracking?.({
196
- ...context,
197
- componentName: 'IconButton',
198
- componentId: 'navigation_shortcut',
199
- screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
200
- });
201
- };
202
- }
203
-
204
- const showBadge = tools.some((group: ToolGroup) => {
205
- return group?.items?.some?.(tool => tool?.showBadge);
206
- });
207
-
208
- return {
209
- isLoading,
210
- iconShortcut,
211
- shortcutOnPress,
212
- showBadge,
213
- onPressHelpCenter,
214
- onClose,
215
- };
216
- };
217
-
218
- export { useToolkitActions };
@@ -1,66 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import {
3
- StyleProp,
4
- StyleSheet,
5
- TouchableOpacity,
6
- ViewStyle,
7
- } from 'react-native';
8
- import { ApplicationContext } from '../Context';
9
- import { Radius, Spacing } from '../Consts';
10
- import { Icon } from '../Icon';
11
-
12
- // modal spec: icon button 32, icon 20, shared with the Compose / SwiftUI kits
13
- const MODAL_ICON_BUTTON_SIZE = Spacing.XXL;
14
- const MODAL_ICON_SIZE = 20;
15
-
16
- type ModalIconButtonProps = {
17
- icon: string;
18
- onPress: () => void;
19
- accessibilityLabel?: string;
20
- style?: StyleProp<ViewStyle>;
21
- };
22
-
23
- /**
24
- * Close / back button of popups and bottom sheet headers
25
- */
26
- const ModalIconButton: React.FC<ModalIconButtonProps> = ({
27
- icon,
28
- onPress,
29
- accessibilityLabel,
30
- style,
31
- }) => {
32
- const { theme } = useContext(ApplicationContext);
33
- return (
34
- <TouchableOpacity
35
- accessibilityLabel={accessibilityLabel}
36
- onPress={onPress}
37
- style={[
38
- styles.button,
39
- {
40
- backgroundColor: theme.colors.background.surface,
41
- borderColor: theme.colors.border.default,
42
- },
43
- style,
44
- ]}
45
- >
46
- <Icon
47
- source={icon}
48
- color={theme.colors.text.default}
49
- size={MODAL_ICON_SIZE}
50
- />
51
- </TouchableOpacity>
52
- );
53
- };
54
-
55
- const styles = StyleSheet.create({
56
- button: {
57
- width: MODAL_ICON_BUTTON_SIZE,
58
- height: MODAL_ICON_BUTTON_SIZE,
59
- borderRadius: Radius.L,
60
- borderWidth: 1,
61
- alignItems: 'center',
62
- justifyContent: 'center',
63
- },
64
- });
65
-
66
- export { ModalIconButton, MODAL_ICON_BUTTON_SIZE };