@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,54 +1,96 @@
1
- import React, { useCallback, useContext, useEffect, useRef } from 'react';
1
+ import React, {
2
+ useCallback,
3
+ useContext,
4
+ useEffect,
5
+ useRef,
6
+ useState,
7
+ } from 'react';
2
8
  import {
9
+ BackHandler,
10
+ Dimensions,
11
+ Keyboard,
3
12
  KeyboardAvoidingView,
13
+ KeyboardEvent,
14
+ LayoutAnimation,
4
15
  Modal,
5
16
  PanResponder,
6
17
  Platform,
7
18
  Pressable,
19
+ StatusBar,
8
20
  StyleSheet,
21
+ TouchableOpacity,
22
+ useWindowDimensions,
9
23
  View,
10
24
  } from 'react-native';
25
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
11
26
  import { ApplicationContext, MiniAppContext } from '../Context';
12
27
  import { BottomSheetParams } from './types';
28
+ import { Colors, Radius, Spacing, Styles } from '../Consts';
29
+ import { Text } from '../Text';
30
+ import { Icon } from '../Icon';
31
+ import { useHeaderHeight } from '@react-navigation/elements';
13
32
  import Animated, {
14
33
  Easing,
34
+ Extrapolation,
35
+ interpolate,
36
+ useAnimatedStyle,
15
37
  useSharedValue,
16
38
  withSpring,
17
39
  withTiming,
18
40
  } from 'react-native-reanimated';
19
41
  import { scheduleOnRN } from 'react-native-worklets';
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';
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
- */
42
+ import layoutStyles from '../Layout/styles';
43
+ import { DuoMetrics, InnerEdgeStyles, useScreenLayout } from '../Layout/utils';
44
+ import { getDuoTopInset, isIPhoneDuo } from './device';
45
+ import { SideBarButton } from './Components/SideBarButton';
46
+
47
+ // iPhone Duo inner display: center the sheet instead of spanning the width
48
+ const DUO_REGULAR_MIN_WIDTH = 600;
49
+
50
+ const INDICATOR_HEIGHT = 16;
51
+ const HEADER_HEIGHT = 56;
52
+ const DUO_ORIENTATIONS = ['portrait', 'landscape'];
53
+ const SIDE_COLUMN_OFFSET =
54
+ INDICATOR_HEIGHT + (HEADER_HEIGHT - DuoMetrics.controlSize) / 2;
55
+
56
+ const getSideInset = (inset: number) => Math.max(inset - Spacing.M, 0);
57
+
37
58
  const BottomSheet: React.FC<BottomSheetParams> = props => {
38
59
  const { theme, navigator } = useContext(ApplicationContext);
39
60
  const context = useContext<any>(MiniAppContext);
40
- const {
41
- windowSize,
42
- isDuo,
43
- isFoldable,
44
- placement,
45
- sheet,
46
- scrimOpacity,
47
- heightDevice,
48
- bottomInset,
49
- keyboardOffset,
50
- } = useBottomSheetLayout();
61
+ const windowSize = useWindowDimensions();
62
+ const isDuo = isIPhoneDuo();
63
+ const isDuoCentered =
64
+ isDuo &&
65
+ Math.min(windowSize.width, windowSize.height) >= DUO_REGULAR_MIN_WIDTH;
66
+ const isDuoFloating = isDuo && !isDuoCentered;
67
+ const { sideBar } = useScreenLayout();
68
+ const sideColumnWidth = (sideBar?.width ?? 0) - Spacing.M;
69
+ const sideColumn =
70
+ isDuoFloating &&
71
+ sideColumnWidth >= DuoMetrics.controlSize + Spacing.M &&
72
+ sideBar
73
+ ? sideBar
74
+ : undefined;
75
+ const hasSideColumn = !!sideColumn;
76
+ // 'screen' is the outer display on iPhone Duo, even when unfolded
77
+ const screenHeight = Dimensions.get('screen').height;
78
+ const heightDevice = isDuo ? windowSize.height : screenHeight;
51
79
  const action = useRef<undefined | string>(undefined);
80
+ const insets = useSafeAreaInsets();
81
+ const heightHeader = useHeaderHeight();
82
+ const topGap = Math.max(
83
+ sideColumn
84
+ ? insets.top
85
+ : getDuoTopInset(insets, windowSize.width, windowSize.height),
86
+ Spacing.XL,
87
+ );
88
+ const sideInsetLeft = isDuoFloating ? getSideInset(insets.left) : 0;
89
+ const sideInsetRight = isDuoFloating ? getSideInset(insets.right) : 0;
90
+ const indicatorShift = (sideInsetRight - sideInsetLeft) / 2;
91
+ const isIOS = Platform.OS === 'ios';
92
+ const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
93
+ const keyboardOffset = heightHeader - bottomInset;
52
94
 
53
95
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
54
96
 
@@ -70,13 +112,44 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
70
112
  const translateY = useSharedValue(heightDevice);
71
113
  const onDismissRef = useRef(props.route.params?.onDismiss);
72
114
  onDismissRef.current = props.route.params?.onDismiss;
73
- const keyboardLift = useDuoKeyboardLift(
115
+ const [keyboardLift, setKeyboardLift] = useState(0);
116
+ const [sheetTop, setSheetTop] = useState(windowSize.height);
117
+
118
+ // KeyboardAvoidingView lifts the whole sheet past the top on iPhone Duo,
119
+ // so lift it here and shrink maxHeight by the same amount instead
120
+ useEffect(() => {
121
+ if (!isDuo || !useKeyboardAvoidingView) {
122
+ return;
123
+ }
124
+ const onKeyboardChange = (e: KeyboardEvent) => {
125
+ const overlap = windowSize.height - e.endCoordinates.screenY;
126
+ const lift = Math.max(
127
+ overlap - bottomInset - (keyboardVerticalOffset ?? 0),
128
+ 0,
129
+ );
130
+ if (e.duration) {
131
+ LayoutAnimation.configureNext({
132
+ duration: e.duration,
133
+ update: {
134
+ duration: e.duration,
135
+ type: LayoutAnimation.Types[e.easing] || 'keyboard',
136
+ },
137
+ });
138
+ }
139
+ setKeyboardLift(lift);
140
+ };
141
+ const subscriptions = [
142
+ Keyboard.addListener('keyboardWillChangeFrame', onKeyboardChange),
143
+ Keyboard.addListener('keyboardWillHide', onKeyboardChange),
144
+ ];
145
+ return () => subscriptions.forEach(sub => sub.remove());
146
+ }, [
147
+ bottomInset,
74
148
  isDuo,
149
+ keyboardVerticalOffset,
75
150
  useKeyboardAvoidingView,
76
151
  windowSize.height,
77
- bottomInset,
78
- keyboardVerticalOffset,
79
- );
152
+ ]);
80
153
 
81
154
  const openAnimation = useCallback(() => {
82
155
  translateY.value = withTiming(0, {
@@ -102,9 +175,8 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
102
175
  const panResponder = useRef(
103
176
  PanResponder.create({
104
177
  onStartShouldSetPanResponder: () => draggable,
105
- onMoveShouldSetPanResponder: (_, gestureState) => {
106
- return draggable && gestureState.dy > 0;
107
- },
178
+ onMoveShouldSetPanResponder: (_, gestureState) =>
179
+ draggable && gestureState.dy > 0,
108
180
  onPanResponderMove: (_, gestureState) => {
109
181
  if (gestureState.dy > 0) {
110
182
  translateY.value = gestureState.dy;
@@ -136,7 +208,10 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
136
208
  backgroundColor = theme.colors.background.surface;
137
209
  }
138
210
 
139
- // Mount only, so folding or rotating iPhone Duo doesn't emit a dismiss.
211
+ /**
212
+ * emit dismiss event, once: folding or rotating iPhone Duo changes the
213
+ * window height while the sheet stays open
214
+ */
140
215
  useEffect(() => {
141
216
  openAnimation();
142
217
  return () => {
@@ -144,35 +219,204 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
144
219
  };
145
220
  }, [openAnimation]);
146
221
 
147
- const handlers = useSheetDismiss({
148
- barrierDismissible,
149
- closeAnimation,
150
- navigator,
151
- leftOptions,
152
- action,
153
- });
154
- const { onDismiss, onRequestClose, onPressBack, onPressClose } = handlers;
222
+ /**
223
+ * handler dismiss
224
+ */
225
+ const onDismiss = useCallback(
226
+ (force = false, callback?: () => void) => {
227
+ if (barrierDismissible && !force) {
228
+ return;
229
+ }
230
+ closeAnimation(() => {
231
+ navigator?.pop();
232
+ scheduleOnRN(() => {
233
+ callback?.();
234
+ });
235
+ });
236
+ },
237
+ [barrierDismissible, closeAnimation, navigator],
238
+ );
239
+
240
+ /**
241
+ * on request close
242
+ */
243
+ const onRequestClose = useCallback(
244
+ (callback?: () => void) => {
245
+ onDismiss(true, callback);
246
+ },
247
+ [onDismiss],
248
+ );
249
+
250
+ useEffect(() => {
251
+ const backHandler = BackHandler.addEventListener(
252
+ 'hardwareBackPress',
253
+ () => {
254
+ onDismiss();
255
+ return true;
256
+ },
257
+ );
258
+ return () => backHandler.remove();
259
+ }, [barrierDismissible, onDismiss]);
260
+
261
+ const onPressBack = useCallback(() => {
262
+ onDismiss(true, leftOptions?.onPressIconLeft);
263
+ }, [leftOptions, onDismiss]);
264
+
265
+ const onPressClose = useCallback(() => {
266
+ action.current = 'icon_close';
267
+ onDismiss(true);
268
+ }, [onDismiss]);
155
269
 
156
270
  const showBack = !!leftOptions?.onPressIconLeft;
157
271
  const iconBack = leftOptions?.iconLeft ?? 'ic_back';
272
+ const sideColumnCount = showBack ? 2 : 1;
273
+ const sideColumnHeight =
274
+ sideColumnCount * DuoMetrics.controlSize +
275
+ (sideColumnCount - 1) * Spacing.M;
276
+ const coversStatusBar = !!sideColumn && sheetTop < sideColumn.top;
158
277
 
159
- const headerParams = {
160
- panHandlers: panResponder.panHandlers,
161
- useDivider,
162
- theme,
163
- showBack,
164
- onPressBack,
165
- onPressClose,
278
+ useEffect(() => {
279
+ if (!coversStatusBar) {
280
+ return;
281
+ }
282
+ const entry = StatusBar.pushStackEntry({
283
+ barStyle: theme.dark ? 'light-content' : 'dark-content',
284
+ animated: true,
285
+ });
286
+ return () => StatusBar.popStackEntry(entry);
287
+ }, [coversStatusBar, theme.dark]);
288
+
289
+ /**
290
+ * render header
291
+ */
292
+ const renderHeader = useCallback(() => {
293
+ const showButtons = !hasSideColumn;
294
+ return (
295
+ <View {...panResponder.panHandlers}>
296
+ <View style={{ height: INDICATOR_HEIGHT }}>
297
+ <View
298
+ style={[
299
+ styles.indicator,
300
+ indicatorShift !== 0 && {
301
+ transform: [{ translateX: indicatorShift }],
302
+ },
303
+ ]}
304
+ />
305
+ </View>
306
+ <View
307
+ style={[
308
+ styles.header,
309
+ useDivider && {
310
+ borderBottomColor: theme.colors.border.default,
311
+ borderBottomWidth: 1,
312
+ },
313
+ ]}
314
+ >
315
+ {showButtons && showBack ? (
316
+ <TouchableOpacity style={styles.iconButton} onPress={onPressBack}>
317
+ <Icon source={iconBack} />
318
+ </TouchableOpacity>
319
+ ) : null}
320
+
321
+ {options.header ? (
322
+ <View style={Styles.flex}>{options.header}</View>
323
+ ) : (
324
+ <>
325
+ {showButtons && !leftOptions ? (
326
+ <View style={styles.iconButton} />
327
+ ) : null}
328
+ <Text
329
+ style={[
330
+ Styles.flex,
331
+ styles.title,
332
+ !showButtons && styles.titleInset,
333
+ ]}
334
+ numberOfLines={1}
335
+ typography="header_default_bold"
336
+ >
337
+ {options.title ?? ''}
338
+ </Text>
339
+ </>
340
+ )}
341
+ {showButtons ? (
342
+ <TouchableOpacity style={styles.iconButton} onPress={onPressClose}>
343
+ <Icon source="navigation_close" />
344
+ </TouchableOpacity>
345
+ ) : null}
346
+ </View>
347
+ </View>
348
+ );
349
+ }, [
350
+ hasSideColumn,
166
351
  iconBack,
167
- options,
352
+ indicatorShift,
168
353
  leftOptions,
354
+ onPressBack,
355
+ onPressClose,
356
+ options.header,
357
+ options.title,
358
+ panResponder.panHandlers,
359
+ showBack,
360
+ theme.colors.border.default,
361
+ useDivider,
362
+ ]);
363
+
364
+ /**
365
+ * iPhone Duo folded: back and close move to the side bar column, drawn on
366
+ * the part of the sheet under the side safe area. They line up with the
367
+ * header row, stay below the status bar cluster on a tall sheet and above a
368
+ * camera at the bottom end of the strip.
369
+ */
370
+ const renderSideColumn = () => {
371
+ if (!sideColumn) {
372
+ return null;
373
+ }
374
+ const lowestTop =
375
+ windowSize.height - sideColumn.bottom - sideColumnHeight - sheetTop;
376
+ const top = Math.min(
377
+ Math.max(sideColumn.top - sheetTop, SIDE_COLUMN_OFFSET),
378
+ lowestTop,
379
+ );
380
+
381
+ return (
382
+ <View
383
+ pointerEvents={'box-none'}
384
+ style={[
385
+ styles.sideColumn,
386
+ sideColumn.edge === 'right' ? styles.alignRight : styles.alignLeft,
387
+ InnerEdgeStyles[sideColumn.edge],
388
+ { top, width: sideColumnWidth },
389
+ ]}
390
+ >
391
+ {showBack ? (
392
+ <SideBarButton icon={iconBack} onPress={onPressBack} />
393
+ ) : null}
394
+ <SideBarButton icon="navigation_close" onPress={onPressClose} />
395
+ </View>
396
+ );
169
397
  };
170
398
 
171
- const { animatedStyle, animatedOverlayStyle } = useSheetAnimatedStyles(
172
- translateY,
173
- heightDevice,
174
- scrimOpacity,
175
- );
399
+ const animatedStyle = useAnimatedStyle(() => {
400
+ return {
401
+ transform: [{ translateY: translateY.value }],
402
+ };
403
+ });
404
+
405
+ const animatedOverlayStyle = useAnimatedStyle(() => {
406
+ return {
407
+ opacity: interpolate(
408
+ translateY.value,
409
+ [0, heightDevice],
410
+ [1, 0],
411
+ Extrapolation.CLAMP,
412
+ ),
413
+ };
414
+ });
415
+
416
+ const sideInsetStyle = isDuoFloating && {
417
+ paddingLeft: sideInsetLeft,
418
+ paddingRight: sideInsetRight,
419
+ };
176
420
 
177
421
  const screen = (
178
422
  <Screen
@@ -182,24 +426,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
182
426
  />
183
427
  );
184
428
 
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
-
203
429
  return (
204
430
  <Container
205
431
  transparent
@@ -232,21 +458,64 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
232
458
  </Pressable>
233
459
 
234
460
  <Animated.View
461
+ onLayout={
462
+ isDuoFloating ? e => setSheetTop(e.nativeEvent.layout.y) : undefined
463
+ }
235
464
  style={[
236
465
  animatedStyle,
237
- getSheetStyle({
466
+ {
238
467
  backgroundColor,
239
- isDuo,
240
- isFoldable,
241
- placement,
242
- sheet,
243
- keyboardLift,
244
- showBaseLineDebug,
245
- }),
468
+ borderTopLeftRadius: isDuo ? Radius.XL : Radius.M,
469
+ borderTopRightRadius: isDuo ? Radius.XL : Radius.M,
470
+ overflow: 'hidden',
471
+ },
472
+ isDuo && {
473
+ maxHeight: windowSize.height - topGap - keyboardLift,
474
+ marginBottom: keyboardLift,
475
+ },
476
+ isDuoFloating && { marginHorizontal: Spacing.M },
477
+ sideColumn && {
478
+ minHeight:
479
+ SIDE_COLUMN_OFFSET + sideColumnHeight + sideColumn.bottom,
480
+ },
481
+ isDuoCentered && {
482
+ // keeps the portrait width in landscape, like system sheets
483
+ width: Math.min(
484
+ Math.min(windowSize.width, windowSize.height) - Spacing.L * 2,
485
+ windowSize.width -
486
+ Math.max(insets.left, insets.right, Spacing.L) * 2,
487
+ ),
488
+ alignSelf: 'center',
489
+ },
490
+ showBaseLineDebug && styles.debugBaseLine,
246
491
  ]}
247
492
  >
248
- {content}
249
- {renderSheetFooter({ footerComponent, theme })}
493
+ {isDuo ? (
494
+ // content shrinks so a tall sheet keeps its header and footer
495
+ <View style={[styles.shrink, sideInsetStyle]}>
496
+ {renderHeader()}
497
+ <View style={styles.shrink}>{screen}</View>
498
+ </View>
499
+ ) : (
500
+ <>
501
+ {renderHeader()}
502
+ {screen}
503
+ </>
504
+ )}
505
+ {footerComponent && (
506
+ <View
507
+ style={[
508
+ layoutStyles.shadow,
509
+ {
510
+ paddingBottom: Spacing.S,
511
+ backgroundColor: theme.colors.background.surface,
512
+ },
513
+ sideInsetStyle,
514
+ ]}
515
+ >
516
+ {footerComponent}
517
+ </View>
518
+ )}
250
519
  {useBottomInset && (
251
520
  <View
252
521
  style={{
@@ -255,10 +524,53 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
255
524
  }}
256
525
  />
257
526
  )}
527
+ {renderSideColumn()}
258
528
  </Animated.View>
259
529
  </KeyboardAvoidingView>
260
530
  </Container>
261
531
  );
262
532
  };
263
533
 
534
+ const styles = StyleSheet.create({
535
+ container: {
536
+ flex: 1,
537
+ justifyContent: 'flex-end',
538
+ },
539
+ overlay: {
540
+ flex: 1,
541
+ backgroundColor: 'rgba(0, 0, 0, 0.6)',
542
+ },
543
+ indicator: {
544
+ width: 40,
545
+ height: 4,
546
+ borderRadius: Radius.S,
547
+ backgroundColor: Colors.black_06,
548
+ position: 'absolute',
549
+ alignSelf: 'center',
550
+ top: Spacing.S,
551
+ },
552
+ header: {
553
+ height: HEADER_HEIGHT,
554
+ flexDirection: 'row',
555
+ alignItems: 'center',
556
+ },
557
+ title: { textAlign: 'center' },
558
+ titleInset: { paddingHorizontal: Spacing.M },
559
+ iconButton: {
560
+ width: 24,
561
+ height: 24,
562
+ alignItems: 'center',
563
+ justifyContent: 'center',
564
+ marginHorizontal: Spacing.M,
565
+ },
566
+ shrink: { flexShrink: 1 },
567
+ sideColumn: {
568
+ position: 'absolute',
569
+ gap: Spacing.M,
570
+ },
571
+ alignRight: { right: 0 },
572
+ alignLeft: { left: 0 },
573
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
574
+ });
575
+
264
576
  export default BottomSheet;