@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.
- package/Application/BottomSheet.tsx +398 -86
- package/Application/BottomTab/BottomTabBar.tsx +275 -215
- package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
- package/Application/BottomTab/DuoBarCompression.tsx +28 -14
- package/Application/BottomTab/DuoTabBar.tsx +540 -32
- package/Application/BottomTab/TabBarIcon.tsx +72 -146
- package/Application/BottomTab/index.tsx +353 -89
- package/Application/BottomTab/useLiquidSelection.ts +374 -0
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +5 -7
- package/Application/Components/HeaderAnimated.tsx +13 -41
- package/Application/Components/HeaderBackground.tsx +3 -20
- package/Application/Components/HeaderExtendHeader.tsx +46 -66
- package/Application/Components/HeaderLeft.tsx +18 -5
- package/Application/Components/HeaderRight.tsx +529 -8
- package/Application/Components/HeaderTitle.tsx +579 -16
- package/Application/Components/NavigationButton.tsx +11 -18
- package/Application/Components/SearchHeader.tsx +18 -38
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +18 -41
- package/Application/Navigation.ts +17 -15
- package/Application/NavigationContainer.tsx +21 -23
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tsx +172 -27
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +7 -20
- package/Application/device.ts +52 -0
- package/Application/index.ts +1 -23
- package/Application/types.ts +242 -17
- package/Application/utils.tsx +493 -0
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +39 -47
- package/Badge/Shape.tsx +0 -2
- package/Badge/styles.ts +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +152 -21
- package/Button/styles.ts +1 -1
- package/CheckBox/index.tsx +6 -5
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +11 -11
- package/Divider/index.tsx +7 -21
- package/FoundationList/index.tsx +0 -4
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +12 -4
- package/Image/index.tsx +7 -9
- package/Input/Input.tsx +12 -10
- package/Input/InputDropDown.tsx +13 -10
- package/Input/InputMoney.tsx +152 -45
- package/Input/InputOTP.tsx +34 -36
- package/Input/InputPhoneNumber.tsx +5 -8
- package/Input/InputSearch.tsx +111 -19
- package/Input/InputTextArea.tsx +5 -5
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +17 -31
- package/Input/index.tsx +21 -24
- package/Input/styles.ts +5 -25
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +21 -26
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +17 -34
- package/Layout/Screen.tsx +696 -122
- package/Layout/Section.tsx +7 -9
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/index.ts +4 -10
- package/Layout/styles.ts +0 -2
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +181 -40
- package/Loader/DotLoader.tsx +3 -11
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +6 -3
- package/Loader/Spinner.tsx +3 -11
- package/Loader/styles.ts +0 -4
- package/Loader/utils.ts +7 -11
- package/Pagination/Dot.tsx +0 -4
- package/Pagination/PaginationDot.tsx +0 -1
- package/Pagination/PaginationNumber.tsx +3 -5
- package/Pagination/PaginationScroll.tsx +0 -5
- package/Pagination/PaginationWhiteDot.tsx +0 -1
- package/Pagination/index.tsx +0 -4
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +102 -94
- package/Popup/PopupPromotion.tsx +11 -9
- package/Popup/types.ts +4 -11
- package/Popup/utils.ts +18 -50
- package/Radio/index.tsx +10 -6
- package/Radio/styles.ts +0 -6
- package/Skeleton/index.tsx +9 -9
- package/Skeleton/styles.ts +0 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +4 -8
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +5 -25
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +40 -42
- package/Title/styles.ts +0 -6
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -2
- package/Application/BottomSheet.hooks.ts +0 -195
- package/Application/BottomSheet.parts.tsx +0 -157
- package/Application/BottomSheet.styles.ts +0 -43
- package/Application/BottomTab/ActiveIndicator.tsx +0 -91
- package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
- package/Application/BottomTab/BottomTabInset.tsx +0 -18
- package/Application/BottomTab/CurvedContainer.tsx +0 -155
- package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
- package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
- package/Application/BottomTab/TabScreen.tsx +0 -160
- package/Application/BottomTab/metrics.ts +0 -164
- package/Application/BottomTab/tabItems.ts +0 -46
- package/Application/BottomTab/usePressLift.ts +0 -32
- package/Application/Components/HeaderRight.styles.ts +0 -146
- package/Application/Components/HeaderTitle.shared.ts +0 -44
- package/Application/Components/HeaderTitle.styles.ts +0 -125
- package/Application/Components/HeaderToolkitAction.tsx +0 -180
- package/Application/Components/SwipeBackHaptic.tsx +0 -95
- package/Application/Components/TitleJourney.tsx +0 -110
- package/Application/Components/TitleLocation.tsx +0 -73
- package/Application/Components/TitleUser.tsx +0 -304
- package/Application/Components/useToolkitActions.tsx +0 -218
- package/Application/ModalIconButton.tsx +0 -66
- package/Application/StackScreen.tracking.ts +0 -143
- package/Application/headerLayout.ts +0 -158
- package/Application/hooks.ts +0 -137
- package/Application/modalLayout.ts +0 -176
- package/Application/navigationOptions.tsx +0 -212
- package/Application/types.header.ts +0 -121
- package/Application/types.tabs.ts +0 -48
- package/Application/types.theme.ts +0 -87
- package/Application/utils.ts +0 -107
- package/Button/utils.ts +0 -133
- package/Input/InputMoneyView.tsx +0 -194
- package/Input/SearchTextTyping.tsx +0 -108
- package/Input/moneyUtils.ts +0 -23
- package/Layout/layoutMetrics.ts +0 -58
- package/Layout/layoutTypes.ts +0 -86
- package/Layout/screenContent.tsx +0 -92
- package/Layout/screenFooter.tsx +0 -63
- package/Layout/screenHeader.tsx +0 -321
- package/Layout/screenQuickReturn.tsx +0 -64
- package/Layout/screenScroll.ts +0 -107
- package/Layout/screenTypes.ts +0 -143
|
@@ -1,54 +1,96 @@
|
|
|
1
|
-
import 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
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
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
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
466
|
+
{
|
|
238
467
|
backgroundColor,
|
|
239
|
-
isDuo,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
{
|
|
249
|
-
|
|
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;
|