@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.
- package/Application/BottomSheet.hooks.ts +25 -45
- package/Application/BottomSheet.parts.tsx +79 -153
- package/Application/BottomSheet.styles.ts +7 -23
- package/Application/BottomSheet.tsx +86 -268
- package/Application/BottomTab/ActiveIndicator.tsx +15 -14
- package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
- package/Application/BottomTab/BottomTabBar.tsx +53 -134
- package/Application/BottomTab/BottomTabInset.tsx +8 -4
- package/Application/BottomTab/CurvedContainer.tsx +14 -12
- package/Application/BottomTab/CustomBottomTabItem.tsx +13 -13
- package/Application/BottomTab/DuoBarCompression.tsx +13 -19
- package/Application/BottomTab/DuoRailTabBar.tsx +223 -0
- package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
- package/Application/BottomTab/DuoTabBar.tsx +20 -315
- package/Application/BottomTab/TabBarIcon.tsx +15 -29
- package/Application/BottomTab/TabScreen.tsx +160 -0
- package/Application/BottomTab/index.tsx +40 -194
- package/Application/BottomTab/metrics.ts +23 -23
- package/Application/BottomTab/tabItems.ts +1 -1
- package/Application/BottomTab/usePressLift.ts +2 -2
- package/Application/Components/BackgroundImageView.tsx +4 -0
- package/Application/Components/DuoGlassBackground.tsx +5 -4
- package/Application/Components/HeaderAnimated.tsx +40 -12
- package/Application/Components/HeaderBackground.tsx +19 -2
- package/Application/Components/HeaderExtendHeader.tsx +56 -34
- package/Application/Components/HeaderLeft.tsx +4 -2
- package/Application/Components/HeaderRight.styles.ts +15 -9
- package/Application/Components/HeaderRight.tsx +2 -1
- package/Application/Components/HeaderTitle.shared.ts +19 -12
- package/Application/Components/HeaderTitle.tsx +4 -3
- package/Application/Components/HeaderToolkitAction.tsx +28 -22
- package/Application/Components/NavigationButton.tsx +10 -6
- package/Application/Components/SearchHeader.tsx +41 -15
- package/Application/Components/TitleJourney.tsx +2 -2
- package/Application/Components/TitleLocation.tsx +2 -2
- package/Application/Components/TitleUser.tsx +2 -2
- package/Application/Components/useToolkitActions.tsx +17 -32
- package/Application/Localize.ts +7 -0
- package/Application/ModalScreen.tsx +10 -4
- package/Application/Navigation.ts +14 -16
- package/Application/NavigationContainer.tsx +19 -16
- package/Application/Navigator.ts +20 -48
- package/Application/ScaleSizeProvider.tsx +13 -6
- package/Application/StackScreen.tracking.ts +11 -26
- package/Application/StackScreen.tsx +17 -35
- package/Application/TooltipPortal.tsx +12 -5
- package/Application/WidgetContainer.tsx +10 -4
- package/Application/headerLayout.ts +158 -0
- package/Application/index.ts +17 -3
- package/Application/modalLayout.ts +15 -19
- package/Application/navigationOptions.tsx +27 -32
- package/Application/types.header.ts +7 -2
- package/Application/types.tabs.ts +5 -0
- package/Application/types.ts +17 -245
- package/Application/utils.ts +0 -36
- package/Badge/Badge.tsx +5 -0
- package/Badge/BadgeDot.tsx +1 -0
- package/Badge/BadgeDotAnimation.tsx +15 -7
- package/Badge/BadgeRibbon.tsx +46 -38
- package/Badge/Shape.tsx +2 -0
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +5 -16
- package/Button/utils.ts +9 -15
- package/CheckBox/index.tsx +4 -0
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +5 -1
- package/Divider/DashDivider.tsx +1 -0
- package/Divider/index.tsx +4 -0
- package/FoundationList/index.tsx +4 -0
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +4 -12
- package/Image/index.tsx +9 -7
- package/Input/Input.tsx +8 -9
- package/Input/InputDropDown.tsx +10 -12
- package/Input/InputMoney.tsx +12 -8
- package/Input/InputMoneyView.tsx +14 -7
- package/Input/InputOTP.tsx +35 -33
- package/Input/InputPhoneNumber.tsx +8 -9
- package/Input/InputSearch.tsx +22 -8
- package/Input/InputTextArea.tsx +4 -0
- package/Input/SearchTextTyping.tsx +4 -0
- package/Input/SystemTextInput.tsx +7 -2
- package/Input/TextTyping.tsx +4 -0
- package/Input/common.tsx +26 -12
- package/Input/index.tsx +24 -21
- package/Input/moneyUtils.ts +10 -4
- package/Input/styles.ts +0 -5
- package/Input/utils.ts +14 -12
- package/Layout/Card.tsx +7 -4
- package/Layout/FloatingButton.tsx +4 -0
- package/Layout/Item.tsx +6 -2
- package/Layout/ItemList.tsx +9 -7
- package/Layout/ItemSectionList.tsx +2 -1
- package/Layout/ReservedRegions.tsx +25 -25
- package/Layout/Screen.tsx +112 -696
- package/Layout/Section.tsx +8 -5
- package/Layout/TrackingScope.tsx +1 -0
- package/Layout/index.ts +8 -3
- package/Layout/screenContent.tsx +92 -0
- package/Layout/screenFooter.tsx +63 -0
- package/Layout/screenHeader.tsx +321 -0
- package/Layout/screenQuickReturn.tsx +64 -0
- package/Layout/screenScroll.ts +107 -0
- package/Layout/screenTypes.ts +143 -0
- package/Layout/types.ts +2 -4
- package/Layout/utils.ts +31 -37
- package/Loader/DotLoader.tsx +4 -0
- package/Loader/Loader.tsx +4 -0
- package/Loader/ProgressBar.tsx +1 -0
- package/Loader/Spinner.tsx +4 -0
- package/Loader/utils.ts +11 -7
- package/Pagination/Dot.tsx +4 -0
- package/Pagination/PaginationDot.tsx +1 -0
- package/Pagination/PaginationNumber.tsx +5 -3
- package/Pagination/PaginationScroll.tsx +5 -0
- package/Pagination/PaginationWhiteDot.tsx +1 -0
- package/Pagination/index.tsx +4 -0
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +44 -48
- package/Popup/PopupPromotion.tsx +4 -7
- package/Popup/types.ts +4 -4
- package/Popup/utils.ts +4 -0
- package/Radio/index.tsx +4 -0
- package/Skeleton/index.tsx +8 -0
- package/Switch/index.tsx +1 -0
- package/Tag/index.tsx +5 -1
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +14 -3
- package/Text/styles.ts +1 -1
- package/Text/types.ts +1 -6
- package/Text/utils.ts +20 -4
- package/Title/index.tsx +41 -32
- package/ViewBoundary/index.tsx +4 -2
- package/index.ts +0 -6
- package/package.json +7 -7
- package/Application/__tests__/modalLayout.test.ts +0 -128
- 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
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
287
|
-
options
|
|
288
|
-
|
|
289
|
-
|
|
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 =
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
{
|
|
374
|
-
|
|
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
|
-
*
|
|
23
|
-
* selected item
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
});
|