@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,104 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import React, { FC, useEffect, useRef } from 'react';
|
|
3
|
+
import { TextInput } from 'react-native';
|
|
4
|
+
import { useScaleSize, exportFontFamily } from '../Text';
|
|
5
|
+
import styles from './styles';
|
|
6
|
+
|
|
7
|
+
export const TextTyping: FC<any> = ({
|
|
8
|
+
data = [],
|
|
9
|
+
timeDelayEnd = 2000,
|
|
10
|
+
timeDelayNextChar = 20,
|
|
11
|
+
}) => {
|
|
12
|
+
const textRef = useRef<TextInput>(null);
|
|
13
|
+
const scaledFontSize = useScaleSize(12);
|
|
14
|
+
const typingFontFamily = exportFontFamily('regular');
|
|
15
|
+
|
|
16
|
+
const currentIndex = useRef<number>(0);
|
|
17
|
+
const currentCharIndex = useRef<number>(0);
|
|
18
|
+
const currentText = useRef('');
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
playAnimation();
|
|
23
|
+
}, 1000);
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
const playAnimation = () => {
|
|
27
|
+
const handleResetList = () => {
|
|
28
|
+
currentIndex.current = 0;
|
|
29
|
+
handleAnimation();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const handleAnimation = () => {
|
|
33
|
+
const listChar = data?.[currentIndex.current]?.split('') || [];
|
|
34
|
+
listChar.length !== 0 && showChar(listChar?.[currentCharIndex.current]);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (currentIndex.current >= data?.length) {
|
|
38
|
+
handleResetList();
|
|
39
|
+
} else {
|
|
40
|
+
handleAnimation();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const showChar = (char?: string) => {
|
|
45
|
+
const handleResetString = () => {
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
reset();
|
|
48
|
+
}, timeDelayEnd);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleShowChar = () => {
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
textRef.current?.setNativeProps?.({
|
|
54
|
+
text: currentText.current + char,
|
|
55
|
+
});
|
|
56
|
+
currentText.current += char;
|
|
57
|
+
currentCharIndex.current++;
|
|
58
|
+
playAnimation();
|
|
59
|
+
}, timeDelayNextChar);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const textLength = data?.[currentIndex.current]?.length || 0;
|
|
63
|
+
if (currentCharIndex.current >= textLength) {
|
|
64
|
+
handleResetString();
|
|
65
|
+
} else {
|
|
66
|
+
handleShowChar();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const reset = () => {
|
|
71
|
+
const handleNextString = () => {
|
|
72
|
+
currentIndex.current++;
|
|
73
|
+
playAnimation();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const handleReset = () => {
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
textRef.current?.setNativeProps?.({
|
|
79
|
+
text: currentText.current.slice(0, -1),
|
|
80
|
+
});
|
|
81
|
+
currentText.current = currentText.current.slice(0, -1);
|
|
82
|
+
currentCharIndex.current--;
|
|
83
|
+
reset();
|
|
84
|
+
}, timeDelayNextChar);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
currentCharIndex.current <= 0 ? handleNextString() : handleReset();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<TextInput
|
|
92
|
+
style={[
|
|
93
|
+
styles.inputStyle,
|
|
94
|
+
{ fontSize: scaledFontSize, fontFamily: typingFontFamily },
|
|
95
|
+
]}
|
|
96
|
+
ref={textRef}
|
|
97
|
+
editable={false}
|
|
98
|
+
autoCorrect={false}
|
|
99
|
+
pointerEvents={'none'}
|
|
100
|
+
numberOfLines={1}
|
|
101
|
+
allowFontScaling={false}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
};
|
package/Input/common.tsx
CHANGED
|
@@ -118,7 +118,7 @@ export const ErrorView: FC<{
|
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
if (errorSpacing) {
|
|
121
|
-
return <View style={[styles.errorView,
|
|
121
|
+
return <View style={[styles.errorView, styles.errorSpacing]} />;
|
|
122
122
|
}
|
|
123
123
|
return <View />;
|
|
124
124
|
};
|
|
@@ -147,9 +147,9 @@ export const FloatingView: FC<FloatingViewProps> = ({
|
|
|
147
147
|
<View
|
|
148
148
|
style={[
|
|
149
149
|
styles.floatingView,
|
|
150
|
+
styles.floatingViewLayer,
|
|
150
151
|
{
|
|
151
152
|
backgroundColor: theme.colors.background.surface,
|
|
152
|
-
zIndex: 10,
|
|
153
153
|
top: -scaledTop,
|
|
154
154
|
},
|
|
155
155
|
style,
|
|
@@ -206,14 +206,14 @@ export const RenderTrailing: FC<TrailingProps> = ({
|
|
|
206
206
|
if (icon) {
|
|
207
207
|
const isIcon =
|
|
208
208
|
(IconSources as any)?.[icon as string]?.uri || icon?.includes('http');
|
|
209
|
-
const renderIconTouchable = (
|
|
209
|
+
const renderIconTouchable = (content: ReactNode) => {
|
|
210
210
|
return (
|
|
211
211
|
<TouchableOpacity
|
|
212
212
|
accessibilityLabel={`${componentId}|trailing-touch`}
|
|
213
213
|
onPress={onPressIcon}
|
|
214
214
|
style={styles.icon}
|
|
215
215
|
>
|
|
216
|
-
{
|
|
216
|
+
{content}
|
|
217
217
|
</TouchableOpacity>
|
|
218
218
|
);
|
|
219
219
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const moneyFormatter = new Intl.NumberFormat('vi-VN');
|
|
2
|
+
|
|
3
|
+
export const findEdit = (old: string, text: string) => {
|
|
4
|
+
let start = 0;
|
|
5
|
+
while (start < text.length && old[start] === text[start]) {
|
|
6
|
+
start += 1;
|
|
7
|
+
}
|
|
8
|
+
let suffix = 0;
|
|
9
|
+
while (
|
|
10
|
+
suffix < Math.min(text.length, old.length) - start &&
|
|
11
|
+
old[old.length - 1 - suffix] === text[text.length - 1 - suffix]
|
|
12
|
+
) {
|
|
13
|
+
suffix += 1;
|
|
14
|
+
}
|
|
15
|
+
const size = old.length + text.length - 2 * (start + suffix);
|
|
16
|
+
return { old, start, suffix, size };
|
|
17
|
+
};
|
package/Input/styles.ts
CHANGED
|
@@ -223,9 +223,33 @@ export default StyleSheet.create({
|
|
|
223
223
|
},
|
|
224
224
|
moneyTextInput: {
|
|
225
225
|
flexShrink: 1,
|
|
226
|
-
height: '100%',
|
|
227
226
|
paddingLeft: 0,
|
|
228
227
|
paddingRight: Spacing.XXS,
|
|
229
|
-
paddingVertical:
|
|
228
|
+
paddingVertical: 0,
|
|
229
|
+
},
|
|
230
|
+
inputField: {
|
|
231
|
+
flex: 1,
|
|
232
|
+
paddingLeft: Spacing.M,
|
|
233
|
+
height: '100%',
|
|
234
|
+
},
|
|
235
|
+
secureTextSmall: { fontSize: 18 },
|
|
236
|
+
secureTextLarge: { fontSize: 22 },
|
|
237
|
+
iconViewDropDownMultiline: {
|
|
238
|
+
alignItems: 'flex-start',
|
|
239
|
+
paddingTop: Spacing.M,
|
|
240
|
+
},
|
|
241
|
+
iconViewDropDownSingle: {
|
|
242
|
+
alignItems: 'center',
|
|
243
|
+
paddingTop: 0,
|
|
244
|
+
},
|
|
245
|
+
otpCursor: { width: 1 },
|
|
246
|
+
searchInputTyping: { justifyContent: 'center' },
|
|
247
|
+
textAreaInput: {
|
|
248
|
+
width: '100%',
|
|
249
|
+
flex: 1,
|
|
250
|
+
paddingRight: Spacing.XS,
|
|
251
|
+
paddingVertical: Spacing.XS,
|
|
230
252
|
},
|
|
253
|
+
errorSpacing: { height: 18 },
|
|
254
|
+
floatingViewLayer: { zIndex: 10 },
|
|
231
255
|
});
|
|
@@ -13,12 +13,11 @@ import Animated, {
|
|
|
13
13
|
} from 'react-native-reanimated';
|
|
14
14
|
import { scheduleOnRN } from 'react-native-worklets';
|
|
15
15
|
import { ApplicationContext } from '../Context';
|
|
16
|
+
import { Colors } from '../Consts';
|
|
16
17
|
import { Icon } from '../Icon';
|
|
17
18
|
import { useScaleSize, exportFontFamily } from '../Text';
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
useNormalizedSharedValue,
|
|
21
|
-
} from '../Application/utils';
|
|
19
|
+
import { type AnimatedCompatValue } from '../Application/utils';
|
|
20
|
+
import { useNormalizedSharedValue } from '../Application/hooks';
|
|
22
21
|
|
|
23
22
|
export interface FloatingButtonProps {
|
|
24
23
|
label?: string;
|
|
@@ -118,11 +117,9 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
118
117
|
onLayout={handleLayout}
|
|
119
118
|
style={[
|
|
120
119
|
styles.container,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
bottom,
|
|
125
|
-
},
|
|
120
|
+
position === 'right' && styles.alignRight,
|
|
121
|
+
position === 'center' ? styles.alignCenter : styles.alignEnd,
|
|
122
|
+
{ bottom },
|
|
126
123
|
]}
|
|
127
124
|
>
|
|
128
125
|
{renderComponent()}
|
|
@@ -135,20 +132,14 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
135
132
|
onLayout={handleLayout}
|
|
136
133
|
style={[
|
|
137
134
|
styles.container,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
backgroundColor: theme.colors.primary,
|
|
143
|
-
bottom,
|
|
144
|
-
},
|
|
135
|
+
position === 'right' && styles.alignRight,
|
|
136
|
+
position === 'center' ? styles.alignCenter : styles.alignEnd,
|
|
137
|
+
size === 'small' ? styles.small : styles.large,
|
|
138
|
+
{ backgroundColor: theme.colors.primary, bottom },
|
|
145
139
|
containerStyle,
|
|
146
140
|
]}
|
|
147
141
|
>
|
|
148
|
-
<TouchableOpacity
|
|
149
|
-
style={{ flexDirection: 'row', alignItems: 'center' }}
|
|
150
|
-
onPress={onPress}
|
|
151
|
-
>
|
|
142
|
+
<TouchableOpacity style={styles.content} onPress={onPress}>
|
|
152
143
|
<Icon
|
|
153
144
|
source={icon}
|
|
154
145
|
size={size === 'small' ? 12 : 24}
|
|
@@ -159,10 +150,10 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
159
150
|
allowFontScaling={false}
|
|
160
151
|
style={[
|
|
161
152
|
styles.label,
|
|
153
|
+
styles.labelText,
|
|
162
154
|
{
|
|
163
155
|
fontSize: scaledFontSize,
|
|
164
156
|
lineHeight: scaledLineHeight,
|
|
165
|
-
color: 'white',
|
|
166
157
|
fontFamily: labelFontFamily,
|
|
167
158
|
},
|
|
168
159
|
labelStyle,
|
|
@@ -191,4 +182,14 @@ const styles = StyleSheet.create({
|
|
|
191
182
|
label: {
|
|
192
183
|
marginLeft: 8,
|
|
193
184
|
},
|
|
185
|
+
alignRight: { right: 12 },
|
|
186
|
+
alignCenter: { alignSelf: 'center' },
|
|
187
|
+
alignEnd: { alignSelf: 'flex-end' },
|
|
188
|
+
small: { height: 36 },
|
|
189
|
+
large: { height: 48 },
|
|
190
|
+
content: {
|
|
191
|
+
flexDirection: 'row',
|
|
192
|
+
alignItems: 'center',
|
|
193
|
+
},
|
|
194
|
+
labelText: { color: Colors.black_01 },
|
|
194
195
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, ReactNode, useMemo } from 'react';
|
|
1
|
+
import React, { createContext, ReactNode, useContext, useMemo } from 'react';
|
|
2
2
|
import { Platform, StyleSheet } from 'react-native';
|
|
3
3
|
|
|
4
4
|
export type ReservedRegion = {
|
|
@@ -25,7 +25,15 @@ try {
|
|
|
25
25
|
const ReservedRegionsContext = createContext<ReservedRegion[]>([]);
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* vertical seam splitting the display into left and right halves, e.g. iPhone Duo
|
|
29
|
+
* half folded. `undefined` while the display is flat or the system reports none
|
|
30
|
+
*/
|
|
31
|
+
const HingeContext = createContext<ReservedRegion | undefined>(undefined);
|
|
32
|
+
|
|
33
|
+
const useHinge = () => useContext(HingeContext);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* keeps the occlusion regions and the vertical division reported by the native provider
|
|
29
37
|
*/
|
|
30
38
|
const OcclusionRegions: React.FC<{
|
|
31
39
|
useRegions: NativeReservedRegions['useReservedRegions'];
|
|
@@ -39,10 +47,19 @@ const OcclusionRegions: React.FC<{
|
|
|
39
47
|
.map(region => region.frame),
|
|
40
48
|
[regions],
|
|
41
49
|
);
|
|
50
|
+
const hinge = useMemo(
|
|
51
|
+
() =>
|
|
52
|
+
regions.find(
|
|
53
|
+
region =>
|
|
54
|
+
region.kind === 'division' &&
|
|
55
|
+
region.frame.height > region.frame.width,
|
|
56
|
+
)?.frame,
|
|
57
|
+
[regions],
|
|
58
|
+
);
|
|
42
59
|
|
|
43
60
|
return (
|
|
44
61
|
<ReservedRegionsContext.Provider value={occlusion}>
|
|
45
|
-
{children}
|
|
62
|
+
<HingeContext.Provider value={hinge}>{children}</HingeContext.Provider>
|
|
46
63
|
</ReservedRegionsContext.Provider>
|
|
47
64
|
);
|
|
48
65
|
};
|
|
@@ -75,4 +92,4 @@ const styles = StyleSheet.create({
|
|
|
75
92
|
},
|
|
76
93
|
});
|
|
77
94
|
|
|
78
|
-
export { ReservedRegionsContext, ReservedRegionsProvider };
|
|
95
|
+
export { ReservedRegionsContext, ReservedRegionsProvider, useHinge };
|