@momo-kits/foundation 0.92.1-tracking.9 → 0.92.2-tracking.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 +479 -0
- package/Application/{BottomTab.tsx → BottomTab/index.tsx} +19 -14
- package/Application/Components.tsx +48 -48
- package/Application/ModalScreen.tsx +107 -131
- package/Application/NavigationContainer.tsx +57 -54
- package/Application/StackScreen.tsx +76 -66
- package/Application/types.ts +13 -6
- package/Application/utils.tsx +14 -3
- package/Badge/Badge.tsx +1 -1
- package/Button/index.tsx +14 -23
- package/CheckBox/index.tsx +10 -18
- package/CheckBox/types.ts +4 -6
- package/Consts/colors+spacing+radius.ts +14 -0
- package/Icon/index.tsx +8 -8
- package/IconButton/index.tsx +7 -15
- package/Image/index.tsx +20 -10
- package/Image/types.ts +1 -0
- package/Input/Input.tsx +19 -14
- package/Input/InputDropDown.tsx +8 -14
- package/Input/InputMoney.tsx +9 -15
- package/Input/InputOTP.tsx +8 -14
- package/Input/InputSearch.tsx +8 -13
- package/Input/InputTextArea.tsx +5 -9
- package/Input/index.tsx +3 -9
- package/Popup/PopupNotify.tsx +15 -15
- package/Popup/PopupPromotion.tsx +13 -15
- package/Radio/index.tsx +8 -12
- package/Radio/types.ts +4 -7
- package/Switch/index.tsx +14 -19
- package/Switch/types.ts +4 -6
- package/Text/index.tsx +24 -3
- package/Text/styles.ts +3 -3
- package/Text/types.ts +19 -1
- package/Title/index.tsx +148 -102
- package/Title/styles.ts +33 -9
- package/Title/types.ts +12 -48
- package/package.json +3 -1
package/Title/index.tsx
CHANGED
|
@@ -1,129 +1,175 @@
|
|
|
1
1
|
import React, {FC, useContext, useState} from 'react';
|
|
2
|
-
import {
|
|
3
|
-
LayoutChangeEvent,
|
|
4
|
-
NativeSyntheticEvent,
|
|
5
|
-
Text as RNText,
|
|
6
|
-
TextLayoutEventData,
|
|
7
|
-
TouchableOpacity,
|
|
8
|
-
View,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import {TitleProps} from './types';
|
|
11
|
-
import {Icon} from '../Icon';
|
|
2
|
+
import {Text as RNText, TouchableOpacity, View, ViewStyle} from 'react-native';
|
|
12
3
|
import styles from './styles';
|
|
13
|
-
import {
|
|
14
|
-
import {Colors, Spacing} from '../Consts';
|
|
4
|
+
import {Icon} from '../Icon';
|
|
15
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';
|
|
16
11
|
|
|
17
12
|
const Title: FC<TitleProps> = ({
|
|
18
|
-
size = 'large',
|
|
19
|
-
type = 'section',
|
|
20
|
-
onPressAction,
|
|
21
|
-
actionTitle,
|
|
22
13
|
title = 'Title',
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
type = 'section',
|
|
15
|
+
size = 'medium',
|
|
25
16
|
icon,
|
|
26
17
|
description,
|
|
27
|
-
|
|
18
|
+
iconColor = null,
|
|
19
|
+
iconAlign = 'top',
|
|
20
|
+
showRightAction = false,
|
|
21
|
+
showTrailingAction = false,
|
|
22
|
+
badgeLabel,
|
|
23
|
+
buttonTitle,
|
|
24
|
+
onPressRightAction = () => {},
|
|
25
|
+
buttonSize = 'small',
|
|
26
|
+
textOnly = false,
|
|
28
27
|
}) => {
|
|
29
28
|
const {theme} = useContext(ApplicationContext);
|
|
30
|
-
const [
|
|
31
|
-
const [
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const numberOfLines =
|
|
29
|
+
const [badgeWidth, setBadgeWidth] = useState(0);
|
|
30
|
+
const [contentWidth, setContentWidth] = useState(0);
|
|
31
|
+
const styleSheet: {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
} = styles;
|
|
34
|
+
const typography = `${type}_${size}`;
|
|
35
|
+
const isSection = type === 'section';
|
|
36
|
+
const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
|
|
37
|
+
const buttonTypo: Typography =
|
|
38
|
+
buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
|
|
39
|
+
const flexStyle = showTrailingAction && {maxWidth: '70%'};
|
|
38
40
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
/>
|
|
59
|
-
</TouchableOpacity>
|
|
41
|
+
const renderIcon = () => {
|
|
42
|
+
if (!icon) return null;
|
|
43
|
+
|
|
44
|
+
let iconStyle: ViewStyle = {
|
|
45
|
+
justifyContent: 'flex-start',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (iconAlign === 'middle') {
|
|
49
|
+
iconStyle = {justifyContent: 'center'};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (iconAlign === 'bottom') {
|
|
53
|
+
iconStyle = {justifyContent: 'flex-end'};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<View style={[styles.iconView, iconStyle]}>
|
|
58
|
+
<Icon color={iconColor} source={icon} />
|
|
59
|
+
</View>
|
|
60
60
|
);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
const
|
|
64
|
-
if (textLines > 1) return null;
|
|
63
|
+
const renderContent = () => {
|
|
65
64
|
return (
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
<View style={styles.contentView}>
|
|
66
|
+
<View
|
|
67
|
+
onLayout={e => {
|
|
68
|
+
setContentWidth(e.nativeEvent.layout.width);
|
|
69
|
+
}}
|
|
70
|
+
style={[styles.iconLeftView, flexStyle]}>
|
|
71
|
+
<RNText
|
|
72
|
+
numberOfLines={numberOfLines}
|
|
73
|
+
style={[
|
|
74
|
+
styleSheet[typography],
|
|
75
|
+
styles.title,
|
|
76
|
+
{maxWidth: contentWidth - badgeWidth},
|
|
77
|
+
]}>
|
|
78
|
+
{title}
|
|
79
|
+
</RNText>
|
|
80
|
+
{badgeLabel && (
|
|
81
|
+
<View
|
|
82
|
+
onLayout={e => {
|
|
83
|
+
setBadgeWidth(e.nativeEvent.layout.width);
|
|
84
|
+
}}
|
|
85
|
+
style={{
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
}}>
|
|
88
|
+
<Badge style={styles.badge} label={badgeLabel} />
|
|
89
|
+
</View>
|
|
90
|
+
)}
|
|
91
|
+
{renderActionLeft()}
|
|
92
|
+
</View>
|
|
93
|
+
<Text
|
|
94
|
+
color={theme.colors.text.secondary}
|
|
95
|
+
typography={'description_default_regular'}>
|
|
96
|
+
{description}
|
|
97
|
+
</Text>
|
|
98
|
+
</View>
|
|
79
99
|
);
|
|
80
100
|
};
|
|
81
|
-
const onLayout = (e: LayoutChangeEvent) => {
|
|
82
|
-
setContainerWidth(e.nativeEvent.layout.width);
|
|
83
|
-
};
|
|
84
101
|
|
|
85
|
-
const
|
|
86
|
-
|
|
102
|
+
const renderActionLeft = () => {
|
|
103
|
+
return (
|
|
104
|
+
<View style={styles.iconLeftView}>
|
|
105
|
+
{showTrailingAction && !showRightAction && (
|
|
106
|
+
<View
|
|
107
|
+
style={[
|
|
108
|
+
styles.iconLeft,
|
|
109
|
+
{
|
|
110
|
+
backgroundColor: isSection
|
|
111
|
+
? Colors.black_06 + '99'
|
|
112
|
+
: Colors.black_06 + '4D',
|
|
113
|
+
},
|
|
114
|
+
]}>
|
|
115
|
+
<Icon
|
|
116
|
+
source={'arrow_chevron_right_small'}
|
|
117
|
+
size={scaleSize(18)}
|
|
118
|
+
color={theme.colors.text.default}
|
|
119
|
+
/>
|
|
120
|
+
</View>
|
|
121
|
+
)}
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
87
124
|
};
|
|
88
125
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<View style={styles.textContent}>
|
|
126
|
+
const renderActionRight = () => {
|
|
127
|
+
if (!showRightAction || showTrailingAction) return false;
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<View>
|
|
131
|
+
{!buttonTitle ? (
|
|
96
132
|
<View
|
|
97
|
-
style={
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
color: theme.colors.text.default,
|
|
109
|
-
marginRight: Spacing.S,
|
|
110
|
-
},
|
|
111
|
-
]}>
|
|
112
|
-
{title}
|
|
113
|
-
</RNText>
|
|
114
|
-
{!titleFlex && renderSemiAction()}
|
|
133
|
+
style={[
|
|
134
|
+
styles.iconRight,
|
|
135
|
+
{
|
|
136
|
+
backgroundColor: theme.colors.primary + '0F',
|
|
137
|
+
},
|
|
138
|
+
]}>
|
|
139
|
+
<Icon
|
|
140
|
+
source={'arrow_chevron_right_small'}
|
|
141
|
+
size={scaleSize(22)}
|
|
142
|
+
color={theme.colors.primary}
|
|
143
|
+
/>
|
|
115
144
|
</View>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
color={theme.colors.text.secondary}>
|
|
121
|
-
{description}
|
|
145
|
+
) : (
|
|
146
|
+
<TouchableOpacity onPress={onPressRightAction}>
|
|
147
|
+
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
148
|
+
{buttonTitle}
|
|
122
149
|
</Text>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{showAction && titleFlex && type !== 'screen' && renderAction()}
|
|
150
|
+
</TouchableOpacity>
|
|
151
|
+
)}
|
|
126
152
|
</View>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (textOnly) {
|
|
157
|
+
return (
|
|
158
|
+
<View style={isSection && styles.margin}>
|
|
159
|
+
<RNText
|
|
160
|
+
numberOfLines={numberOfLines}
|
|
161
|
+
style={[styleSheet[typography], styles.title]}>
|
|
162
|
+
{title}
|
|
163
|
+
</RNText>
|
|
164
|
+
</View>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<View style={[styles.wrapper, isSection && styles.margin]}>
|
|
170
|
+
{renderIcon()}
|
|
171
|
+
{renderContent()}
|
|
172
|
+
{renderActionRight()}
|
|
127
173
|
</View>
|
|
128
174
|
);
|
|
129
175
|
};
|
package/Title/styles.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
2
|
import {scaleSize} from '../Text';
|
|
3
|
-
import {Radius, Spacing} from '../Consts';
|
|
3
|
+
import {Colors, Radius, Spacing} from '../Consts';
|
|
4
4
|
|
|
5
5
|
export default StyleSheet.create({
|
|
6
6
|
card_small: {
|
|
@@ -27,10 +27,6 @@ export default StyleSheet.create({
|
|
|
27
27
|
fontSize: scaleSize(24),
|
|
28
28
|
lineHeight: scaleSize(34),
|
|
29
29
|
},
|
|
30
|
-
screen: {
|
|
31
|
-
fontSize: scaleSize(36),
|
|
32
|
-
lineHeight: scaleSize(44),
|
|
33
|
-
},
|
|
34
30
|
actionIcon: {
|
|
35
31
|
borderRadius: Radius.M,
|
|
36
32
|
alignItems: 'center',
|
|
@@ -41,12 +37,40 @@ export default StyleSheet.create({
|
|
|
41
37
|
borderRadius: Radius.XS,
|
|
42
38
|
},
|
|
43
39
|
wrapper: {
|
|
44
|
-
width: '100%',
|
|
45
40
|
flexDirection: 'row',
|
|
46
|
-
alignItems: 'center',
|
|
47
41
|
},
|
|
48
|
-
|
|
42
|
+
margin: {
|
|
43
|
+
marginTop: Spacing.S,
|
|
44
|
+
},
|
|
45
|
+
iconView: {
|
|
49
46
|
marginRight: Spacing.S,
|
|
50
|
-
|
|
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
|
+
marginBottom: Spacing.XS,
|
|
72
|
+
},
|
|
73
|
+
badge: {
|
|
74
|
+
marginLeft: Spacing.XS,
|
|
51
75
|
},
|
|
52
76
|
});
|
package/Title/types.ts
CHANGED
|
@@ -1,52 +1,16 @@
|
|
|
1
1
|
export type TitleProps = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* 'screen' - Used for screen titles.
|
|
5
|
-
* 'section' - Used for section titles within a screen.
|
|
6
|
-
* 'card' - Used for titles within a card component.
|
|
7
|
-
*/
|
|
8
|
-
type?: 'screen' | 'section' | 'card';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Required. The text of the title.
|
|
12
|
-
*/
|
|
2
|
+
type?: 'card' | 'section';
|
|
3
|
+
size?: 'small' | 'medium' | 'large';
|
|
13
4
|
title: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Optional. A description or subtitle that appears below the title.
|
|
17
|
-
*/
|
|
18
|
-
description?: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Optional. Defines the size of the Title component.
|
|
22
|
-
* 'large' - A larger, more prominent title.
|
|
23
|
-
* 'small' - A smaller, less prominent title.
|
|
24
|
-
*/
|
|
25
|
-
size?: 'large' | 'medium' | 'small';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Optional. Represents the name or key of the icon to be displayed alongside the title.
|
|
29
|
-
*/
|
|
30
5
|
icon?: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Optional. Function to be called when the action associated with the title is pressed.
|
|
44
|
-
*/
|
|
45
|
-
onPressAction?: () => void;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Optional. If `true`, an action button or icon is displayed alongside the title.
|
|
49
|
-
*/
|
|
50
|
-
showAction?: boolean;
|
|
51
|
-
usePadding?: boolean;
|
|
6
|
+
description?: string;
|
|
7
|
+
iconColor?: string;
|
|
8
|
+
iconAlign?: 'top' | 'middle' | 'bottom';
|
|
9
|
+
showRightAction?: boolean;
|
|
10
|
+
showTrailingAction?: boolean;
|
|
11
|
+
badgeLabel?: string;
|
|
12
|
+
buttonTitle?: string;
|
|
13
|
+
buttonSize?: 'small' | 'large';
|
|
14
|
+
onPressRightAction?: () => void;
|
|
15
|
+
textOnly?: boolean;
|
|
52
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.2-tracking.2",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"react-native-safe-area-context": "3.1.4",
|
|
15
15
|
"react-native-linear-gradient": "2.8.3",
|
|
16
16
|
"react-native-gesture-handler": "1.10.3",
|
|
17
|
+
"react-native-modalize": "2.1.1",
|
|
17
18
|
"react-native-fast-image": "8.1.5",
|
|
18
19
|
"@react-navigation/bottom-tabs": "git+https://gitlab.com/momo-platform/react-navigation-bottom-tabs.git#main",
|
|
19
20
|
"@react-navigation/core": "5.16.1",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@types/jest": "26.0.23",
|
|
33
34
|
"@types/react-native": "0.64.4",
|
|
34
35
|
"@types/react-test-renderer": "16.9.2",
|
|
36
|
+
"@types/d3-shape": "1.3.7",
|
|
35
37
|
"babel-jest": "^26.6.3",
|
|
36
38
|
"eslint": "^7.14.0",
|
|
37
39
|
"jest": "^26.6.3",
|