@momo-kits/foundation 0.168.1-beta.36 → 0.168.1-beta.38

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 (138) hide show
  1. package/Application/BottomSheet.hooks.ts +25 -45
  2. package/Application/BottomSheet.parts.tsx +79 -153
  3. package/Application/BottomSheet.styles.ts +7 -23
  4. package/Application/BottomSheet.tsx +86 -268
  5. package/Application/BottomTab/ActiveIndicator.tsx +15 -14
  6. package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
  7. package/Application/BottomTab/BottomTabBar.tsx +53 -134
  8. package/Application/BottomTab/BottomTabInset.tsx +8 -4
  9. package/Application/BottomTab/CurvedContainer.tsx +14 -12
  10. package/Application/BottomTab/CustomBottomTabItem.tsx +13 -13
  11. package/Application/BottomTab/DuoBarCompression.tsx +13 -19
  12. package/Application/BottomTab/DuoRailTabBar.tsx +223 -0
  13. package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
  14. package/Application/BottomTab/DuoTabBar.tsx +20 -315
  15. package/Application/BottomTab/TabBarIcon.tsx +15 -29
  16. package/Application/BottomTab/TabScreen.tsx +160 -0
  17. package/Application/BottomTab/index.tsx +40 -194
  18. package/Application/BottomTab/metrics.ts +23 -23
  19. package/Application/BottomTab/tabItems.ts +1 -1
  20. package/Application/BottomTab/usePressLift.ts +2 -2
  21. package/Application/Components/BackgroundImageView.tsx +4 -0
  22. package/Application/Components/DuoGlassBackground.tsx +5 -4
  23. package/Application/Components/HeaderAnimated.tsx +40 -12
  24. package/Application/Components/HeaderBackground.tsx +19 -2
  25. package/Application/Components/HeaderExtendHeader.tsx +56 -34
  26. package/Application/Components/HeaderLeft.tsx +4 -2
  27. package/Application/Components/HeaderRight.styles.ts +15 -9
  28. package/Application/Components/HeaderRight.tsx +2 -1
  29. package/Application/Components/HeaderTitle.shared.ts +19 -12
  30. package/Application/Components/HeaderTitle.tsx +4 -3
  31. package/Application/Components/HeaderToolkitAction.tsx +28 -22
  32. package/Application/Components/NavigationButton.tsx +10 -6
  33. package/Application/Components/SearchHeader.tsx +41 -15
  34. package/Application/Components/TitleJourney.tsx +2 -2
  35. package/Application/Components/TitleLocation.tsx +2 -2
  36. package/Application/Components/TitleUser.tsx +2 -2
  37. package/Application/Components/useToolkitActions.tsx +17 -32
  38. package/Application/Localize.ts +7 -0
  39. package/Application/ModalScreen.tsx +10 -4
  40. package/Application/Navigation.ts +14 -16
  41. package/Application/NavigationContainer.tsx +19 -16
  42. package/Application/Navigator.ts +20 -48
  43. package/Application/ScaleSizeProvider.tsx +13 -6
  44. package/Application/StackScreen.tracking.ts +11 -26
  45. package/Application/StackScreen.tsx +17 -35
  46. package/Application/TooltipPortal.tsx +12 -5
  47. package/Application/WidgetContainer.tsx +10 -4
  48. package/Application/headerLayout.ts +158 -0
  49. package/Application/index.ts +17 -3
  50. package/Application/modalLayout.ts +15 -19
  51. package/Application/navigationOptions.tsx +27 -32
  52. package/Application/types.header.ts +7 -2
  53. package/Application/types.tabs.ts +5 -0
  54. package/Application/types.ts +17 -245
  55. package/Application/utils.ts +0 -36
  56. package/Badge/Badge.tsx +5 -0
  57. package/Badge/BadgeDot.tsx +1 -0
  58. package/Badge/BadgeDotAnimation.tsx +15 -7
  59. package/Badge/BadgeRibbon.tsx +46 -38
  60. package/Badge/Shape.tsx +2 -0
  61. package/Badge/types.ts +2 -2
  62. package/Button/index.tsx +5 -16
  63. package/Button/utils.ts +9 -15
  64. package/CheckBox/index.tsx +4 -0
  65. package/Consts/theme.ts +10 -10
  66. package/Context/index.ts +5 -1
  67. package/Divider/DashDivider.tsx +1 -0
  68. package/Divider/index.tsx +4 -0
  69. package/FoundationList/index.tsx +4 -0
  70. package/Icon/index.tsx +6 -6
  71. package/Icon/types.ts +1 -1
  72. package/IconButton/index.tsx +4 -12
  73. package/Image/index.tsx +9 -7
  74. package/Input/Input.tsx +8 -9
  75. package/Input/InputDropDown.tsx +10 -12
  76. package/Input/InputMoney.tsx +12 -8
  77. package/Input/InputMoneyView.tsx +14 -7
  78. package/Input/InputOTP.tsx +35 -33
  79. package/Input/InputPhoneNumber.tsx +8 -9
  80. package/Input/InputSearch.tsx +22 -8
  81. package/Input/InputTextArea.tsx +4 -0
  82. package/Input/SearchTextTyping.tsx +4 -0
  83. package/Input/SystemTextInput.tsx +7 -2
  84. package/Input/TextTyping.tsx +4 -0
  85. package/Input/common.tsx +26 -12
  86. package/Input/index.tsx +24 -21
  87. package/Input/moneyUtils.ts +10 -4
  88. package/Input/styles.ts +0 -5
  89. package/Input/utils.ts +14 -12
  90. package/Layout/Card.tsx +7 -4
  91. package/Layout/FloatingButton.tsx +4 -0
  92. package/Layout/Item.tsx +6 -2
  93. package/Layout/ItemList.tsx +9 -7
  94. package/Layout/ItemSectionList.tsx +2 -1
  95. package/Layout/ReservedRegions.tsx +25 -25
  96. package/Layout/Screen.tsx +112 -696
  97. package/Layout/Section.tsx +8 -5
  98. package/Layout/TrackingScope.tsx +1 -0
  99. package/Layout/index.ts +8 -3
  100. package/Layout/screenContent.tsx +92 -0
  101. package/Layout/screenFooter.tsx +63 -0
  102. package/Layout/screenHeader.tsx +321 -0
  103. package/Layout/screenQuickReturn.tsx +64 -0
  104. package/Layout/screenScroll.ts +107 -0
  105. package/Layout/screenTypes.ts +143 -0
  106. package/Layout/types.ts +2 -4
  107. package/Layout/utils.ts +31 -37
  108. package/Loader/DotLoader.tsx +4 -0
  109. package/Loader/Loader.tsx +4 -0
  110. package/Loader/ProgressBar.tsx +1 -0
  111. package/Loader/Spinner.tsx +4 -0
  112. package/Loader/utils.ts +11 -7
  113. package/Pagination/Dot.tsx +4 -0
  114. package/Pagination/PaginationDot.tsx +1 -0
  115. package/Pagination/PaginationNumber.tsx +5 -3
  116. package/Pagination/PaginationScroll.tsx +5 -0
  117. package/Pagination/PaginationWhiteDot.tsx +1 -0
  118. package/Pagination/index.tsx +4 -0
  119. package/Pagination/types.ts +2 -2
  120. package/Popup/PopupNotify.tsx +44 -48
  121. package/Popup/PopupPromotion.tsx +4 -7
  122. package/Popup/types.ts +4 -4
  123. package/Popup/utils.ts +4 -0
  124. package/Radio/index.tsx +4 -0
  125. package/Skeleton/index.tsx +8 -0
  126. package/Switch/index.tsx +1 -0
  127. package/Tag/index.tsx +5 -1
  128. package/Tag/types.ts +3 -3
  129. package/Text/index.tsx +14 -3
  130. package/Text/styles.ts +1 -1
  131. package/Text/types.ts +1 -6
  132. package/Text/utils.ts +20 -4
  133. package/Title/index.tsx +41 -32
  134. package/ViewBoundary/index.tsx +4 -2
  135. package/index.ts +0 -6
  136. package/package.json +7 -7
  137. package/Application/__tests__/modalLayout.test.ts +0 -128
  138. package/Application/device.ts +0 -21
@@ -1,65 +1,54 @@
1
- import React, {
2
- useCallback,
3
- useContext,
4
- useEffect,
5
- useRef,
6
- useState,
7
- } from 'react';
1
+ import React, { useCallback, useContext, useEffect, useRef } from 'react';
8
2
  import {
9
- BackHandler,
10
- Dimensions,
11
- Keyboard,
12
3
  KeyboardAvoidingView,
13
- KeyboardEvent,
14
- LayoutAnimation,
15
4
  Modal,
16
5
  PanResponder,
17
6
  Platform,
18
7
  Pressable,
19
8
  StyleSheet,
20
- useWindowDimensions,
21
9
  View,
22
10
  } from 'react-native';
23
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
24
11
  import { ApplicationContext, MiniAppContext } from '../Context';
25
12
  import { BottomSheetParams } from './types';
26
- import { Colors, Radius, Spacing, Styles } from '../Consts';
27
- import { Text } from '../Text';
28
- import { useHeaderHeight } from '@react-navigation/elements';
29
13
  import Animated, {
30
14
  Easing,
31
- Extrapolation,
32
- interpolate,
33
- useAnimatedStyle,
34
15
  useSharedValue,
35
16
  withSpring,
36
17
  withTiming,
37
18
  } from 'react-native-reanimated';
38
19
  import { scheduleOnRN } from 'react-native-worklets';
39
- import layoutStyles from '../Layout/styles';
40
- import { isIPhoneDuo } from './device';
41
- import { useModalLayout } from './modalLayout';
42
- import { MODAL_ICON_BUTTON_SIZE, ModalIconButton } from './ModalIconButton';
43
-
44
- const INDICATOR_HEIGHT = 16;
45
- const HEADER_HEIGHT = 56;
46
- const DUO_ORIENTATIONS = ['portrait', 'landscape'];
20
+ import { DUO_ORIENTATIONS, styles } from './BottomSheet.styles';
21
+ import {
22
+ useBottomSheetLayout,
23
+ useDuoKeyboardLift,
24
+ useSheetDismiss,
25
+ useSheetAnimatedStyles,
26
+ } from './BottomSheet.hooks';
27
+ import {
28
+ getSheetStyle,
29
+ renderSheetFooter,
30
+ renderSheetHeader,
31
+ } from './BottomSheet.parts';
47
32
 
33
+ /**
34
+ * Bottom sheet route of the modal stack: slides the given screen up under a
35
+ * drag handle and header, and reports how it was closed through `onDismiss`.
36
+ */
48
37
  const BottomSheet: React.FC<BottomSheetParams> = props => {
49
38
  const { theme, navigator } = useContext(ApplicationContext);
50
39
  const context = useContext<any>(MiniAppContext);
51
- const windowSize = useWindowDimensions();
52
- const isDuo = isIPhoneDuo();
53
- const { isFoldable, placement, sheet, scrimOpacity } = useModalLayout();
54
- // 'screen' is the outer display on iPhone Duo, even when unfolded
55
- const screenHeight = Dimensions.get('screen').height;
56
- const heightDevice = isDuo ? windowSize.height : screenHeight;
40
+ const {
41
+ windowSize,
42
+ isDuo,
43
+ isFoldable,
44
+ placement,
45
+ sheet,
46
+ scrimOpacity,
47
+ heightDevice,
48
+ bottomInset,
49
+ keyboardOffset,
50
+ } = useBottomSheetLayout();
57
51
  const action = useRef<undefined | string>(undefined);
58
- const insets = useSafeAreaInsets();
59
- const heightHeader = useHeaderHeight();
60
- const isIOS = Platform.OS === 'ios';
61
- const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
62
- const keyboardOffset = heightHeader - bottomInset;
63
52
 
64
53
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
65
54
 
@@ -81,43 +70,13 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
81
70
  const translateY = useSharedValue(heightDevice);
82
71
  const onDismissRef = useRef(props.route.params?.onDismiss);
83
72
  onDismissRef.current = props.route.params?.onDismiss;
84
- const [keyboardLift, setKeyboardLift] = useState(0);
85
-
86
- // KeyboardAvoidingView lifts the whole sheet past the top on iPhone Duo,
87
- // so lift it here and shrink maxHeight by the same amount instead
88
- useEffect(() => {
89
- if (!isDuo || !useKeyboardAvoidingView) {
90
- return;
91
- }
92
- const onKeyboardChange = (e: KeyboardEvent) => {
93
- const overlap = windowSize.height - e.endCoordinates.screenY;
94
- const lift = Math.max(
95
- overlap - bottomInset - (keyboardVerticalOffset ?? 0),
96
- 0,
97
- );
98
- if (e.duration) {
99
- LayoutAnimation.configureNext({
100
- duration: e.duration,
101
- update: {
102
- duration: e.duration,
103
- type: LayoutAnimation.Types[e.easing] || 'keyboard',
104
- },
105
- });
106
- }
107
- setKeyboardLift(lift);
108
- };
109
- const subscriptions = [
110
- Keyboard.addListener('keyboardWillChangeFrame', onKeyboardChange),
111
- Keyboard.addListener('keyboardWillHide', onKeyboardChange),
112
- ];
113
- return () => subscriptions.forEach(sub => sub.remove());
114
- }, [
115
- bottomInset,
73
+ const keyboardLift = useDuoKeyboardLift(
116
74
  isDuo,
117
- keyboardVerticalOffset,
118
75
  useKeyboardAvoidingView,
119
76
  windowSize.height,
120
- ]);
77
+ bottomInset,
78
+ keyboardVerticalOffset,
79
+ );
121
80
 
122
81
  const openAnimation = useCallback(() => {
123
82
  translateY.value = withTiming(0, {
@@ -143,8 +102,9 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
143
102
  const panResponder = useRef(
144
103
  PanResponder.create({
145
104
  onStartShouldSetPanResponder: () => draggable,
146
- onMoveShouldSetPanResponder: (_, gestureState) =>
147
- draggable && gestureState.dy > 0,
105
+ onMoveShouldSetPanResponder: (_, gestureState) => {
106
+ return draggable && gestureState.dy > 0;
107
+ },
148
108
  onPanResponderMove: (_, gestureState) => {
149
109
  if (gestureState.dy > 0) {
150
110
  translateY.value = gestureState.dy;
@@ -176,10 +136,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
176
136
  backgroundColor = theme.colors.background.surface;
177
137
  }
178
138
 
179
- /**
180
- * emit dismiss event, once: folding or rotating iPhone Duo changes the
181
- * window height while the sheet stays open
182
- */
139
+ // Mount only, so folding or rotating iPhone Duo doesn't emit a dismiss.
183
140
  useEffect(() => {
184
141
  openAnimation();
185
142
  return () => {
@@ -187,126 +144,35 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
187
144
  };
188
145
  }, [openAnimation]);
189
146
 
190
- /**
191
- * handler dismiss
192
- */
193
- const onDismiss = useCallback(
194
- (force = false, callback?: () => void) => {
195
- if (barrierDismissible && !force) {
196
- return;
197
- }
198
- closeAnimation(() => {
199
- navigator?.pop();
200
- scheduleOnRN(() => {
201
- callback?.();
202
- });
203
- });
204
- },
205
- [barrierDismissible, closeAnimation, navigator],
206
- );
207
-
208
- /**
209
- * on request close
210
- */
211
- const onRequestClose = useCallback(
212
- (callback?: () => void) => {
213
- onDismiss(true, callback);
214
- },
215
- [onDismiss],
216
- );
217
-
218
- useEffect(() => {
219
- const backHandler = BackHandler.addEventListener(
220
- 'hardwareBackPress',
221
- () => {
222
- onDismiss();
223
- return true;
224
- },
225
- );
226
- return () => backHandler.remove();
227
- }, [barrierDismissible, onDismiss]);
228
-
229
- const onPressBack = useCallback(() => {
230
- onDismiss(true, leftOptions?.onPressIconLeft);
231
- }, [leftOptions, onDismiss]);
232
-
233
- const onPressClose = useCallback(() => {
234
- action.current = 'icon_close';
235
- onDismiss(true);
236
- }, [onDismiss]);
147
+ const handlers = useSheetDismiss({
148
+ barrierDismissible,
149
+ closeAnimation,
150
+ navigator,
151
+ leftOptions,
152
+ action,
153
+ });
154
+ const { onDismiss, onRequestClose, onPressBack, onPressClose } = handlers;
237
155
 
238
156
  const showBack = !!leftOptions?.onPressIconLeft;
239
157
  const iconBack = leftOptions?.iconLeft ?? 'ic_back';
240
158
 
241
- /**
242
- * render header
243
- */
244
- const renderHeader = useCallback(() => {
245
- return (
246
- <View {...panResponder.panHandlers}>
247
- <View style={{ height: INDICATOR_HEIGHT }}>
248
- <View style={styles.indicator} />
249
- </View>
250
- <View
251
- style={[
252
- styles.header,
253
- useDivider && {
254
- borderBottomColor: theme.colors.border.default,
255
- borderBottomWidth: 1,
256
- },
257
- ]}
258
- >
259
- {showBack ? (
260
- <ModalIconButton icon={iconBack} onPress={onPressBack} />
261
- ) : null}
262
-
263
- {options.header ? (
264
- <View style={Styles.flex}>{options.header}</View>
265
- ) : (
266
- <>
267
- {!leftOptions ? <View style={styles.iconButtonSpace} /> : null}
268
- <Text
269
- style={[Styles.flex, styles.title]}
270
- numberOfLines={1}
271
- typography="header_default_bold"
272
- >
273
- {options.title ?? ''}
274
- </Text>
275
- </>
276
- )}
277
- <ModalIconButton icon="navigation_close" onPress={onPressClose} />
278
- </View>
279
- </View>
280
- );
281
- }, [
282
- iconBack,
283
- leftOptions,
159
+ const headerParams = {
160
+ panHandlers: panResponder.panHandlers,
161
+ useDivider,
162
+ theme,
163
+ showBack,
284
164
  onPressBack,
285
165
  onPressClose,
286
- options.header,
287
- options.title,
288
- panResponder.panHandlers,
289
- showBack,
290
- theme.colors.border.default,
291
- useDivider,
292
- ]);
293
-
294
- const animatedStyle = useAnimatedStyle(() => {
295
- return {
296
- transform: [{ translateY: translateY.value }],
297
- };
298
- });
166
+ iconBack,
167
+ options,
168
+ leftOptions,
169
+ };
299
170
 
300
- const animatedOverlayStyle = useAnimatedStyle(() => {
301
- return {
302
- opacity: interpolate(
303
- translateY.value,
304
- [0, heightDevice],
305
- [scrimOpacity, 0],
306
- Extrapolation.CLAMP,
307
- ),
308
- };
309
- });
171
+ const { animatedStyle, animatedOverlayStyle } = useSheetAnimatedStyles(
172
+ translateY,
173
+ heightDevice,
174
+ scrimOpacity,
175
+ );
310
176
 
311
177
  const screen = (
312
178
  <Screen
@@ -316,6 +182,24 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
316
182
  />
317
183
  );
318
184
 
185
+ let content: React.ReactNode;
186
+ if (isFoldable) {
187
+ // Content shrinks so a tall sheet keeps its header and footer.
188
+ content = (
189
+ <View style={styles.shrink}>
190
+ {renderSheetHeader(headerParams)}
191
+ <View style={styles.shrink}>{screen}</View>
192
+ </View>
193
+ );
194
+ } else {
195
+ content = (
196
+ <>
197
+ {renderSheetHeader(headerParams)}
198
+ {screen}
199
+ </>
200
+ );
201
+ }
202
+
319
203
  return (
320
204
  <Container
321
205
  transparent
@@ -350,51 +234,19 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
350
234
  <Animated.View
351
235
  style={[
352
236
  animatedStyle,
353
- {
237
+ getSheetStyle({
354
238
  backgroundColor,
355
- borderTopLeftRadius: sheet.radius,
356
- borderTopRightRadius: sheet.radius,
357
- overflow: 'hidden',
358
- },
359
- isDuo && { marginBottom: keyboardLift },
360
- isFoldable &&
361
- sheet.width !== undefined &&
362
- sheet.maxHeight !== undefined && {
363
- // centered in the placement area, clear of the iPhone Duo
364
- // control column and on the right half when half folded
365
- width: sheet.width,
366
- marginLeft: placement.x + (placement.width - sheet.width) / 2,
367
- maxHeight: sheet.maxHeight - keyboardLift,
368
- minHeight: sheet.minHeight,
369
- },
370
- showBaseLineDebug && styles.debugBaseLine,
239
+ isDuo,
240
+ isFoldable,
241
+ placement,
242
+ sheet,
243
+ keyboardLift,
244
+ showBaseLineDebug,
245
+ }),
371
246
  ]}
372
247
  >
373
- {isFoldable ? (
374
- // content shrinks so a tall sheet keeps its header and footer
375
- <View style={styles.shrink}>
376
- {renderHeader()}
377
- <View style={styles.shrink}>{screen}</View>
378
- </View>
379
- ) : (
380
- <>
381
- {renderHeader()}
382
- {screen}
383
- </>
384
- )}
385
- {footerComponent && (
386
- <View
387
- style={[
388
- layoutStyles.shadow,
389
- {
390
- paddingBottom: Spacing.S,
391
- backgroundColor: theme.colors.background.surface,
392
- },
393
- ]}
394
- >
395
- {footerComponent}
396
- </View>
397
- )}
248
+ {content}
249
+ {renderSheetFooter({ footerComponent, theme })}
398
250
  {useBottomInset && (
399
251
  <View
400
252
  style={{
@@ -409,38 +261,4 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
409
261
  );
410
262
  };
411
263
 
412
- const styles = StyleSheet.create({
413
- container: {
414
- flex: 1,
415
- justifyContent: 'flex-end',
416
- },
417
- overlay: {
418
- flex: 1,
419
- backgroundColor: Colors.black_20,
420
- },
421
- indicator: {
422
- width: 40,
423
- height: 4,
424
- borderRadius: Radius.S,
425
- backgroundColor: Colors.black_06,
426
- position: 'absolute',
427
- alignSelf: 'center',
428
- top: Spacing.S,
429
- },
430
- header: {
431
- height: HEADER_HEIGHT,
432
- flexDirection: 'row',
433
- alignItems: 'center',
434
- paddingHorizontal: Spacing.M,
435
- gap: Spacing.S,
436
- },
437
- title: { textAlign: 'center' },
438
- iconButtonSpace: {
439
- width: MODAL_ICON_BUTTON_SIZE,
440
- height: MODAL_ICON_BUTTON_SIZE,
441
- },
442
- shrink: { flexShrink: 1 },
443
- debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
444
- });
445
-
446
264
  export default BottomSheet;
@@ -19,8 +19,8 @@ type Props = {
19
19
  };
20
20
 
21
21
  /**
22
- * one active indicator per bar (Background/tonal with its inner shadows) sliding to the
23
- * selected item; it lands in place on the first measure and slides from then on
22
+ * The single active indicator of a bar (Background/tonal with inner shadows) that slides
23
+ * to the selected item. It lands in place on the first measure and slides from then on.
24
24
  */
25
25
  const ActiveIndicator: React.FC<Props> = ({
26
26
  axis,
@@ -49,18 +49,19 @@ const ActiveIndicator: React.FC<Props> = ({
49
49
  position.value = withTiming(offset, TabBarMotion.indicator);
50
50
  }, [offset, extent, position, size, visible]);
51
51
 
52
- const animatedStyle = useAnimatedStyle(() =>
53
- axis === 'x'
54
- ? {
55
- opacity: visible.value,
56
- width: size.value,
57
- transform: [{ translateX: position.value }],
58
- }
59
- : {
60
- opacity: visible.value,
61
- transform: [{ translateY: position.value }],
62
- },
63
- );
52
+ const animatedStyle = useAnimatedStyle(() => {
53
+ if (axis === 'x') {
54
+ return {
55
+ opacity: visible.value,
56
+ width: size.value,
57
+ transform: [{ translateX: position.value }],
58
+ };
59
+ }
60
+ return {
61
+ opacity: visible.value,
62
+ transform: [{ translateY: position.value }],
63
+ };
64
+ });
64
65
 
65
66
  return (
66
67
  <Animated.View
@@ -0,0 +1,65 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors, Spacing } from '../../Consts';
3
+ import { CTA_SHADOW, TabBarMetrics } from './metrics';
4
+
5
+ export const styles = StyleSheet.create({
6
+ bar: {
7
+ position: 'absolute',
8
+ left: 0,
9
+ right: 0,
10
+ bottom: 0,
11
+ alignItems: 'center',
12
+ },
13
+ // transparent strip that keeps the rising center action touchable
14
+ barCtaRise: {
15
+ paddingTop: TabBarMetrics.ctaLift,
16
+ },
17
+ container: {
18
+ height: TabBarMetrics.height,
19
+ },
20
+ content: {
21
+ flex: 1,
22
+ flexDirection: 'row',
23
+ alignItems: 'center',
24
+ gap: TabBarMetrics.itemGap,
25
+ paddingVertical: TabBarMetrics.paddingVertical,
26
+ paddingHorizontal: TabBarMetrics.paddingHorizontal,
27
+ },
28
+ indicator: {
29
+ height: TabBarMetrics.indicatorHeight,
30
+ },
31
+ ctaSlot: {
32
+ width: TabBarMetrics.ctaSlotWidth,
33
+ alignSelf: 'stretch',
34
+ },
35
+ // the button rises ctaLift above the container top, the label ends on the item baseline
36
+ cta: {
37
+ position: 'absolute',
38
+ left: 0,
39
+ right: 0,
40
+ top: -TabBarMetrics.ctaLift - TabBarMetrics.paddingVertical,
41
+ alignItems: 'center',
42
+ gap: TabBarMetrics.ctaLabelGap,
43
+ },
44
+ ctaButton: {
45
+ boxShadow: CTA_SHADOW,
46
+ width: TabBarMetrics.ctaSize,
47
+ height: TabBarMetrics.ctaSize,
48
+ borderRadius: TabBarMetrics.ctaSize / 2,
49
+ alignItems: 'center',
50
+ justifyContent: 'center',
51
+ },
52
+ // custom label content over the label text, centered and unclipped
53
+ ctaLabelOverlay: {
54
+ ...StyleSheet.absoluteFillObject,
55
+ alignItems: 'center',
56
+ justifyContent: 'center',
57
+ },
58
+ ctaLabel: {
59
+ maxWidth: TabBarMetrics.ctaSlotWidth,
60
+ minHeight: TabBarMetrics.ctaLabelHeight,
61
+ paddingHorizontal: Spacing.XXS,
62
+ justifyContent: 'center',
63
+ },
64
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
65
+ });