@momo-kits/foundation 0.115.3-beta.9 → 0.116.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.tsx +5 -57
- package/Application/Components/HeaderRight.tsx +0 -2
- package/Application/types.ts +0 -2
- package/Divider/index.tsx +8 -32
- package/Input/InputOTP.tsx +0 -11
- package/Input/styles.ts +0 -6
- package/Text/utils.ts +5 -14
- package/package.json +5 -6
- package/Divider/DashDivider.tsx +0 -45
|
@@ -1,32 +1,23 @@
|
|
|
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
3
|
Dimensions,
|
|
10
|
-
Keyboard,
|
|
11
4
|
KeyboardAvoidingView,
|
|
12
|
-
LayoutAnimation,
|
|
13
5
|
Modal,
|
|
14
6
|
PanResponder,
|
|
15
7
|
Platform,
|
|
16
8
|
Pressable,
|
|
17
|
-
ScrollView,
|
|
18
9
|
StyleSheet,
|
|
19
10
|
TouchableOpacity,
|
|
20
11
|
View,
|
|
21
12
|
} from 'react-native';
|
|
22
13
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
23
|
-
import Animated, {Easing, Extrapolate} from 'react-native-reanimated';
|
|
24
|
-
import {useHeaderHeight} from '@react-navigation/stack';
|
|
25
14
|
import {ApplicationContext} from './index';
|
|
26
15
|
import {BottomSheetParams} from './types';
|
|
27
16
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
28
17
|
import {Text} from '../Text';
|
|
29
18
|
import {Icon} from '../Icon';
|
|
19
|
+
import {useHeaderHeight} from '@react-navigation/stack';
|
|
20
|
+
import Animated, {Easing, Extrapolate} from 'react-native-reanimated';
|
|
30
21
|
|
|
31
22
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
32
23
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
@@ -34,8 +25,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
34
25
|
const action = useRef<undefined | string>();
|
|
35
26
|
const insets = useSafeAreaInsets();
|
|
36
27
|
const heightHeader = useHeaderHeight();
|
|
37
|
-
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
38
|
-
const [contentHeight, setContentHeight] = useState(0);
|
|
39
28
|
const keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
|
|
40
29
|
|
|
41
30
|
const {
|
|
@@ -47,7 +36,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
47
36
|
draggable = true,
|
|
48
37
|
useBottomInset = true,
|
|
49
38
|
useKeyboardAvoidingView = true,
|
|
50
|
-
useScrollOverflow = false,
|
|
51
39
|
keyboardVerticalOffset,
|
|
52
40
|
}: BottomSheetParams = props.route.params;
|
|
53
41
|
|
|
@@ -98,39 +86,14 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
98
86
|
).current;
|
|
99
87
|
|
|
100
88
|
let Container: any = View;
|
|
101
|
-
let Content: any = View;
|
|
102
89
|
if (useNativeModal) {
|
|
103
90
|
Container = Modal;
|
|
104
91
|
}
|
|
105
|
-
if (useScrollOverflow) {
|
|
106
|
-
Content = ScrollView;
|
|
107
|
-
}
|
|
108
92
|
let backgroundColor = theme.colors.background.default;
|
|
109
93
|
if (surface) {
|
|
110
94
|
backgroundColor = theme.colors.background.surface;
|
|
111
95
|
}
|
|
112
96
|
|
|
113
|
-
const maxContentSize = heightDevice - 52 - keyboardHeight;
|
|
114
|
-
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
const onKeyboardShow = (e: any) => {
|
|
117
|
-
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
118
|
-
setKeyboardHeight(e.endCoordinates.height);
|
|
119
|
-
};
|
|
120
|
-
const onKeyboardHide = () => {
|
|
121
|
-
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
122
|
-
setKeyboardHeight(0);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const showSub = Keyboard.addListener('keyboardWillShow', onKeyboardShow);
|
|
126
|
-
const hideSub = Keyboard.addListener('keyboardWillHide', onKeyboardHide);
|
|
127
|
-
|
|
128
|
-
return () => {
|
|
129
|
-
showSub.remove();
|
|
130
|
-
hideSub.remove();
|
|
131
|
-
};
|
|
132
|
-
}, []);
|
|
133
|
-
|
|
134
97
|
/**
|
|
135
98
|
* emit dismiss event
|
|
136
99
|
*/
|
|
@@ -142,17 +105,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
142
105
|
};
|
|
143
106
|
}, []);
|
|
144
107
|
|
|
145
|
-
/**
|
|
146
|
-
* handle content bottom sheet change
|
|
147
|
-
* @param width
|
|
148
|
-
* @param height
|
|
149
|
-
*/
|
|
150
|
-
const handleContentSizeChange = (width: number, height: number) => {
|
|
151
|
-
if (contentHeight !== height) {
|
|
152
|
-
setContentHeight(height);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
108
|
/**
|
|
157
109
|
* handler dismiss
|
|
158
110
|
*/
|
|
@@ -264,13 +216,9 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
264
216
|
<Animated.View
|
|
265
217
|
style={{
|
|
266
218
|
transform: [{translateY}],
|
|
267
|
-
maxHeight: maxContentSize,
|
|
268
219
|
}}>
|
|
269
220
|
{renderHeader()}
|
|
270
|
-
<
|
|
271
|
-
scrollEnabled={contentHeight + 20 > maxContentSize}
|
|
272
|
-
style={{backgroundColor: backgroundColor}}
|
|
273
|
-
onContentSizeChange={handleContentSizeChange}>
|
|
221
|
+
<View style={{backgroundColor: backgroundColor}}>
|
|
274
222
|
<Screen
|
|
275
223
|
{...props}
|
|
276
224
|
{...props.route.params}
|
|
@@ -279,7 +227,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
279
227
|
{useBottomInset && (
|
|
280
228
|
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
281
229
|
)}
|
|
282
|
-
</
|
|
230
|
+
</View>
|
|
283
231
|
</Animated.View>
|
|
284
232
|
</KeyboardAvoidingView>
|
|
285
233
|
</Container>
|
|
@@ -50,7 +50,6 @@ const HeaderRight: React.FC<any> = props => {
|
|
|
50
50
|
const HeaderToolkitAction: React.FC<any> = ({
|
|
51
51
|
tintColor,
|
|
52
52
|
preventClose,
|
|
53
|
-
useSystemTools = true,
|
|
54
53
|
useShortcut = false,
|
|
55
54
|
useMore = false,
|
|
56
55
|
tools = [],
|
|
@@ -199,7 +198,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
199
198
|
navigator?.maxApi?.dispatchFunction?.(
|
|
200
199
|
'showTools',
|
|
201
200
|
{
|
|
202
|
-
useSystemTools,
|
|
203
201
|
tools,
|
|
204
202
|
context,
|
|
205
203
|
},
|
package/Application/types.ts
CHANGED
|
@@ -98,7 +98,6 @@ export type Tool = {
|
|
|
98
98
|
name: {vi: string; en: string};
|
|
99
99
|
key: string;
|
|
100
100
|
showBadge?: boolean;
|
|
101
|
-
showRightIcon?: boolean;
|
|
102
101
|
onPress: () => void;
|
|
103
102
|
};
|
|
104
103
|
|
|
@@ -151,7 +150,6 @@ export type BottomSheetParams = {
|
|
|
151
150
|
useBottomInset?: boolean;
|
|
152
151
|
useKeyboardAvoidingView?: boolean;
|
|
153
152
|
keyboardVerticalOffset?: number;
|
|
154
|
-
useScrollOverflow?: boolean;
|
|
155
153
|
};
|
|
156
154
|
|
|
157
155
|
export interface NavigationButtonProps extends TouchableOpacityProps {
|
package/Divider/index.tsx
CHANGED
|
@@ -1,43 +1,19 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
|
-
import {View
|
|
2
|
+
import {View} from 'react-native';
|
|
3
3
|
import {ApplicationContext} from '../Application';
|
|
4
4
|
import {Spacing} from '../Consts';
|
|
5
|
-
import {DashDivider} from './DashDivider';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Custom styles for divider
|
|
10
|
-
*/
|
|
11
|
-
style?: ViewStyle;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Enable margin vertical 4px
|
|
15
|
-
*/
|
|
16
|
-
useMargin?: boolean;
|
|
17
|
-
|
|
18
|
-
type?: 'dash' | 'default';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const Divider: React.FC<DividerProps> = ({
|
|
22
|
-
style,
|
|
23
|
-
useMargin = true,
|
|
24
|
-
type = 'default',
|
|
25
|
-
}) => {
|
|
6
|
+
const Divider = () => {
|
|
26
7
|
const {theme} = useContext(ApplicationContext);
|
|
27
8
|
|
|
28
|
-
if (type === 'dash') return <DashDivider style={style} />;
|
|
29
|
-
|
|
30
9
|
return (
|
|
31
10
|
<View
|
|
32
|
-
style={
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
marginVertical: useMargin ? Spacing.XS : 0,
|
|
39
|
-
},
|
|
40
|
-
]}
|
|
11
|
+
style={{
|
|
12
|
+
height: 1,
|
|
13
|
+
width: '100%',
|
|
14
|
+
backgroundColor: theme.colors.border.default,
|
|
15
|
+
marginVertical: Spacing.XS,
|
|
16
|
+
}}
|
|
41
17
|
/>
|
|
42
18
|
);
|
|
43
19
|
};
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
NativeSyntheticEvent,
|
|
13
13
|
TextInput,
|
|
14
14
|
TextInputFocusEventData,
|
|
15
|
-
TouchableOpacity,
|
|
16
15
|
View,
|
|
17
16
|
} from 'react-native';
|
|
18
17
|
import {
|
|
@@ -25,7 +24,6 @@ import {scaleSize, Text} from '../Text';
|
|
|
25
24
|
import {ErrorView, getBorderColor} from './common';
|
|
26
25
|
import {CaretProps, InputOTPProps} from './index';
|
|
27
26
|
import styles from './styles';
|
|
28
|
-
import {Icon} from "../Icon";
|
|
29
27
|
|
|
30
28
|
const OTPCaret: FC<CaretProps> = ({index, length}) => {
|
|
31
29
|
const DURATION = 300;
|
|
@@ -134,10 +132,6 @@ const InputOTP = forwardRef(
|
|
|
134
132
|
onChangeText?.(text);
|
|
135
133
|
};
|
|
136
134
|
|
|
137
|
-
const onClearText = () => {
|
|
138
|
-
_onChangeText('');
|
|
139
|
-
};
|
|
140
|
-
|
|
141
135
|
const renderInputs = (inputLength: number) => {
|
|
142
136
|
const TextInputs: React.ReactNode[] = [];
|
|
143
137
|
for (let i = 0; i < inputLength; i++) {
|
|
@@ -221,11 +215,6 @@ const InputOTP = forwardRef(
|
|
|
221
215
|
</Text>
|
|
222
216
|
</View>
|
|
223
217
|
)}
|
|
224
|
-
{value.length > 0 && focused && (
|
|
225
|
-
<TouchableOpacity onPress={onClearText} style={styles.clearIcon}>
|
|
226
|
-
<Icon source={'24_navigation_close_circle_full'} size={12} />
|
|
227
|
-
</TouchableOpacity>
|
|
228
|
-
)}
|
|
229
218
|
<View style={styles.otpInputsView}>
|
|
230
219
|
{length ? renderInputs(length) : renderUnidentifiedInputs()}
|
|
231
220
|
</View>
|
package/Input/styles.ts
CHANGED
|
@@ -150,14 +150,8 @@ export default StyleSheet.create({
|
|
|
150
150
|
otpInput: {
|
|
151
151
|
height: 56,
|
|
152
152
|
borderRadius: Radius.S,
|
|
153
|
-
justifyContent: 'center',
|
|
154
153
|
borderWidth: 1,
|
|
155
154
|
},
|
|
156
|
-
clearIcon: {
|
|
157
|
-
position: 'absolute',
|
|
158
|
-
right: Spacing.M,
|
|
159
|
-
zIndex: 4,
|
|
160
|
-
},
|
|
161
155
|
otpFloatingView: {
|
|
162
156
|
position: 'absolute',
|
|
163
157
|
top: -Spacing.M + 2,
|
package/Text/utils.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import {Dimensions
|
|
1
|
+
import {Dimensions} from 'react-native';
|
|
2
2
|
|
|
3
3
|
const deviceWidth = Dimensions.get('window').width;
|
|
4
4
|
const DEFAULT_SCREEN_SIZE = 375;
|
|
5
|
-
const MAX_FONT_SCALE = 1.2;
|
|
6
|
-
const MAX_DEVICE_SCALE = 5;
|
|
7
|
-
|
|
8
5
|
const scaleSize = (size: number) => {
|
|
9
|
-
const
|
|
10
|
-
const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
|
|
11
|
-
let fontSize = size;
|
|
12
|
-
|
|
13
|
-
if (deviceScale > 1) {
|
|
14
|
-
fontSize = Math.min(fontSize * deviceScale, fontSize + MAX_DEVICE_SCALE);
|
|
15
|
-
}
|
|
6
|
+
const scaleRate = deviceWidth / DEFAULT_SCREEN_SIZE;
|
|
16
7
|
|
|
17
|
-
if (
|
|
18
|
-
|
|
8
|
+
if (scaleRate > 1) {
|
|
9
|
+
return Math.min(Math.round(size * scaleRate), size + 3);
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
return
|
|
12
|
+
return size;
|
|
22
13
|
};
|
|
23
14
|
|
|
24
15
|
export {scaleSize};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.116.2",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -14,14 +14,13 @@
|
|
|
14
14
|
"react-native-linear-gradient": "2.8.3",
|
|
15
15
|
"react-native-gesture-handler": "1.10.3",
|
|
16
16
|
"react-native-fast-image": "8.1.5",
|
|
17
|
-
"@react-navigation/bottom-tabs": "https://gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
|
|
18
17
|
"@react-navigation/core": "5.16.1",
|
|
19
18
|
"@react-navigation/native": "5.9.8",
|
|
20
19
|
"@react-navigation/routers": "5.7.4",
|
|
21
|
-
"react-native-reanimated": "git+https://gitlab.mservice.com.vn/momo-platform/react-native-reanimated.git#v1.13.4_gradle_7",
|
|
22
|
-
"lottie-react-native": "git+https://gitlab.mservice.com.vn/momo-platform/momo-lottie-react-native.git",
|
|
23
|
-
"@react-navigation/stack": "https://gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git",
|
|
24
|
-
"react-
|
|
20
|
+
"react-native-reanimated": "git+https://oauth2:q9C8ByV3vnsw_vjwrDay@gitlab.mservice.com.vn/momo-platform/react-native-reanimated.git#v1.13.4_gradle_7",
|
|
21
|
+
"lottie-react-native": "git+https://oauth2:oZFuaMKUc7GV7HeP8xq6@gitlab.mservice.com.vn/momo-platform/momo-lottie-react-native.git",
|
|
22
|
+
"@react-navigation/stack": "git+https://oauth2:ntR45Ct8MSUKVd52rG7a@gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git",
|
|
23
|
+
"@react-navigation/bottom-tabs": "git+https://oauth2:RQq-YxRT5sme7Hx3xkKk@gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git"
|
|
25
24
|
},
|
|
26
25
|
"peerDependencies": {
|
|
27
26
|
"react-native": "*"
|
package/Divider/DashDivider.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React, {useContext} from 'react';
|
|
2
|
-
import {View, ViewStyle} from 'react-native';
|
|
3
|
-
import {ApplicationContext} from '../Application';
|
|
4
|
-
import {Spacing} from '../Consts';
|
|
5
|
-
import Svg, {Line} from 'react-native-svg';
|
|
6
|
-
|
|
7
|
-
export interface DashDividerProps {
|
|
8
|
-
/**
|
|
9
|
-
* Custom styles for dash divider
|
|
10
|
-
*/
|
|
11
|
-
style?: ViewStyle;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const DashDivider: React.FC<DashDividerProps> = ({style}) => {
|
|
15
|
-
const {theme} = useContext(ApplicationContext);
|
|
16
|
-
const borderColor = theme.colors.border.default;
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<View
|
|
20
|
-
style={[
|
|
21
|
-
{
|
|
22
|
-
width: '100%',
|
|
23
|
-
height: 1,
|
|
24
|
-
marginVertical: Spacing.XS,
|
|
25
|
-
},
|
|
26
|
-
style,
|
|
27
|
-
]}>
|
|
28
|
-
<Svg height="1" width="100%">
|
|
29
|
-
<Line
|
|
30
|
-
x1="0"
|
|
31
|
-
y1="0"
|
|
32
|
-
x2="100%"
|
|
33
|
-
y2="0"
|
|
34
|
-
stroke={borderColor}
|
|
35
|
-
strokeWidth="1"
|
|
36
|
-
strokeDasharray={`4, 4`}
|
|
37
|
-
strokeLinecap={'round'}
|
|
38
|
-
strokeLinejoin={'miter'}
|
|
39
|
-
/>
|
|
40
|
-
</Svg>
|
|
41
|
-
</View>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export {DashDivider};
|