@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,125 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors, Radius, Spacing } from '../../Consts';
|
|
3
|
-
|
|
4
|
-
export const styles = StyleSheet.create({
|
|
5
|
-
rowJourney: { flexDirection: 'row', width: '100%', alignItems: 'flex-start' },
|
|
6
|
-
verifiedDot: {
|
|
7
|
-
width: 4,
|
|
8
|
-
height: 4,
|
|
9
|
-
borderRadius: 2,
|
|
10
|
-
backgroundColor: Colors.green_03,
|
|
11
|
-
position: 'absolute',
|
|
12
|
-
alignSelf: 'center',
|
|
13
|
-
},
|
|
14
|
-
circle: {
|
|
15
|
-
width: 32,
|
|
16
|
-
height: 32,
|
|
17
|
-
borderRadius: 16,
|
|
18
|
-
borderWidth: 0.5,
|
|
19
|
-
borderColor: Colors.black_04,
|
|
20
|
-
},
|
|
21
|
-
circleMedium: {
|
|
22
|
-
width: 24,
|
|
23
|
-
height: 24,
|
|
24
|
-
borderRadius: 16,
|
|
25
|
-
borderWidth: 0.5,
|
|
26
|
-
borderColor: Colors.black_04,
|
|
27
|
-
},
|
|
28
|
-
circleSmall: {
|
|
29
|
-
width: 16,
|
|
30
|
-
height: 16,
|
|
31
|
-
borderRadius: 16,
|
|
32
|
-
borderWidth: 0.5,
|
|
33
|
-
borderColor: Colors.black_04,
|
|
34
|
-
},
|
|
35
|
-
groupAvtContainer: {
|
|
36
|
-
width: Spacing.XXL,
|
|
37
|
-
height: Spacing.XXL,
|
|
38
|
-
position: 'relative',
|
|
39
|
-
},
|
|
40
|
-
imageContainer: {
|
|
41
|
-
width: 32,
|
|
42
|
-
height: 32,
|
|
43
|
-
borderRadius: 16,
|
|
44
|
-
backgroundColor: Colors.pink_09,
|
|
45
|
-
borderWidth: 0.5,
|
|
46
|
-
justifyContent: 'center',
|
|
47
|
-
alignItems: 'center',
|
|
48
|
-
overflow: 'hidden',
|
|
49
|
-
},
|
|
50
|
-
dotAvatar: {
|
|
51
|
-
position: 'absolute',
|
|
52
|
-
width: 12,
|
|
53
|
-
height: 12,
|
|
54
|
-
borderRadius: 6,
|
|
55
|
-
bottom: -2,
|
|
56
|
-
right: -2,
|
|
57
|
-
borderWidth: 2,
|
|
58
|
-
borderColor: Colors.black_01,
|
|
59
|
-
},
|
|
60
|
-
verifiedIcon: { width: 16, height: 16, marginLeft: Spacing.XS },
|
|
61
|
-
shimmerTitle: {
|
|
62
|
-
height: 18,
|
|
63
|
-
width: 120,
|
|
64
|
-
borderRadius: Radius.XS,
|
|
65
|
-
overflow: 'hidden',
|
|
66
|
-
},
|
|
67
|
-
shimmerDescription: {
|
|
68
|
-
height: 12,
|
|
69
|
-
width: 120,
|
|
70
|
-
borderRadius: Radius.XS,
|
|
71
|
-
overflow: 'hidden',
|
|
72
|
-
},
|
|
73
|
-
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
74
|
-
centerContent: {
|
|
75
|
-
justifyContent: 'center',
|
|
76
|
-
},
|
|
77
|
-
centerStart: {
|
|
78
|
-
justifyContent: 'center',
|
|
79
|
-
alignItems: 'flex-start',
|
|
80
|
-
},
|
|
81
|
-
titleInfo: {
|
|
82
|
-
marginLeft: 6,
|
|
83
|
-
},
|
|
84
|
-
avatarEdgeTopRight: {
|
|
85
|
-
position: 'absolute',
|
|
86
|
-
top: 0,
|
|
87
|
-
right: 0,
|
|
88
|
-
},
|
|
89
|
-
avatarEdgeBottomLeft: {
|
|
90
|
-
position: 'absolute',
|
|
91
|
-
left: 0,
|
|
92
|
-
bottom: 0,
|
|
93
|
-
},
|
|
94
|
-
avatarTop: {
|
|
95
|
-
position: 'absolute',
|
|
96
|
-
top: 2,
|
|
97
|
-
},
|
|
98
|
-
avatarTopLeft: {
|
|
99
|
-
position: 'absolute',
|
|
100
|
-
top: 2,
|
|
101
|
-
left: 2,
|
|
102
|
-
},
|
|
103
|
-
avatarTopRight: {
|
|
104
|
-
position: 'absolute',
|
|
105
|
-
top: 2,
|
|
106
|
-
right: 2,
|
|
107
|
-
},
|
|
108
|
-
avatarBottomLeft: {
|
|
109
|
-
position: 'absolute',
|
|
110
|
-
left: 2,
|
|
111
|
-
bottom: 2,
|
|
112
|
-
},
|
|
113
|
-
avatarBottomRight: {
|
|
114
|
-
position: 'absolute',
|
|
115
|
-
bottom: 2,
|
|
116
|
-
right: 2,
|
|
117
|
-
},
|
|
118
|
-
avatarMore: {
|
|
119
|
-
backgroundColor: Colors.pink_09,
|
|
120
|
-
},
|
|
121
|
-
layer0: { zIndex: 0 },
|
|
122
|
-
layer1: { zIndex: 1 },
|
|
123
|
-
layer2: { zIndex: 2 },
|
|
124
|
-
layer3: { zIndex: 3 },
|
|
125
|
-
});
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useEffect } from 'react';
|
|
2
|
-
import { TouchableOpacity, View, ViewStyle } from 'react-native';
|
|
3
|
-
import { NavigationButton } from './NavigationButton';
|
|
4
|
-
import { MiniAppContext } from '../../Context';
|
|
5
|
-
import { Colors, Spacing, Styles } from '../../Consts';
|
|
6
|
-
import { Icon } from '../../Icon';
|
|
7
|
-
import { DuoMetrics } from '../../Layout/utils';
|
|
8
|
-
import { SideBarButton, SideBarGroup, SideBarGroupItem } from './SideBarButton';
|
|
9
|
-
import { useDuoBarCompression } from '../BottomTab/DuoBarCompression';
|
|
10
|
-
import { styles } from './HeaderRight.styles';
|
|
11
|
-
import { useToolkitActions } from './useToolkitActions';
|
|
12
|
-
import { HeaderBarMetrics } from '../headerLayout';
|
|
13
|
-
|
|
14
|
-
const CLOSE_ICON = '16_navigation_close_circle';
|
|
15
|
-
const HOME_ICON = '16_basic_home';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Header toolkit: optional shortcut plus the help center / close capsule. When
|
|
19
|
-
* `vertical` (iPhone Duo side bar) it reports its height and may fold into one button.
|
|
20
|
-
*/
|
|
21
|
-
const HeaderToolkitAction: React.FC<any> = ({
|
|
22
|
-
tintColor,
|
|
23
|
-
preventClose,
|
|
24
|
-
useSystemTools = true,
|
|
25
|
-
useShortcut = false,
|
|
26
|
-
useMore = false,
|
|
27
|
-
tools = [],
|
|
28
|
-
useCloseIcon = false,
|
|
29
|
-
vertical = false,
|
|
30
|
-
}) => {
|
|
31
|
-
const context = useContext<any>(MiniAppContext);
|
|
32
|
-
const compression = useDuoBarCompression();
|
|
33
|
-
const { toolbarCompressed, toolbarHidden } = compression;
|
|
34
|
-
const { expandToolbar, setToolbarHeight } = compression;
|
|
35
|
-
const {
|
|
36
|
-
isLoading,
|
|
37
|
-
iconShortcut,
|
|
38
|
-
shortcutOnPress,
|
|
39
|
-
showBadge,
|
|
40
|
-
onPressHelpCenter,
|
|
41
|
-
onClose,
|
|
42
|
-
} = useToolkitActions({
|
|
43
|
-
preventClose,
|
|
44
|
-
useSystemTools,
|
|
45
|
-
useShortcut,
|
|
46
|
-
useMore,
|
|
47
|
-
tools,
|
|
48
|
-
useCloseIcon,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
let buttonStyle: ViewStyle = {};
|
|
52
|
-
if (tintColor === Colors.black_01 || tintColor === 'white') {
|
|
53
|
-
buttonStyle = {
|
|
54
|
-
backgroundColor: Colors.black_20 + '99',
|
|
55
|
-
borderColor: Colors.black_01 + '33',
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const useHelpCenter = context.appId !== 'vn.momo.helpcenter';
|
|
60
|
-
const closeIcon = useCloseIcon ? CLOSE_ICON : HOME_ICON;
|
|
61
|
-
let toolkitWidthStyle: ViewStyle = styles.toolkitNarrow;
|
|
62
|
-
if (useHelpCenter) {
|
|
63
|
-
toolkitWidthStyle = styles.toolkitWide;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const groupCount = useHelpCenter ? 2 : 1;
|
|
67
|
-
let capsuleHeight = DuoMetrics.controlSize;
|
|
68
|
-
if (groupCount > 1) {
|
|
69
|
-
capsuleHeight = groupCount * DuoMetrics.itemPitch;
|
|
70
|
-
}
|
|
71
|
-
const backSlotHeight = DuoMetrics.controlSize + Spacing.M;
|
|
72
|
-
let shortcutHeight = 0;
|
|
73
|
-
if (useShortcut) {
|
|
74
|
-
shortcutHeight = DuoMetrics.controlSize + Spacing.M;
|
|
75
|
-
}
|
|
76
|
-
const fullToolbarHeight = backSlotHeight + shortcutHeight + capsuleHeight;
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (vertical) {
|
|
80
|
-
setToolbarHeight?.(fullToolbarHeight);
|
|
81
|
-
}
|
|
82
|
-
}, [vertical, fullToolbarHeight, setToolbarHeight]);
|
|
83
|
-
|
|
84
|
-
// an open tab rail takes this slot for a moment
|
|
85
|
-
if (vertical && toolbarHidden) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// HIG "Toolbar compressed": a menu icon (not the "more" one) that expands the toolbar
|
|
90
|
-
if (vertical && toolbarCompressed) {
|
|
91
|
-
return (
|
|
92
|
-
<SideBarButton
|
|
93
|
-
accessibilityLabel={'btn_navigation_toolbar'}
|
|
94
|
-
icon={'navigation_menu'}
|
|
95
|
-
tintColor={tintColor}
|
|
96
|
-
showBadge={showBadge}
|
|
97
|
-
onPress={expandToolbar}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (vertical) {
|
|
103
|
-
return (
|
|
104
|
-
<View style={styles.sideBarColumn}>
|
|
105
|
-
{useShortcut && (
|
|
106
|
-
<SideBarButton
|
|
107
|
-
disabled={isLoading}
|
|
108
|
-
icon={iconShortcut}
|
|
109
|
-
onPress={shortcutOnPress}
|
|
110
|
-
tintColor={tintColor}
|
|
111
|
-
showBadge={showBadge}
|
|
112
|
-
/>
|
|
113
|
-
)}
|
|
114
|
-
<SideBarGroup tintColor={tintColor}>
|
|
115
|
-
{useHelpCenter && (
|
|
116
|
-
<SideBarGroupItem
|
|
117
|
-
accessibilityLabel={'btn_navigation_help_center'}
|
|
118
|
-
icon={'help_center'}
|
|
119
|
-
tintColor={tintColor}
|
|
120
|
-
onPress={onPressHelpCenter}
|
|
121
|
-
/>
|
|
122
|
-
)}
|
|
123
|
-
<SideBarGroupItem
|
|
124
|
-
accessibilityLabel={'btn_navigation_close'}
|
|
125
|
-
icon={closeIcon}
|
|
126
|
-
tintColor={tintColor}
|
|
127
|
-
onPress={onClose}
|
|
128
|
-
/>
|
|
129
|
-
</SideBarGroup>
|
|
130
|
-
</View>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<View style={Styles.row}>
|
|
136
|
-
{useShortcut && (
|
|
137
|
-
<NavigationButton
|
|
138
|
-
disabled={isLoading}
|
|
139
|
-
icon={iconShortcut}
|
|
140
|
-
onPress={shortcutOnPress}
|
|
141
|
-
tintColor={tintColor}
|
|
142
|
-
showBadge={showBadge}
|
|
143
|
-
/>
|
|
144
|
-
)}
|
|
145
|
-
<View style={[styles.toolkitContainer, buttonStyle, toolkitWidthStyle]}>
|
|
146
|
-
{useHelpCenter && (
|
|
147
|
-
<>
|
|
148
|
-
<TouchableOpacity
|
|
149
|
-
accessibilityLabel={'btn_navigation_help_center'}
|
|
150
|
-
style={styles.toolkitButton}
|
|
151
|
-
onPress={onPressHelpCenter}
|
|
152
|
-
hitSlop={{ top: 7, bottom: 7, left: 7, right: 0 }}
|
|
153
|
-
>
|
|
154
|
-
<Icon
|
|
155
|
-
color={tintColor}
|
|
156
|
-
source={'help_center'}
|
|
157
|
-
size={HeaderBarMetrics.iconSize}
|
|
158
|
-
/>
|
|
159
|
-
</TouchableOpacity>
|
|
160
|
-
<View style={[styles.divider, { backgroundColor: tintColor }]} />
|
|
161
|
-
</>
|
|
162
|
-
)}
|
|
163
|
-
<TouchableOpacity
|
|
164
|
-
accessibilityLabel={'btn_navigation_close'}
|
|
165
|
-
onPress={onClose}
|
|
166
|
-
style={styles.toolkitButton}
|
|
167
|
-
hitSlop={{ top: 7, bottom: 7, left: 0, right: 7 }}
|
|
168
|
-
>
|
|
169
|
-
<Icon
|
|
170
|
-
color={tintColor}
|
|
171
|
-
source={closeIcon}
|
|
172
|
-
size={HeaderBarMetrics.iconSize}
|
|
173
|
-
/>
|
|
174
|
-
</TouchableOpacity>
|
|
175
|
-
</View>
|
|
176
|
-
</View>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export { HeaderToolkitAction };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useRef } from 'react';
|
|
2
|
-
import { Animated, Platform } from 'react-native';
|
|
3
|
-
import { CardAnimationContext } from '@react-navigation/stack';
|
|
4
|
-
import { ApplicationContext } from '../../Context';
|
|
5
|
-
import { hasMethod } from '../utils';
|
|
6
|
-
|
|
7
|
-
const SWIPE_BACK_HAPTIC_THRESHOLD = 50;
|
|
8
|
-
|
|
9
|
-
type AnimatedChild = { _parent?: Animated.Value };
|
|
10
|
-
type AnimatedNode = { __getValue?: () => unknown };
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* True when `value` can be subscribed like an `Animated.Value`.
|
|
14
|
-
*/
|
|
15
|
-
const isListenable = (value: unknown): value is Animated.Value => {
|
|
16
|
-
return hasMethod(value, 'addListener') && hasMethod(value, 'removeListener');
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Raw swipe translation behind `current.progress`, read from the private
|
|
21
|
-
* `_parent` of the stack interpolation. Undefined if that shape changes.
|
|
22
|
-
*/
|
|
23
|
-
const getSwipeGestureValue = (
|
|
24
|
-
progress?: Animated.AnimatedInterpolation<number>,
|
|
25
|
-
): Animated.Value | undefined => {
|
|
26
|
-
const parent = (progress as AnimatedChild | undefined)?._parent;
|
|
27
|
-
return isListenable(parent) ? parent : undefined;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Current value of an Animated node through its private `__getValue`, or
|
|
32
|
-
* `fallback` when that is missing or not a number.
|
|
33
|
-
*/
|
|
34
|
-
const readAnimatedValue = (node: unknown, fallback: number): number => {
|
|
35
|
-
const value = (node as AnimatedNode | undefined)?.__getValue?.();
|
|
36
|
-
return typeof value === 'number' ? value : fallback;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Haptic tick for the iOS swipe back. Keep it a null leaf (re-rendering the
|
|
41
|
-
* screen mid gesture breaks the pop) and attach listeners on mount, not lazily.
|
|
42
|
-
*/
|
|
43
|
-
const SwipeBackHaptic = () => {
|
|
44
|
-
const { navigator } = useContext<any>(ApplicationContext);
|
|
45
|
-
const animation = useContext(CardAnimationContext);
|
|
46
|
-
const hasFired = useRef(false);
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (Platform.OS !== 'ios' || !animation) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const { swiping, inverted, current } = animation;
|
|
54
|
-
const gesture = getSwipeGestureValue(current?.progress);
|
|
55
|
-
if (!gesture || !hasMethod(swiping, 'addListener')) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let isSwiping = readAnimatedValue(swiping, 0) === 1;
|
|
60
|
-
// sign, not magnitude: a leftward overdrag must not count toward dismissal
|
|
61
|
-
const direction = readAnimatedValue(inverted, 1);
|
|
62
|
-
|
|
63
|
-
const swipingListener = swiping.addListener(({ value }) => {
|
|
64
|
-
isSwiping = value === 1;
|
|
65
|
-
if (!isSwiping) {
|
|
66
|
-
hasFired.current = false;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const gestureListener = gesture.addListener(({ value: translation }) => {
|
|
71
|
-
if (!isSwiping) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (translation * direction < SWIPE_BACK_HAPTIC_THRESHOLD) {
|
|
76
|
-
hasFired.current = false;
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!hasFired.current) {
|
|
81
|
-
hasFired.current = true;
|
|
82
|
-
navigator?.maxApi?.triggerEventVibration?.('light');
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return () => {
|
|
87
|
-
gesture.removeListener(gestureListener);
|
|
88
|
-
swiping.removeListener(swipingListener);
|
|
89
|
-
};
|
|
90
|
-
}, [animation, navigator]);
|
|
91
|
-
|
|
92
|
-
return null;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export { SwipeBackHaptic };
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Dimensions, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import { Text } from '../../Text';
|
|
4
|
-
import { Spacing, Styles } from '../../Consts';
|
|
5
|
-
import { TitleJourneyProps } from '../types';
|
|
6
|
-
import { Icon } from '../../Icon';
|
|
7
|
-
import { Skeleton } from '../../Skeleton';
|
|
8
|
-
import { useScreenLayout } from '../../Layout';
|
|
9
|
-
import { styles } from './HeaderTitle.styles';
|
|
10
|
-
import {
|
|
11
|
-
HEADER_ACTIONS_WIDTH,
|
|
12
|
-
useHeaderFontFamily,
|
|
13
|
-
useTitleMaxWidth,
|
|
14
|
-
} from './HeaderTitle.shared';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Header title for a journey: `start` and `end` around an icon, with an optional
|
|
18
|
-
* description below; a shimmer while `isLoading`.
|
|
19
|
-
*/
|
|
20
|
-
const TitleJourney: React.FC<TitleJourneyProps> = ({
|
|
21
|
-
start,
|
|
22
|
-
end,
|
|
23
|
-
description,
|
|
24
|
-
icon,
|
|
25
|
-
iconColor,
|
|
26
|
-
tintColor,
|
|
27
|
-
onPress,
|
|
28
|
-
isLoading,
|
|
29
|
-
}) => {
|
|
30
|
-
const headerFontFamily = useHeaderFontFamily();
|
|
31
|
-
const maxWidth = useTitleMaxWidth();
|
|
32
|
-
const { sideBar } = useScreenLayout();
|
|
33
|
-
// journey split is tuned against the whole bar width
|
|
34
|
-
const screenWidth = Dimensions.get('screen').width;
|
|
35
|
-
const barWidth = sideBar ? maxWidth + HEADER_ACTIONS_WIDTH : screenWidth;
|
|
36
|
-
const startWidth = barWidth * 0.25;
|
|
37
|
-
const endWidth = barWidth * 0.75 - 212;
|
|
38
|
-
const renderShimmer = () => {
|
|
39
|
-
return (
|
|
40
|
-
<View style={Styles.flex}>
|
|
41
|
-
<View style={styles.shimmerTitle}>
|
|
42
|
-
<Skeleton />
|
|
43
|
-
</View>
|
|
44
|
-
<View style={{ height: Spacing.XXS }} />
|
|
45
|
-
<View style={styles.shimmerDescription}>
|
|
46
|
-
<Skeleton />
|
|
47
|
-
</View>
|
|
48
|
-
</View>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
if (isLoading) {
|
|
52
|
-
return renderShimmer();
|
|
53
|
-
}
|
|
54
|
-
return (
|
|
55
|
-
<TouchableOpacity
|
|
56
|
-
style={[styles.centerContent, { maxWidth: maxWidth }]}
|
|
57
|
-
onPress={onPress}
|
|
58
|
-
>
|
|
59
|
-
<View style={styles.rowJourney}>
|
|
60
|
-
<View style={Styles.row}>
|
|
61
|
-
<Text
|
|
62
|
-
typography="action_xs_bold"
|
|
63
|
-
style={{ maxWidth: startWidth }}
|
|
64
|
-
color={tintColor}
|
|
65
|
-
numberOfLines={1}
|
|
66
|
-
fontFamily={headerFontFamily}
|
|
67
|
-
>
|
|
68
|
-
{start}
|
|
69
|
-
</Text>
|
|
70
|
-
<Icon
|
|
71
|
-
source={icon}
|
|
72
|
-
size={16}
|
|
73
|
-
color={iconColor ?? tintColor}
|
|
74
|
-
style={{ marginHorizontal: Spacing.S, marginVertical: Spacing.XXS }}
|
|
75
|
-
/>
|
|
76
|
-
{!!end && (
|
|
77
|
-
<Text
|
|
78
|
-
style={{ maxWidth: endWidth }}
|
|
79
|
-
typography="action_xs_bold"
|
|
80
|
-
color={tintColor}
|
|
81
|
-
numberOfLines={1}
|
|
82
|
-
fontFamily={headerFontFamily}
|
|
83
|
-
>
|
|
84
|
-
{end}
|
|
85
|
-
</Text>
|
|
86
|
-
)}
|
|
87
|
-
</View>
|
|
88
|
-
<Icon
|
|
89
|
-
source={'16_arrow_chevron_down_small'}
|
|
90
|
-
size={16}
|
|
91
|
-
color={tintColor}
|
|
92
|
-
style={{ marginHorizontal: Spacing.XS, marginVertical: Spacing.XXS }}
|
|
93
|
-
/>
|
|
94
|
-
</View>
|
|
95
|
-
{!!description && (
|
|
96
|
-
<View style={styles.rowJourney}>
|
|
97
|
-
<Text
|
|
98
|
-
typography="description_xs_regular"
|
|
99
|
-
color={tintColor}
|
|
100
|
-
numberOfLines={1}
|
|
101
|
-
>
|
|
102
|
-
{description}
|
|
103
|
-
</Text>
|
|
104
|
-
</View>
|
|
105
|
-
)}
|
|
106
|
-
</TouchableOpacity>
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export { TitleJourney };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import { Text } from '../../Text';
|
|
4
|
-
import { Spacing, Styles } from '../../Consts';
|
|
5
|
-
import { TitleLocationProps } from '../types';
|
|
6
|
-
import { Icon } from '../../Icon';
|
|
7
|
-
import { Skeleton } from '../../Skeleton';
|
|
8
|
-
import { styles } from './HeaderTitle.styles';
|
|
9
|
-
import { useHeaderFontFamily, useTitleMaxWidth } from './HeaderTitle.shared';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Header title showing a location with a dropdown chevron and an optional
|
|
13
|
-
* description above it; a shimmer while `isLoading`.
|
|
14
|
-
*/
|
|
15
|
-
const TitleLocation: React.FC<TitleLocationProps> = ({
|
|
16
|
-
tintColor,
|
|
17
|
-
location,
|
|
18
|
-
description,
|
|
19
|
-
onPress,
|
|
20
|
-
isLoading,
|
|
21
|
-
}) => {
|
|
22
|
-
const headerFontFamily = useHeaderFontFamily();
|
|
23
|
-
const maxWidth = useTitleMaxWidth();
|
|
24
|
-
const renderShimmer = () => {
|
|
25
|
-
return (
|
|
26
|
-
<View style={Styles.flex}>
|
|
27
|
-
<View style={styles.shimmerDescription}>
|
|
28
|
-
<Skeleton />
|
|
29
|
-
</View>
|
|
30
|
-
<View style={{ height: Spacing.XXS }} />
|
|
31
|
-
<View style={styles.shimmerTitle}>
|
|
32
|
-
<Skeleton />
|
|
33
|
-
</View>
|
|
34
|
-
</View>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
if (isLoading) {
|
|
38
|
-
return renderShimmer();
|
|
39
|
-
}
|
|
40
|
-
return (
|
|
41
|
-
<TouchableOpacity
|
|
42
|
-
style={[styles.centerStart, { maxWidth: maxWidth }]}
|
|
43
|
-
onPress={onPress}
|
|
44
|
-
>
|
|
45
|
-
{!!description && (
|
|
46
|
-
<Text
|
|
47
|
-
typography="description_xs_regular"
|
|
48
|
-
color={tintColor}
|
|
49
|
-
numberOfLines={1}
|
|
50
|
-
>
|
|
51
|
-
{description}
|
|
52
|
-
</Text>
|
|
53
|
-
)}
|
|
54
|
-
<View style={Styles.row}>
|
|
55
|
-
<Text
|
|
56
|
-
typography="action_xs_bold"
|
|
57
|
-
fontFamily={headerFontFamily}
|
|
58
|
-
color={tintColor}
|
|
59
|
-
numberOfLines={1}
|
|
60
|
-
>
|
|
61
|
-
{location}
|
|
62
|
-
</Text>
|
|
63
|
-
<Icon
|
|
64
|
-
source={'16_arrow_chevron_down_small'}
|
|
65
|
-
size={16}
|
|
66
|
-
style={{ marginHorizontal: Spacing.XS }}
|
|
67
|
-
/>
|
|
68
|
-
</View>
|
|
69
|
-
</TouchableOpacity>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export { TitleLocation };
|