@momo-kits/foundation 0.168.1-rn862.1 → 0.169.2
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 +195 -0
- package/Application/BottomSheet.parts.tsx +147 -0
- package/Application/BottomSheet.styles.ts +43 -0
- package/Application/BottomSheet.tsx +76 -279
- package/Application/BottomTab/ActiveIndicator.tsx +90 -0
- package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
- package/Application/BottomTab/BottomTabBar.tsx +229 -276
- package/Application/BottomTab/BottomTabInset.tsx +14 -0
- package/Application/BottomTab/CurvedContainer.tsx +153 -0
- package/Application/BottomTab/CustomBottomTabItem.tsx +132 -108
- package/Application/BottomTab/DuoBarCompression.tsx +4 -12
- package/Application/BottomTab/DuoRailTabBar.tsx +227 -0
- package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
- package/Application/BottomTab/DuoTabBar.tsx +29 -495
- package/Application/BottomTab/TabBarIcon.tsx +160 -72
- package/Application/BottomTab/TabScreen.tsx +164 -0
- package/Application/BottomTab/index.tsx +84 -351
- package/Application/BottomTab/metrics.ts +164 -0
- package/Application/BottomTab/tabItems.ts +46 -0
- package/Application/BottomTab/usePressLift.ts +32 -0
- package/Application/Components/DuoGlassBackground.tsx +7 -9
- package/Application/Components/HeaderAnimated.tsx +1 -1
- package/Application/Components/HeaderBackground.tsx +1 -1
- package/Application/Components/HeaderExtendHeader.tsx +17 -11
- package/Application/Components/HeaderRight.styles.ts +144 -0
- package/Application/Components/HeaderRight.tsx +6 -528
- package/Application/Components/HeaderTitle.shared.ts +43 -0
- package/Application/Components/HeaderTitle.styles.ts +125 -0
- package/Application/Components/HeaderTitle.tsx +12 -576
- package/Application/Components/HeaderToolkitAction.tsx +208 -0
- package/Application/Components/NavigationButton.tsx +9 -6
- package/Application/Components/SearchHeader.tsx +1 -1
- package/Application/Components/SwipeBackHaptic.tsx +95 -0
- package/Application/Components/TitleJourney.tsx +110 -0
- package/Application/Components/TitleLocation.tsx +73 -0
- package/Application/Components/TitleUser.tsx +304 -0
- package/Application/Components/useToolkitActions.tsx +233 -0
- package/Application/ModalIconButton.tsx +66 -0
- package/Application/ModalScreen.tsx +39 -18
- package/Application/Navigation.ts +1 -1
- package/Application/NavigationContainer.tsx +7 -8
- package/Application/StackScreen.tracking.ts +158 -0
- package/Application/StackScreen.tsx +10 -137
- package/Application/WidgetContainer.tsx +10 -3
- package/Application/__tests__/modalLayout.test.ts +128 -0
- package/Application/hooks.ts +137 -0
- package/Application/index.ts +13 -1
- package/Application/modalLayout.ts +177 -0
- package/Application/navigationOptions.tsx +217 -0
- package/Application/types.header.ts +116 -0
- package/Application/types.tabs.ts +48 -0
- package/Application/types.theme.ts +87 -0
- package/Application/types.ts +12 -244
- package/Application/utils.ts +107 -0
- package/Badge/BadgeRibbon.tsx +3 -3
- package/Badge/styles.ts +2 -0
- package/Button/index.tsx +16 -136
- package/Button/styles.ts +1 -1
- package/Button/utils.ts +139 -0
- package/CheckBox/index.tsx +1 -6
- package/Divider/DashDivider.tsx +10 -11
- package/Divider/index.tsx +18 -8
- package/Image/index.tsx +1 -46
- package/Input/Input.tsx +7 -8
- package/Input/InputDropDown.tsx +3 -4
- package/Input/InputMoney.tsx +38 -164
- package/Input/InputMoneyView.tsx +187 -0
- package/Input/InputOTP.tsx +1 -1
- package/Input/InputPhoneNumber.tsx +5 -1
- package/Input/InputSearch.tsx +2 -108
- package/Input/InputTextArea.tsx +1 -5
- package/Input/SearchTextTyping.tsx +104 -0
- package/Input/common.tsx +4 -4
- package/Input/moneyUtils.ts +17 -0
- package/Input/styles.ts +26 -2
- package/Layout/FloatingButton.tsx +22 -21
- package/Layout/ReservedRegions.tsx +21 -4
- package/Layout/Screen.tsx +74 -670
- package/Layout/Section.tsx +1 -2
- package/Layout/index.ts +10 -4
- package/Layout/layoutMetrics.ts +58 -0
- package/Layout/layoutTypes.ts +86 -0
- package/Layout/screenContent.tsx +90 -0
- package/Layout/screenFooter.tsx +53 -0
- package/Layout/screenHeader.tsx +315 -0
- package/Layout/screenQuickReturn.tsx +67 -0
- package/Layout/screenScroll.ts +110 -0
- package/Layout/screenTypes.ts +134 -0
- package/Layout/styles.ts +2 -0
- package/Layout/utils.ts +10 -144
- package/Loader/DotLoader.tsx +7 -3
- package/Loader/ProgressBar.tsx +2 -6
- package/Loader/Spinner.tsx +7 -3
- package/Loader/styles.ts +4 -0
- package/Popup/PopupNotify.tsx +70 -64
- package/Popup/PopupPromotion.tsx +5 -4
- package/Popup/types.ts +7 -0
- package/Popup/utils.ts +46 -24
- package/Radio/index.tsx +2 -10
- package/Radio/styles.ts +6 -0
- package/Skeleton/index.tsx +1 -9
- package/Skeleton/styles.ts +1 -0
- package/Tag/index.tsx +3 -3
- package/Text/index.tsx +11 -2
- package/Title/index.tsx +2 -9
- package/Title/styles.ts +6 -0
- package/package.json +21 -22
- package/Application/device.ts +0 -29
- package/Application/utils.tsx +0 -497
|
@@ -0,0 +1,208 @@
|
|
|
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, useScreenLayout } 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
|
+
|
|
13
|
+
const CLOSE_ICON = '16_navigation_close_circle';
|
|
14
|
+
const HOME_ICON = '16_basic_home';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Header toolkit action
|
|
18
|
+
*/
|
|
19
|
+
const HeaderToolkitAction: React.FC<any> = ({
|
|
20
|
+
tintColor,
|
|
21
|
+
preventClose,
|
|
22
|
+
useSystemTools = true,
|
|
23
|
+
useShortcut = false,
|
|
24
|
+
useMore = false,
|
|
25
|
+
tools = [],
|
|
26
|
+
useCloseIcon = false,
|
|
27
|
+
vertical = false,
|
|
28
|
+
}) => {
|
|
29
|
+
const context = useContext<any>(MiniAppContext);
|
|
30
|
+
const { toolbarCompressed, toolbarHidden, expandToolbar, setToolbarHeight } =
|
|
31
|
+
useDuoBarCompression();
|
|
32
|
+
const { statusBarClearance } = useScreenLayout();
|
|
33
|
+
const {
|
|
34
|
+
isLoading,
|
|
35
|
+
iconShortcut,
|
|
36
|
+
shortcutOnPress,
|
|
37
|
+
showBadge,
|
|
38
|
+
onPressHelpCenter,
|
|
39
|
+
onClose,
|
|
40
|
+
} = useToolkitActions({
|
|
41
|
+
preventClose,
|
|
42
|
+
useSystemTools,
|
|
43
|
+
useShortcut,
|
|
44
|
+
useMore,
|
|
45
|
+
tools,
|
|
46
|
+
useCloseIcon,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
let buttonStyle: ViewStyle = {};
|
|
50
|
+
if (tintColor === Colors.black_01 || tintColor === 'white') {
|
|
51
|
+
buttonStyle = {
|
|
52
|
+
backgroundColor: Colors.black_20 + '99',
|
|
53
|
+
borderColor: Colors.black_01 + '33',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const useHelpCenter = context.appId !== 'vn.momo.helpcenter';
|
|
58
|
+
const closeIcon = useCloseIcon ? CLOSE_ICON : HOME_ICON;
|
|
59
|
+
|
|
60
|
+
const groupCount = useHelpCenter ? 2 : 1;
|
|
61
|
+
let capsuleHeight = DuoMetrics.controlSize;
|
|
62
|
+
if (groupCount > 1) {
|
|
63
|
+
capsuleHeight = groupCount * DuoMetrics.itemPitch;
|
|
64
|
+
}
|
|
65
|
+
// Back slot, the optional shortcut, then the help/home capsule
|
|
66
|
+
const fullToolbarHeight =
|
|
67
|
+
DuoMetrics.controlSize +
|
|
68
|
+
Spacing.M +
|
|
69
|
+
(useShortcut ? DuoMetrics.controlSize + Spacing.M : 0) +
|
|
70
|
+
capsuleHeight;
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (vertical) {
|
|
74
|
+
setToolbarHeight?.(fullToolbarHeight);
|
|
75
|
+
}
|
|
76
|
+
}, [vertical, fullToolbarHeight, setToolbarHeight]);
|
|
77
|
+
|
|
78
|
+
// an open tab rail takes this slot for a moment
|
|
79
|
+
if (vertical && toolbarHidden) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// HIG "Toolbar compressed": tools fold into one button; tapping it expands the
|
|
84
|
+
// toolbar and compresses the tab bar instead. Not the useMore icon, to tell them apart
|
|
85
|
+
if (vertical && toolbarCompressed) {
|
|
86
|
+
return (
|
|
87
|
+
<SideBarButton
|
|
88
|
+
accessibilityLabel={'btn_navigation_toolbar'}
|
|
89
|
+
icon={'navigation_menu'}
|
|
90
|
+
tintColor={tintColor}
|
|
91
|
+
showBadge={showBadge}
|
|
92
|
+
onPress={expandToolbar}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (vertical) {
|
|
98
|
+
return (
|
|
99
|
+
<View style={styles.sideBarColumn}>
|
|
100
|
+
{useShortcut && (
|
|
101
|
+
<SideBarButton
|
|
102
|
+
disabled={isLoading}
|
|
103
|
+
icon={iconShortcut}
|
|
104
|
+
onPress={shortcutOnPress}
|
|
105
|
+
tintColor={tintColor}
|
|
106
|
+
showBadge={showBadge}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
<SideBarGroup tintColor={tintColor}>
|
|
110
|
+
{useHelpCenter && (
|
|
111
|
+
<SideBarGroupItem
|
|
112
|
+
accessibilityLabel={'btn_navigation_help_center'}
|
|
113
|
+
icon={'help_center'}
|
|
114
|
+
tintColor={tintColor}
|
|
115
|
+
onPress={onPressHelpCenter}
|
|
116
|
+
/>
|
|
117
|
+
)}
|
|
118
|
+
<SideBarGroupItem
|
|
119
|
+
accessibilityLabel={'btn_navigation_close'}
|
|
120
|
+
icon={closeIcon}
|
|
121
|
+
tintColor={tintColor}
|
|
122
|
+
onPress={onClose}
|
|
123
|
+
/>
|
|
124
|
+
</SideBarGroup>
|
|
125
|
+
</View>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// on the status bar row the controls keep the side bar size
|
|
130
|
+
if (statusBarClearance) {
|
|
131
|
+
return (
|
|
132
|
+
<View style={styles.sideBarRow}>
|
|
133
|
+
{useShortcut && (
|
|
134
|
+
<SideBarButton
|
|
135
|
+
disabled={isLoading}
|
|
136
|
+
icon={iconShortcut}
|
|
137
|
+
onPress={shortcutOnPress}
|
|
138
|
+
tintColor={tintColor}
|
|
139
|
+
showBadge={showBadge}
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
<SideBarGroup tintColor={tintColor} horizontal>
|
|
143
|
+
{useHelpCenter && (
|
|
144
|
+
<SideBarGroupItem
|
|
145
|
+
accessibilityLabel={'btn_navigation_help_center'}
|
|
146
|
+
icon={'help_center'}
|
|
147
|
+
tintColor={tintColor}
|
|
148
|
+
onPress={onPressHelpCenter}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
<SideBarGroupItem
|
|
152
|
+
accessibilityLabel={'btn_navigation_close'}
|
|
153
|
+
icon={closeIcon}
|
|
154
|
+
tintColor={tintColor}
|
|
155
|
+
onPress={onClose}
|
|
156
|
+
/>
|
|
157
|
+
</SideBarGroup>
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<View style={Styles.row}>
|
|
164
|
+
{useShortcut && (
|
|
165
|
+
<NavigationButton
|
|
166
|
+
disabled={isLoading}
|
|
167
|
+
icon={iconShortcut}
|
|
168
|
+
onPress={shortcutOnPress}
|
|
169
|
+
tintColor={tintColor}
|
|
170
|
+
showBadge={showBadge}
|
|
171
|
+
/>
|
|
172
|
+
)}
|
|
173
|
+
<View
|
|
174
|
+
style={[
|
|
175
|
+
styles.toolkitContainer,
|
|
176
|
+
buttonStyle,
|
|
177
|
+
context.appId !== 'vn.momo.helpcenter'
|
|
178
|
+
? styles.toolkitWide
|
|
179
|
+
: styles.toolkitNarrow,
|
|
180
|
+
]}
|
|
181
|
+
>
|
|
182
|
+
{useHelpCenter && (
|
|
183
|
+
<>
|
|
184
|
+
<TouchableOpacity
|
|
185
|
+
accessibilityLabel={'btn_navigation_help_center'}
|
|
186
|
+
style={styles.toolkitButton}
|
|
187
|
+
onPress={onPressHelpCenter}
|
|
188
|
+
hitSlop={{ top: 7, bottom: 7, left: 7, right: 0 }}
|
|
189
|
+
>
|
|
190
|
+
<Icon color={tintColor} source={'help_center'} size={20} />
|
|
191
|
+
</TouchableOpacity>
|
|
192
|
+
<View style={[styles.divider, { backgroundColor: tintColor }]} />
|
|
193
|
+
</>
|
|
194
|
+
)}
|
|
195
|
+
<TouchableOpacity
|
|
196
|
+
accessibilityLabel={'btn_navigation_close'}
|
|
197
|
+
onPress={onClose}
|
|
198
|
+
style={styles.toolkitButton}
|
|
199
|
+
hitSlop={{ top: 7, bottom: 7, left: 0, right: 7 }}
|
|
200
|
+
>
|
|
201
|
+
<Icon color={tintColor} source={closeIcon} size={20} />
|
|
202
|
+
</TouchableOpacity>
|
|
203
|
+
</View>
|
|
204
|
+
</View>
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export { HeaderToolkitAction };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NavigationButtonProps } from '../types';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import { ApplicationContext
|
|
3
|
+
import { ApplicationContext } from '../../Context';
|
|
4
4
|
import { StyleSheet, TouchableOpacity, View, ViewStyle } from 'react-native';
|
|
5
5
|
import { Colors, Spacing } from '../../Consts';
|
|
6
6
|
import { Icon } from '../../Icon';
|
|
@@ -19,13 +19,13 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
19
19
|
let buttonStyle: ViewStyle = {};
|
|
20
20
|
if (tintColor === Colors.black_01) {
|
|
21
21
|
buttonStyle = {
|
|
22
|
-
backgroundColor: '
|
|
23
|
-
borderColor: '
|
|
22
|
+
backgroundColor: Colors.black_20 + '99',
|
|
23
|
+
borderColor: Colors.black_01 + '33',
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
|
-
<View style={
|
|
28
|
+
<View style={styles.container}>
|
|
29
29
|
<TouchableOpacity
|
|
30
30
|
{...props}
|
|
31
31
|
style={[styles.navigationButton, buttonStyle]}
|
|
@@ -43,14 +43,17 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
const styles = StyleSheet.create({
|
|
46
|
+
container: {
|
|
47
|
+
width: 28,
|
|
48
|
+
},
|
|
46
49
|
navigationButton: {
|
|
47
50
|
height: 28,
|
|
48
51
|
width: 28,
|
|
49
52
|
borderRadius: 14,
|
|
50
53
|
justifyContent: 'center',
|
|
51
54
|
alignItems: 'center',
|
|
52
|
-
backgroundColor: '
|
|
53
|
-
borderColor: '
|
|
55
|
+
backgroundColor: Colors.black_01 + '99',
|
|
56
|
+
borderColor: Colors.black_20 + '33',
|
|
54
57
|
borderWidth: 0.2,
|
|
55
58
|
},
|
|
56
59
|
badgeDot: {
|
|
@@ -6,7 +6,7 @@ import React, { useContext } from 'react';
|
|
|
6
6
|
import { SearchHeaderProps } from '../types';
|
|
7
7
|
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
8
8
|
import { Text } from '../../Text';
|
|
9
|
-
import { useNormalizedSharedValue } from '../
|
|
9
|
+
import { useNormalizedSharedValue } from '../hooks';
|
|
10
10
|
import { useScreenLayout } from '../../Layout';
|
|
11
11
|
import { DuoMetrics } from '../../Layout/utils';
|
|
12
12
|
|
|
@@ -0,0 +1,95 @@
|
|
|
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 };
|
|
@@ -0,0 +1,110 @@
|
|
|
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 user title
|
|
18
|
+
* @constructor
|
|
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 };
|
|
@@ -0,0 +1,73 @@
|
|
|
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 user title
|
|
13
|
+
* @constructor
|
|
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 };
|