@momo-kits/foundation 0.76.1-beta.2 → 0.77.1-optimize.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/BottomTab/BottomTabBar.tsx +478 -0
- package/Application/BottomTab/index.tsx +134 -0
- package/Application/Components.tsx +339 -161
- package/Application/ModalScreen.tsx +113 -99
- package/Application/Navigation.ts +22 -16
- package/Application/NavigationContainer.tsx +99 -48
- package/Application/Navigator.ts +110 -41
- package/Application/StackScreen.tsx +126 -8
- package/Application/index.ts +23 -4
- package/Application/types.ts +84 -33
- package/Application/utils.tsx +90 -50
- package/Assets/DotAnimation.json +256 -0
- package/Assets/SpinnerAnimation.json +1027 -0
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +202 -0
- package/Badge/Badge.tsx +56 -0
- package/Badge/BadgeDot.tsx +11 -0
- package/Badge/BadgeRibbon.tsx +125 -0
- package/Badge/Shape.tsx +29 -0
- package/Badge/index.tsx +7 -0
- package/Badge/styles.ts +58 -0
- package/Badge/types.ts +63 -0
- package/Button/index.tsx +90 -39
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +58 -43
- package/CheckBox/styles.ts +1 -1
- package/CheckBox/types.ts +6 -4
- package/Consts/colors+spacing+radius.ts +18 -0
- package/Consts/styles.ts +0 -26
- package/Consts/theme.ts +4 -0
- package/Divider/index.tsx +2 -0
- package/Icon/index.tsx +13 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +60 -48
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +227 -116
- package/Input/InputDropDown.tsx +132 -0
- package/Input/InputMoney.tsx +174 -111
- package/Input/InputOTP.tsx +257 -0
- package/Input/InputSearch.tsx +160 -132
- package/Input/InputTextArea.tsx +150 -123
- package/Input/common.tsx +42 -17
- package/Input/index.tsx +204 -18
- package/Input/styles.ts +44 -7
- package/Input/utils.ts +2 -2
- package/Layout/Card.tsx +67 -29
- package/Layout/FloatingButton.tsx +128 -0
- package/Layout/GridSystem.tsx +31 -21
- package/Layout/Item.tsx +21 -25
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +348 -153
- package/Layout/Section.tsx +66 -34
- package/Layout/index.ts +13 -3
- package/Layout/styles.ts +101 -0
- package/Layout/types.ts +1 -39
- package/Layout/utils.ts +27 -52
- package/Loader/DotLoader.tsx +37 -0
- package/Loader/Loader.tsx +13 -0
- package/Loader/ProgressBar.tsx +44 -0
- package/Loader/Spinner.tsx +29 -0
- package/Loader/index.tsx +4 -0
- package/Loader/styles.ts +10 -0
- package/Loader/types.ts +35 -0
- package/Loader/utils.ts +25 -0
- package/Pagination/PaginationDot.tsx +7 -2
- package/Pagination/PaginationNumber.tsx +8 -6
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Pagination/PaginationWhiteDot.tsx +8 -5
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Popup/PopupNotify.tsx +102 -44
- package/Popup/PopupPromotion.tsx +63 -22
- package/Popup/types.ts +15 -4
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +7 -5
- package/Skeleton/index.tsx +1 -1
- package/Skeleton/types.ts +3 -0
- package/Switch/index.tsx +35 -24
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +27 -22
- package/Text/styles.ts +38 -0
- package/Text/types.ts +25 -13
- package/Text/utils.ts +1 -1
- package/Title/index.tsx +186 -0
- package/Title/styles.ts +79 -0
- package/Title/types.ts +20 -0
- package/code-scanner.js +143 -0
- package/index.ts +8 -1
- package/migrate_typo.js +56 -0
- package/package.json +14 -9
- package/tsconfig.json +24 -0
- package/verify.js +47 -0
- package/Application/BottomTab.tsx +0 -52
- package/Application/NavigationButton.tsx +0 -54
- package/Assets/header-background.png +0 -0
package/Text/index.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import {Text as RNText, TextProps as RNTextProps} from 'react-native';
|
|
|
3
3
|
import styles from './styles';
|
|
4
4
|
import {Typography, TypographyWeight} from './types';
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
|
-
import {GridContext} from '../Layout';
|
|
7
6
|
import {scaleSize} from './utils';
|
|
8
7
|
|
|
9
8
|
const SFProText: TypographyWeight = {
|
|
@@ -51,22 +50,30 @@ export interface TextProps extends RNTextProps {
|
|
|
51
50
|
* It can be any valid color string (e.g., hex, rgb, rgba, etc.).
|
|
52
51
|
*/
|
|
53
52
|
color?: string;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Optional. Represents the width of the Text component in terms of span numbers.
|
|
57
|
-
* It can be used to set a specific width for the text based on a predefined grid system.
|
|
58
|
-
*/
|
|
59
|
-
widthSpan?: number;
|
|
60
53
|
}
|
|
54
|
+
|
|
55
|
+
const deprecatedValues: Typography[] = [
|
|
56
|
+
'headline_default',
|
|
57
|
+
'headline_l',
|
|
58
|
+
'headline_xl',
|
|
59
|
+
'title_default',
|
|
60
|
+
'title_xs',
|
|
61
|
+
'title_s',
|
|
62
|
+
'header_default',
|
|
63
|
+
'paragraph_default',
|
|
64
|
+
'paragraph_bold',
|
|
65
|
+
'paragraph_italic',
|
|
66
|
+
'label_xxs',
|
|
67
|
+
'action_s',
|
|
68
|
+
];
|
|
69
|
+
|
|
61
70
|
const Text: React.FC<TextProps> = ({
|
|
62
|
-
typography,
|
|
71
|
+
typography = 'body_default_regular',
|
|
63
72
|
color,
|
|
64
73
|
children,
|
|
65
74
|
style,
|
|
66
|
-
widthSpan,
|
|
67
75
|
...rest
|
|
68
76
|
}) => {
|
|
69
|
-
const grid = useContext(GridContext);
|
|
70
77
|
const {theme} = useContext(ApplicationContext);
|
|
71
78
|
|
|
72
79
|
const getTypoStyle = (typo: Typography) => {
|
|
@@ -93,32 +100,30 @@ const Text: React.FC<TextProps> = ({
|
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
return {
|
|
103
|
+
...typoStyle,
|
|
96
104
|
fontFamily,
|
|
97
105
|
fontSize: scaleSize(fontSize),
|
|
98
106
|
lineHeight: scaleSize(lineHeight),
|
|
99
107
|
fontStyle,
|
|
108
|
+
fontWeight,
|
|
100
109
|
};
|
|
101
110
|
};
|
|
102
111
|
|
|
103
112
|
const textStyle = getTypoStyle(typography);
|
|
104
|
-
|
|
113
|
+
|
|
114
|
+
if (deprecatedValues.includes(typography)) {
|
|
115
|
+
console.warn(
|
|
116
|
+
`Warning: The typography value "${typography}" is deprecated.`,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
105
120
|
return (
|
|
106
121
|
<RNText
|
|
107
122
|
{...rest}
|
|
108
|
-
|
|
109
|
-
style={[
|
|
110
|
-
style,
|
|
111
|
-
textStyle,
|
|
112
|
-
spanStyle,
|
|
113
|
-
{color: color ?? theme.colors.text.default},
|
|
114
|
-
]}>
|
|
123
|
+
style={[style, textStyle, {color: color ?? theme.colors.text.default}]}>
|
|
115
124
|
{children ?? ''}
|
|
116
125
|
</RNText>
|
|
117
126
|
);
|
|
118
127
|
};
|
|
119
128
|
|
|
120
|
-
Text.defaultProps = {
|
|
121
|
-
typography: 'paragraph_default',
|
|
122
|
-
};
|
|
123
|
-
|
|
124
129
|
export {Text, scaleSize};
|
package/Text/styles.ts
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
export default {
|
|
2
|
+
headline_default_bold: {fontSize: 24, lineHeight: 34, fontWeight: '700'},
|
|
3
|
+
header_m_bold: {fontSize: 18, lineHeight: 26, fontWeight: '700'},
|
|
4
|
+
header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
|
|
5
|
+
header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
|
|
6
|
+
header_xs_semibold: {fontSize: 12, lineHeight: 18, fontWeight: '600'},
|
|
7
|
+
body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
|
|
8
|
+
body_default_regularstrikethrought: {
|
|
9
|
+
fontSize: 14,
|
|
10
|
+
lineHeight: 20,
|
|
11
|
+
fontWeight: '400',
|
|
12
|
+
textDecorationLine: 'line-through',
|
|
13
|
+
},
|
|
14
|
+
description_default_regular: {
|
|
15
|
+
fontSize: 12,
|
|
16
|
+
lineHeight: 18,
|
|
17
|
+
fontWeight: '400',
|
|
18
|
+
},
|
|
19
|
+
description_default_regularstrikethrought: {
|
|
20
|
+
fontSize: 12,
|
|
21
|
+
lineHeight: 18,
|
|
22
|
+
fontWeight: '400',
|
|
23
|
+
textDecorationLine: 'line-through',
|
|
24
|
+
},
|
|
25
|
+
description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
|
|
26
|
+
description_xs_regularstrikethrought: {
|
|
27
|
+
fontSize: 10,
|
|
28
|
+
lineHeight: 14,
|
|
29
|
+
fontWeight: '400',
|
|
30
|
+
textDecorationLine: 'line-through',
|
|
31
|
+
},
|
|
32
|
+
label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
|
|
33
|
+
label_s_medium: {fontSize: 12, lineHeight: 18, fontWeight: '500'},
|
|
34
|
+
label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
|
|
35
|
+
action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
|
|
36
|
+
action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
|
|
37
|
+
action_xs_bold: {fontSize: 12, lineHeight: 18, fontWeight: '700'},
|
|
38
|
+
action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
|
|
39
|
+
/**non-support**/
|
|
2
40
|
headline_default: {
|
|
3
41
|
fontSize: 28,
|
|
4
42
|
lineHeight: 34,
|
package/Text/types.ts
CHANGED
|
@@ -14,27 +14,39 @@ export type TypographyWeight = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export type Typography =
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
**/
|
|
17
20
|
| 'headline_default'
|
|
18
|
-
| 'headline_s'
|
|
19
21
|
| 'headline_l'
|
|
20
22
|
| 'headline_xl'
|
|
21
23
|
| 'title_default'
|
|
22
24
|
| 'title_xs'
|
|
23
25
|
| 'title_s'
|
|
24
26
|
| 'header_default'
|
|
25
|
-
| 'header_xs'
|
|
26
|
-
| 'header_s'
|
|
27
27
|
| 'paragraph_default'
|
|
28
28
|
| 'paragraph_bold'
|
|
29
29
|
| 'paragraph_italic'
|
|
30
|
-
| 'description_default'
|
|
31
|
-
| 'description_xs'
|
|
32
|
-
| 'description_s'
|
|
33
|
-
| 'label_default'
|
|
34
30
|
| 'label_xxs'
|
|
35
|
-
| '
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| '
|
|
40
|
-
| '
|
|
31
|
+
| 'action_s'
|
|
32
|
+
/**
|
|
33
|
+
* end
|
|
34
|
+
**/
|
|
35
|
+
| 'headline_default_bold'
|
|
36
|
+
| 'header_m_bold'
|
|
37
|
+
| 'header_default_bold'
|
|
38
|
+
| 'header_s_semibold'
|
|
39
|
+
| 'header_xs_semibold'
|
|
40
|
+
| 'body_default_regular'
|
|
41
|
+
| 'body_default_regularstrikethrought'
|
|
42
|
+
| 'description_default_regular'
|
|
43
|
+
| 'description_default_regularstrikethrought'
|
|
44
|
+
| 'description_xs_regular'
|
|
45
|
+
| 'description_xs_regularstrikethrought'
|
|
46
|
+
| 'label_default_medium'
|
|
47
|
+
| 'label_s_medium'
|
|
48
|
+
| 'label_xs_medium'
|
|
49
|
+
| 'action_default_bold'
|
|
50
|
+
| 'action_s_bold'
|
|
51
|
+
| 'action_xs_bold'
|
|
52
|
+
| 'action_xxs_bold';
|
package/Text/utils.ts
CHANGED
package/Title/index.tsx
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import React, {FC, useContext, useState} from 'react';
|
|
2
|
+
import {Text as RNText, TouchableOpacity, View, ViewStyle} from 'react-native';
|
|
3
|
+
import styles from './styles';
|
|
4
|
+
import {Icon} from '../Icon';
|
|
5
|
+
import {scaleSize, Text} from '../Text';
|
|
6
|
+
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {Badge} from '../Badge';
|
|
8
|
+
import {Typography} from '../Text/types';
|
|
9
|
+
import {TitleProps} from './types';
|
|
10
|
+
import {Colors} from '../Consts';
|
|
11
|
+
|
|
12
|
+
const Title: FC<TitleProps> = ({
|
|
13
|
+
title = 'Title',
|
|
14
|
+
type = 'section',
|
|
15
|
+
size = 'medium',
|
|
16
|
+
icon,
|
|
17
|
+
description,
|
|
18
|
+
iconColor = null,
|
|
19
|
+
iconAlign = 'top',
|
|
20
|
+
showRightAction = false,
|
|
21
|
+
showTrailingAction = false,
|
|
22
|
+
badgeLabel,
|
|
23
|
+
buttonTitle,
|
|
24
|
+
onPressRightAction = () => {},
|
|
25
|
+
onPressTrailingAction = () => {},
|
|
26
|
+
buttonSize = 'small',
|
|
27
|
+
textOnly = false,
|
|
28
|
+
style,
|
|
29
|
+
}) => {
|
|
30
|
+
const {theme} = useContext(ApplicationContext);
|
|
31
|
+
const [badgeWidth, setBadgeWidth] = useState(0);
|
|
32
|
+
const [contentWidth, setContentWidth] = useState(0);
|
|
33
|
+
const styleSheet: {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
} = styles;
|
|
36
|
+
const typography = `${type}_${size}`;
|
|
37
|
+
const isSection = type === 'section';
|
|
38
|
+
const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
|
|
39
|
+
const buttonTypo: Typography =
|
|
40
|
+
buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
|
|
41
|
+
const flexStyle = showTrailingAction && {maxWidth: '70%'};
|
|
42
|
+
|
|
43
|
+
const renderIcon = () => {
|
|
44
|
+
if (!icon) return null;
|
|
45
|
+
|
|
46
|
+
let iconStyle: ViewStyle = {
|
|
47
|
+
justifyContent: 'flex-start',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (iconAlign === 'middle') {
|
|
51
|
+
iconStyle = {justifyContent: 'center'};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (iconAlign === 'bottom') {
|
|
55
|
+
iconStyle = {justifyContent: 'flex-end'};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View style={[styles.iconView, iconStyle]}>
|
|
60
|
+
<Icon color={iconColor} source={icon} />
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const renderContent = () => {
|
|
66
|
+
return (
|
|
67
|
+
<View style={styles.contentView}>
|
|
68
|
+
<View
|
|
69
|
+
onLayout={e => {
|
|
70
|
+
setContentWidth(e.nativeEvent.layout.width);
|
|
71
|
+
}}
|
|
72
|
+
style={[styles.iconLeftView, flexStyle]}>
|
|
73
|
+
<RNText
|
|
74
|
+
numberOfLines={numberOfLines}
|
|
75
|
+
style={[
|
|
76
|
+
styleSheet[typography],
|
|
77
|
+
styles.title,
|
|
78
|
+
{maxWidth: contentWidth - badgeWidth},
|
|
79
|
+
]}>
|
|
80
|
+
{title}
|
|
81
|
+
</RNText>
|
|
82
|
+
{badgeLabel && (
|
|
83
|
+
<View
|
|
84
|
+
onLayout={e => {
|
|
85
|
+
setBadgeWidth(e.nativeEvent.layout.width);
|
|
86
|
+
}}
|
|
87
|
+
style={{
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
}}>
|
|
90
|
+
<Badge style={styles.badge} label={badgeLabel} />
|
|
91
|
+
</View>
|
|
92
|
+
)}
|
|
93
|
+
{renderActionLeft()}
|
|
94
|
+
</View>
|
|
95
|
+
{description && (
|
|
96
|
+
<Text
|
|
97
|
+
style={styles.description}
|
|
98
|
+
color={theme.colors.text.secondary}
|
|
99
|
+
typography={'description_default_regular'}>
|
|
100
|
+
{description}
|
|
101
|
+
</Text>
|
|
102
|
+
)}
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const renderActionLeft = () => {
|
|
108
|
+
return (
|
|
109
|
+
<TouchableOpacity
|
|
110
|
+
onPress={onPressTrailingAction}
|
|
111
|
+
style={styles.iconLeftView}>
|
|
112
|
+
{showTrailingAction && !showRightAction && (
|
|
113
|
+
<View
|
|
114
|
+
style={[
|
|
115
|
+
styles.iconLeft,
|
|
116
|
+
{
|
|
117
|
+
backgroundColor: isSection
|
|
118
|
+
? Colors.black_06 + '99'
|
|
119
|
+
: Colors.black_06 + '4D',
|
|
120
|
+
},
|
|
121
|
+
]}>
|
|
122
|
+
<Icon
|
|
123
|
+
source={'arrow_chevron_right_small'}
|
|
124
|
+
size={scaleSize(18)}
|
|
125
|
+
color={theme.colors.text.default}
|
|
126
|
+
/>
|
|
127
|
+
</View>
|
|
128
|
+
)}
|
|
129
|
+
</TouchableOpacity>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const renderActionRight = () => {
|
|
134
|
+
if (!showRightAction || showTrailingAction) return false;
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<View>
|
|
138
|
+
{!buttonTitle ? (
|
|
139
|
+
<TouchableOpacity
|
|
140
|
+
onPress={onPressRightAction}
|
|
141
|
+
style={[
|
|
142
|
+
styles.iconRight,
|
|
143
|
+
{
|
|
144
|
+
backgroundColor: theme.colors.primary + '0F',
|
|
145
|
+
},
|
|
146
|
+
]}>
|
|
147
|
+
<Icon
|
|
148
|
+
source={'arrow_chevron_right_small'}
|
|
149
|
+
size={scaleSize(22)}
|
|
150
|
+
color={theme.colors.primary}
|
|
151
|
+
/>
|
|
152
|
+
</TouchableOpacity>
|
|
153
|
+
) : (
|
|
154
|
+
<TouchableOpacity onPress={onPressRightAction}>
|
|
155
|
+
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
156
|
+
{buttonTitle}
|
|
157
|
+
</Text>
|
|
158
|
+
</TouchableOpacity>
|
|
159
|
+
)}
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
if (textOnly) {
|
|
165
|
+
return (
|
|
166
|
+
<View style={isSection && styles.margin}>
|
|
167
|
+
<RNText
|
|
168
|
+
numberOfLines={numberOfLines}
|
|
169
|
+
style={[styleSheet[typography], styles.title]}>
|
|
170
|
+
{title}
|
|
171
|
+
</RNText>
|
|
172
|
+
</View>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<View style={[style, styles.wrapper, isSection && styles.margin]}>
|
|
178
|
+
{renderIcon()}
|
|
179
|
+
{renderContent()}
|
|
180
|
+
{renderActionRight()}
|
|
181
|
+
</View>
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export {Title};
|
|
186
|
+
export type {TitleProps};
|
package/Title/styles.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {scaleSize} from '../Text';
|
|
3
|
+
import {Colors, Radius, Spacing} from '../Consts';
|
|
4
|
+
|
|
5
|
+
export default StyleSheet.create({
|
|
6
|
+
card_small: {
|
|
7
|
+
fontSize: scaleSize(14),
|
|
8
|
+
lineHeight: scaleSize(20),
|
|
9
|
+
},
|
|
10
|
+
card_medium: {
|
|
11
|
+
fontSize: scaleSize(16),
|
|
12
|
+
lineHeight: scaleSize(22),
|
|
13
|
+
},
|
|
14
|
+
card_large: {
|
|
15
|
+
fontSize: scaleSize(18),
|
|
16
|
+
lineHeight: scaleSize(26),
|
|
17
|
+
},
|
|
18
|
+
section_medium: {
|
|
19
|
+
fontSize: scaleSize(20),
|
|
20
|
+
lineHeight: scaleSize(28),
|
|
21
|
+
},
|
|
22
|
+
section_small: {
|
|
23
|
+
fontSize: scaleSize(16),
|
|
24
|
+
lineHeight: scaleSize(22),
|
|
25
|
+
},
|
|
26
|
+
section_large: {
|
|
27
|
+
fontSize: scaleSize(24),
|
|
28
|
+
lineHeight: scaleSize(34),
|
|
29
|
+
},
|
|
30
|
+
actionIcon: {
|
|
31
|
+
borderRadius: Radius.M,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
},
|
|
35
|
+
icon: {
|
|
36
|
+
marginRight: Spacing.S,
|
|
37
|
+
borderRadius: Radius.XS,
|
|
38
|
+
},
|
|
39
|
+
wrapper: {
|
|
40
|
+
flexDirection: 'row',
|
|
41
|
+
},
|
|
42
|
+
margin: {
|
|
43
|
+
marginTop: Spacing.S,
|
|
44
|
+
},
|
|
45
|
+
iconView: {
|
|
46
|
+
marginRight: Spacing.S,
|
|
47
|
+
},
|
|
48
|
+
iconRight: {
|
|
49
|
+
width: scaleSize(22),
|
|
50
|
+
height: scaleSize(22),
|
|
51
|
+
borderRadius: Radius.M,
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
marginLeft: Spacing.S,
|
|
55
|
+
},
|
|
56
|
+
iconLeft: {
|
|
57
|
+
width: scaleSize(18),
|
|
58
|
+
height: scaleSize(18),
|
|
59
|
+
borderRadius: Radius.M,
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
justifyContent: 'center',
|
|
62
|
+
marginHorizontal: Spacing.XS,
|
|
63
|
+
},
|
|
64
|
+
iconLeftView: {
|
|
65
|
+
flexDirection: 'row',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
},
|
|
68
|
+
contentView: {marginRight: Spacing.S, flex: 1},
|
|
69
|
+
title: {
|
|
70
|
+
fontWeight: 'bold',
|
|
71
|
+
color: Colors.black_17,
|
|
72
|
+
},
|
|
73
|
+
badge: {
|
|
74
|
+
marginLeft: Spacing.XS,
|
|
75
|
+
},
|
|
76
|
+
description: {
|
|
77
|
+
marginTop: Spacing.XS,
|
|
78
|
+
},
|
|
79
|
+
});
|
package/Title/types.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type TitleProps = {
|
|
4
|
+
type?: 'card' | 'section';
|
|
5
|
+
size?: 'small' | 'medium' | 'large';
|
|
6
|
+
title: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
iconColor?: string;
|
|
10
|
+
iconAlign?: 'top' | 'middle' | 'bottom';
|
|
11
|
+
showRightAction?: boolean;
|
|
12
|
+
showTrailingAction?: boolean;
|
|
13
|
+
badgeLabel?: string;
|
|
14
|
+
buttonTitle?: string;
|
|
15
|
+
buttonSize?: 'small' | 'large';
|
|
16
|
+
onPressRightAction?: () => void;
|
|
17
|
+
onPressTrailingAction?: () => void;
|
|
18
|
+
textOnly?: boolean;
|
|
19
|
+
style?: ViewStyle;
|
|
20
|
+
};
|
package/code-scanner.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const scanner = require('react-scanner');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const scan = async (config) => {
|
|
6
|
+
return await scanner.run(config);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const calcSum = (array) => {
|
|
10
|
+
return array.reduce((a, b) => a + b, 0);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const calculateAdoptionRate = async (branchName , kitJsonPath , miniappJsonPath , reactNativeJsonPath , fsJsonPath ) => {
|
|
14
|
+
const kitJson = require(kitJsonPath);
|
|
15
|
+
const miniAppJson = require(miniappJsonPath);
|
|
16
|
+
const reactNativeJson = require(reactNativeJsonPath);
|
|
17
|
+
const fsJson = require(fsJsonPath);
|
|
18
|
+
|
|
19
|
+
const numOfKitComponents = calcSum(Object.values(kitJson));
|
|
20
|
+
const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
|
|
21
|
+
const numOfReactNativeComponents = calcSum(Object.values(reactNativeJson));
|
|
22
|
+
const numOfFSComponents = calcSum(Object.values(fsJson));
|
|
23
|
+
|
|
24
|
+
const adoptionRate = ((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) / numOfMiniAppComponents) * 100;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
miniAppName: branchName,
|
|
28
|
+
numOfKitComponents: numOfKitComponents,
|
|
29
|
+
numOfMiniAppComponents: numOfMiniAppComponents,
|
|
30
|
+
numOfReactNativeComponents: numOfReactNativeComponents,
|
|
31
|
+
numOfFSComponents: numOfFSComponents,
|
|
32
|
+
adoptionRate: adoptionRate.toFixed(2) + '%'
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function ensureFileExists(filePath , defaultContent = {}) {
|
|
37
|
+
if (!fs.existsSync(filePath)) {
|
|
38
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
39
|
+
fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const sendMessage = ({
|
|
44
|
+
numOfKitComponents,
|
|
45
|
+
numOfMiniAppComponents,
|
|
46
|
+
numOfFSComponents,
|
|
47
|
+
numOfReactNativeComponents,
|
|
48
|
+
adoptionRate,
|
|
49
|
+
miniAppName = ''
|
|
50
|
+
}) => {
|
|
51
|
+
const url = 'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
|
|
52
|
+
|
|
53
|
+
const data = {
|
|
54
|
+
text: `MiniApp: ${miniAppName}\nNumber of kit's components: ${numOfKitComponents}\nNumber of miniapp's components: ${numOfMiniAppComponents}\nNumber of FS's components: ${numOfFSComponents}\nNumber of React Native's components: ${numOfReactNativeComponents}\nAdoption rate: ${adoptionRate}`
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
fetch(url, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: {
|
|
60
|
+
'Content-Type': 'application/json'
|
|
61
|
+
},
|
|
62
|
+
body: JSON.stringify(data)
|
|
63
|
+
})
|
|
64
|
+
.then(response => response.json())
|
|
65
|
+
.then(data => {
|
|
66
|
+
console.log('Success:', data);
|
|
67
|
+
})
|
|
68
|
+
.catch((error) => {
|
|
69
|
+
console.error('Error:', error);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const main = async () => {
|
|
74
|
+
const rootPath = `${__dirname}/../../../`
|
|
75
|
+
const app = path.join(`${__dirname}/../../../`, 'app.json');
|
|
76
|
+
const appJson = require(app)
|
|
77
|
+
const branchName = appJson.appId
|
|
78
|
+
|
|
79
|
+
if (!branchName || !branchName.includes("vn.momo")){
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const scanPath = path.join(rootPath, 'src')
|
|
84
|
+
const kitJsonPath = path.join(rootPath, './scan/kit.json')
|
|
85
|
+
const miniappJsonPath = path.join(rootPath, './scan/miniapp.json')
|
|
86
|
+
const reactNativeJsonPath = path.join(rootPath, './scan/RN.json')
|
|
87
|
+
const fsJsonPath = path.join(rootPath, './scan/verLib.json')
|
|
88
|
+
|
|
89
|
+
const allKitsReg = /@momo-kits/;
|
|
90
|
+
const fsReg = /^(?:@fs-mobile-platform\/(components|investment|screens)|@miniapp-platform\/(components|foundation))$/;
|
|
91
|
+
const RNReg = 'react-native'
|
|
92
|
+
|
|
93
|
+
const config1 = {
|
|
94
|
+
crawlFrom: scanPath,
|
|
95
|
+
includeSubComponents: true,
|
|
96
|
+
importedFrom: allKitsReg,
|
|
97
|
+
processors: [['count-components', { outputTo: kitJsonPath }]],
|
|
98
|
+
rootDir: process.cwd(),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const config2 = {
|
|
102
|
+
crawlFrom: scanPath,
|
|
103
|
+
includeSubComponents: true,
|
|
104
|
+
processors: [['count-components', { outputTo: miniappJsonPath }]],
|
|
105
|
+
rootDir: process.cwd(),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const config3 = {
|
|
109
|
+
crawlFrom: scanPath,
|
|
110
|
+
includeSubComponents: true,
|
|
111
|
+
importedFrom: RNReg,
|
|
112
|
+
processors: [['count-components', { outputTo: reactNativeJsonPath }]],
|
|
113
|
+
rootDir: process.cwd(),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const config4 = {
|
|
117
|
+
crawlFrom: scanPath,
|
|
118
|
+
includeSubComponents: true,
|
|
119
|
+
importedFrom: fsReg,
|
|
120
|
+
processors: [['count-components', { outputTo: fsJsonPath }]],
|
|
121
|
+
rootDir: process.cwd(),
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
ensureFileExists(kitJsonPath, {});
|
|
126
|
+
ensureFileExists(miniappJsonPath, {});
|
|
127
|
+
ensureFileExists(reactNativeJsonPath, {});
|
|
128
|
+
ensureFileExists(fsJsonPath, {});
|
|
129
|
+
|
|
130
|
+
await scan(config1);
|
|
131
|
+
await scan(config2);
|
|
132
|
+
await scan(config3);
|
|
133
|
+
await scan(config4);
|
|
134
|
+
|
|
135
|
+
const result = await calculateAdoptionRate(branchName,kitJsonPath, miniappJsonPath, reactNativeJsonPath, fsJsonPath);
|
|
136
|
+
sendMessage(result)
|
|
137
|
+
console.log(result)
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error("Error during scan or calculation:", error);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
main();
|
package/index.ts
CHANGED
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
useSafeAreaInsets,
|
|
5
5
|
} from 'react-native-safe-area-context';
|
|
6
6
|
import LinearGradient from 'react-native-linear-gradient';
|
|
7
|
+
import {getAccessibilityID} from "./Application/utils";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* native export
|
|
10
11
|
*/
|
|
11
|
-
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
|
|
12
|
+
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient, getAccessibilityID};
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* foundation component
|
|
@@ -43,3 +44,9 @@ export * from './Tag';
|
|
|
43
44
|
export * from './Tag/types';
|
|
44
45
|
export * from './Pagination';
|
|
45
46
|
export * from './Pagination/types';
|
|
47
|
+
export * from './Loader';
|
|
48
|
+
export * from './Loader/types';
|
|
49
|
+
export * from './Title';
|
|
50
|
+
export * from './Title/types';
|
|
51
|
+
export * from './Badge';
|
|
52
|
+
export * from './Badge/types';
|