@momo-kits/foundation 0.92.1-tracking.22 → 0.92.1-tracking.24
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/NavigationContainer.tsx +2 -1
- package/Application/StackScreen.tsx +6 -4
- package/Application/types.ts +1 -0
- package/Badge/Badge.tsx +1 -1
- package/Consts/colors+spacing+radius.ts +13 -0
- package/Image/index.tsx +2 -2
- package/Input/Input.tsx +22 -7
- package/Input/InputDropDown.tsx +12 -7
- package/Input/InputMoney.tsx +8 -7
- package/Input/InputOTP.tsx +2 -2
- package/Input/InputSearch.tsx +2 -2
- package/Input/InputTextArea.tsx +12 -6
- package/Input/index.tsx +2 -0
- package/Popup/PopupNotify.tsx +2 -0
- package/Radio/index.tsx +2 -2
- package/Switch/index.tsx +2 -2
- package/Title/index.tsx +119 -102
- package/Title/styles.ts +26 -6
- package/Title/types.ts +11 -48
- package/package.json +1 -1
|
@@ -32,6 +32,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
32
32
|
options,
|
|
33
33
|
maxApi,
|
|
34
34
|
localization,
|
|
35
|
+
initialParams,
|
|
35
36
|
}) => {
|
|
36
37
|
const context = useContext<any>(MiniAppContext);
|
|
37
38
|
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
@@ -106,7 +107,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
106
107
|
<Stack.Screen
|
|
107
108
|
name="Stack"
|
|
108
109
|
component={StackScreen}
|
|
109
|
-
initialParams={{screen}}
|
|
110
|
+
initialParams={{screen, initialParams}}
|
|
110
111
|
options={{...getStackOptions(), ...options}}
|
|
111
112
|
/>
|
|
112
113
|
<Stack.Screen
|
|
@@ -20,16 +20,18 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
20
20
|
|
|
21
21
|
const context = useContext<any>(MiniAppContext);
|
|
22
22
|
|
|
23
|
-
const {screen: Component, options} = props.route.params;
|
|
23
|
+
const {screen: Component, options, initialParams} = props.route.params;
|
|
24
24
|
const navigation = new Navigation(props.navigation, theme);
|
|
25
25
|
const heightHeader = useHeaderHeight();
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const data = {
|
|
28
28
|
...props.route.params,
|
|
29
|
+
...initialParams,
|
|
29
30
|
navigation,
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
delete
|
|
33
|
+
delete data.screen;
|
|
34
|
+
delete data.initialParams;
|
|
33
35
|
|
|
34
36
|
const screenName = Component?.name || Component?.type?.name || '';
|
|
35
37
|
|
|
@@ -129,7 +131,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
129
131
|
}}>
|
|
130
132
|
<Component
|
|
131
133
|
heightHeader={heightHeader}
|
|
132
|
-
{...
|
|
134
|
+
{...data}
|
|
133
135
|
onScreenLoad={() => {}}
|
|
134
136
|
/>
|
|
135
137
|
{showGrid && <GridSystem />}
|
package/Application/types.ts
CHANGED
package/Badge/Badge.tsx
CHANGED
|
@@ -46,7 +46,7 @@ const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<View style={[style, styles.badge, {backgroundColor: badgeColor}]}>
|
|
49
|
-
<Text color={Colors.black_01} typography={'
|
|
49
|
+
<Text color={Colors.black_01} typography={'action_xxs_bold'}>
|
|
50
50
|
{formatTitle()}
|
|
51
51
|
</Text>
|
|
52
52
|
</View>
|
|
@@ -213,6 +213,19 @@ const Shadow = {
|
|
|
213
213
|
elevation: 6,
|
|
214
214
|
},
|
|
215
215
|
}),
|
|
216
|
+
|
|
217
|
+
Pink: Platform.select({
|
|
218
|
+
ios: {
|
|
219
|
+
shadowColor: 'rgba(224, 128, 181, 0.25)',
|
|
220
|
+
shadowOffset: { width: 0, height: 6 },
|
|
221
|
+
shadowOpacity: 1,
|
|
222
|
+
shadowRadius: 8,
|
|
223
|
+
},
|
|
224
|
+
android: {
|
|
225
|
+
elevation: 16,
|
|
226
|
+
shadowColor: 'rgba(224, 128, 181, 0.25)',
|
|
227
|
+
},
|
|
228
|
+
}),
|
|
216
229
|
};
|
|
217
230
|
|
|
218
231
|
export {Colors, Spacing, Radius, Shadow};
|
package/Image/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {useContext, useRef, useState} from 'react';
|
|
2
2
|
import {StyleSheet, View} from 'react-native';
|
|
3
|
-
import FastImage from 'react-native-fast-image';
|
|
3
|
+
import FastImage, {Source} from 'react-native-fast-image';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
6
|
import {Skeleton} from '../Skeleton';
|
|
@@ -45,7 +45,7 @@ const Image: React.FC<ImageProps> = ({
|
|
|
45
45
|
return (
|
|
46
46
|
<FastImage
|
|
47
47
|
{...rest}
|
|
48
|
-
{...getAccessibilityID(`img|${source}`)}
|
|
48
|
+
{...getAccessibilityID(`img|${(source as Source).uri}`)}
|
|
49
49
|
source={source}
|
|
50
50
|
style={[styles.container, style]}
|
|
51
51
|
onProgress={() => {
|
package/Input/Input.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, {forwardRef, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
NativeSyntheticEvent,
|
|
4
|
+
Platform,
|
|
4
5
|
TextInput,
|
|
5
6
|
TextInputFocusEventData,
|
|
6
7
|
TouchableOpacity,
|
|
@@ -44,6 +45,7 @@ const Input = forwardRef(
|
|
|
44
45
|
fontWeight = 'Regular',
|
|
45
46
|
onPressIcon,
|
|
46
47
|
secureTextEntry,
|
|
48
|
+
keyboardType,
|
|
47
49
|
style,
|
|
48
50
|
params,
|
|
49
51
|
componentId,
|
|
@@ -52,7 +54,7 @@ const Input = forwardRef(
|
|
|
52
54
|
ref,
|
|
53
55
|
) => {
|
|
54
56
|
const {theme} = useContext(ApplicationContext);
|
|
55
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
57
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
56
58
|
const [focused, setFocused] = useState(false);
|
|
57
59
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
58
60
|
const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
|
|
@@ -116,6 +118,17 @@ const Input = forwardRef(
|
|
|
116
118
|
let textColor = theme.colors.text.default;
|
|
117
119
|
let placeholderColor = theme.colors.text.hint;
|
|
118
120
|
let iconTintColor = iconColor;
|
|
121
|
+
const accessibilityID = disabled
|
|
122
|
+
? getAccessibilityID(
|
|
123
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${
|
|
124
|
+
floatingValue ?? placeholder
|
|
125
|
+
}_disabled`,
|
|
126
|
+
)
|
|
127
|
+
: getAccessibilityID(
|
|
128
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${
|
|
129
|
+
floatingValue ?? placeholder
|
|
130
|
+
}`,
|
|
131
|
+
);
|
|
119
132
|
|
|
120
133
|
if (disabled) {
|
|
121
134
|
textColor = disabledColor;
|
|
@@ -123,11 +136,12 @@ const Input = forwardRef(
|
|
|
123
136
|
iconTintColor = disabledColor;
|
|
124
137
|
}
|
|
125
138
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
if (secureTextEntry) {
|
|
140
|
+
keyboardType = Platform.select({
|
|
141
|
+
ios: 'ascii-capable',
|
|
142
|
+
android: 'visible-password',
|
|
143
|
+
});
|
|
144
|
+
}
|
|
131
145
|
|
|
132
146
|
return (
|
|
133
147
|
<View
|
|
@@ -157,7 +171,7 @@ const Input = forwardRef(
|
|
|
157
171
|
<TextInput
|
|
158
172
|
{...props}
|
|
159
173
|
{...accessibilityID}
|
|
160
|
-
editable={!disabled}
|
|
174
|
+
editable={props.editable && !disabled}
|
|
161
175
|
secureTextEntry={secure}
|
|
162
176
|
textAlignVertical="center"
|
|
163
177
|
ref={inputRef}
|
|
@@ -177,6 +191,7 @@ const Input = forwardRef(
|
|
|
177
191
|
placeholder={placeholder}
|
|
178
192
|
selectionColor={theme.colors.primary}
|
|
179
193
|
placeholderTextColor={placeholderColor}
|
|
194
|
+
keyboardType={keyboardType}
|
|
180
195
|
/>
|
|
181
196
|
</View>
|
|
182
197
|
<View style={styles.iconView}>
|
package/Input/InputDropDown.tsx
CHANGED
|
@@ -36,7 +36,7 @@ const InputDropDown = ({
|
|
|
36
36
|
componentId,
|
|
37
37
|
...props
|
|
38
38
|
}: InputDropDownProps) => {
|
|
39
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
39
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
40
40
|
const {theme} = useContext(ApplicationContext);
|
|
41
41
|
const full = !!value || !!placeholder;
|
|
42
42
|
const screenInfo = useContext<any>(ScreenContext);
|
|
@@ -55,6 +55,17 @@ const InputDropDown = ({
|
|
|
55
55
|
let textColor = theme.colors.text.default;
|
|
56
56
|
let placeholderColor = theme.colors.text.hint;
|
|
57
57
|
let iconTintColor = iconColor;
|
|
58
|
+
const accessibilityID = disabled
|
|
59
|
+
? getAccessibilityID(
|
|
60
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${
|
|
61
|
+
floatingValue ?? placeholder
|
|
62
|
+
}_disabled`,
|
|
63
|
+
)
|
|
64
|
+
: getAccessibilityID(
|
|
65
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${
|
|
66
|
+
floatingValue ?? placeholder
|
|
67
|
+
}`,
|
|
68
|
+
);
|
|
58
69
|
|
|
59
70
|
if (disabled) {
|
|
60
71
|
textColor = disabledColor;
|
|
@@ -62,12 +73,6 @@ const InputDropDown = ({
|
|
|
62
73
|
iconTintColor = disabledColor;
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
const accessibilityID = getAccessibilityID(
|
|
66
|
-
`${appId}/${screenInfo.screenName}/input_${floatingValue}${
|
|
67
|
-
disabled && '_disabled'
|
|
68
|
-
}`,
|
|
69
|
-
);
|
|
70
|
-
|
|
71
76
|
return (
|
|
72
77
|
<View
|
|
73
78
|
style={[
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -50,7 +50,7 @@ const InputMoney = forwardRef(
|
|
|
50
50
|
ref,
|
|
51
51
|
) => {
|
|
52
52
|
const {theme} = useContext(ApplicationContext);
|
|
53
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
53
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
54
54
|
const [focused, setFocused] = useState(false);
|
|
55
55
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
56
56
|
const screenInfo = useContext<any>(ScreenContext);
|
|
@@ -99,6 +99,13 @@ const InputMoney = forwardRef(
|
|
|
99
99
|
let textColor = theme.colors.text.default;
|
|
100
100
|
let placeholderColor = theme.colors.text.hint;
|
|
101
101
|
let iconTintColor = iconColor;
|
|
102
|
+
const accessibilityID = disabled
|
|
103
|
+
? getAccessibilityID(
|
|
104
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${floatingValue}_disabled`,
|
|
105
|
+
)
|
|
106
|
+
: getAccessibilityID(
|
|
107
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${floatingValue}`,
|
|
108
|
+
);
|
|
102
109
|
|
|
103
110
|
if (disabled) {
|
|
104
111
|
textColor = disabledColor;
|
|
@@ -106,12 +113,6 @@ const InputMoney = forwardRef(
|
|
|
106
113
|
iconTintColor = disabledColor;
|
|
107
114
|
}
|
|
108
115
|
|
|
109
|
-
const accessibilityID = getAccessibilityID(
|
|
110
|
-
`${appId}/${screenInfo.screenName}/input_${floatingValue}${
|
|
111
|
-
disabled && '_disabled'
|
|
112
|
-
}`,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
116
|
return (
|
|
116
117
|
<View
|
|
117
118
|
style={[
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -92,7 +92,7 @@ const InputOTP = forwardRef(
|
|
|
92
92
|
ref,
|
|
93
93
|
) => {
|
|
94
94
|
const MAX_LENGTH = 10;
|
|
95
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
95
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
96
96
|
|
|
97
97
|
const [value, setValue] = useState('');
|
|
98
98
|
const [focused, setFocused] = useState(false);
|
|
@@ -192,7 +192,7 @@ const InputOTP = forwardRef(
|
|
|
192
192
|
};
|
|
193
193
|
|
|
194
194
|
const accessibilityID = getAccessibilityID(
|
|
195
|
-
`${appId}/${screenInfo.screenName}/input_${floatingValue}`,
|
|
195
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${floatingValue}`,
|
|
196
196
|
);
|
|
197
197
|
|
|
198
198
|
const renderInputView = () => {
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -42,7 +42,7 @@ const InputSearch = forwardRef(
|
|
|
42
42
|
ref,
|
|
43
43
|
) => {
|
|
44
44
|
const {theme} = useContext(ApplicationContext);
|
|
45
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
45
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
46
46
|
const [focused, setFocused] = useState(false);
|
|
47
47
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
48
48
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
@@ -73,7 +73,7 @@ const InputSearch = forwardRef(
|
|
|
73
73
|
<TextInput
|
|
74
74
|
{...props}
|
|
75
75
|
{...getAccessibilityID(
|
|
76
|
-
`${appId}/${screenInfo.screenName}/input_search`,
|
|
76
|
+
`${appId}/${code}/${screenInfo.screenName}/input_search`,
|
|
77
77
|
)}
|
|
78
78
|
textAlignVertical="center"
|
|
79
79
|
ref={inputRef}
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -50,7 +50,7 @@ const InputTextArea = forwardRef(
|
|
|
50
50
|
) => {
|
|
51
51
|
const {theme} = useContext(ApplicationContext);
|
|
52
52
|
const screenInfo = useContext<any>(ScreenContext);
|
|
53
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
53
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
54
54
|
const [focused, setFocused] = useState(false);
|
|
55
55
|
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
56
56
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
@@ -96,11 +96,17 @@ const InputTextArea = forwardRef(
|
|
|
96
96
|
placeholderColor = disabledColor;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
const accessibilityID =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
const accessibilityID = disabled
|
|
100
|
+
? getAccessibilityID(
|
|
101
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${
|
|
102
|
+
floatingValue ?? placeholder
|
|
103
|
+
}_disabled`,
|
|
104
|
+
)
|
|
105
|
+
: getAccessibilityID(
|
|
106
|
+
`${appId}/${code}/${screenInfo.screenName}/input_${
|
|
107
|
+
floatingValue ?? placeholder
|
|
108
|
+
}`,
|
|
109
|
+
);
|
|
104
110
|
|
|
105
111
|
return (
|
|
106
112
|
<View
|
package/Input/index.tsx
CHANGED
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -94,6 +94,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
94
94
|
closeAction.current = 'button_action';
|
|
95
95
|
onAction(secondary?.onPress);
|
|
96
96
|
}}
|
|
97
|
+
accessibilityLabel={'btn_popup_cancel'}
|
|
97
98
|
/>
|
|
98
99
|
</View>
|
|
99
100
|
<View style={styles.buttonSpace} />
|
|
@@ -107,6 +108,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
107
108
|
closeAction.current = 'button_action';
|
|
108
109
|
onAction(primary.onPress);
|
|
109
110
|
}}
|
|
111
|
+
accessibilityLabel={'btn_popup_allow'}
|
|
110
112
|
/>
|
|
111
113
|
</View>
|
|
112
114
|
</View>
|
package/Radio/index.tsx
CHANGED
|
@@ -23,7 +23,7 @@ const Radio: FC<RadioProps> = ({
|
|
|
23
23
|
params,
|
|
24
24
|
componentId,
|
|
25
25
|
}) => {
|
|
26
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
26
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
27
27
|
const {theme} = useContext(ApplicationContext);
|
|
28
28
|
const screenInfo = useContext<any>(ScreenContext);
|
|
29
29
|
const selected = value === groupValue;
|
|
@@ -48,7 +48,7 @@ const Radio: FC<RadioProps> = ({
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const accessibilityID = getAccessibilityID?.(
|
|
51
|
-
`${appId}/${screenInfo.screenName}/rdo_${label}_${value}`,
|
|
51
|
+
`${appId}/${code}/${screenInfo.screenName}/rdo_${label}_${value}`,
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
return (
|
package/Switch/index.tsx
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
} = require('react-native/Libraries/Components/ScreenContext');
|
|
12
12
|
|
|
13
13
|
const Switch: FC<SwitchProps> = props => {
|
|
14
|
-
const {appId} = useContext<any>(MiniAppContext);
|
|
14
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
15
15
|
const {value, onChange, disabled, style, params, componentId} = props;
|
|
16
16
|
const screenInfo = useContext<any>(ScreenContext);
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ const Switch: FC<SwitchProps> = props => {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const accessibilityID = getAccessibilityID?.(
|
|
27
|
-
`${appId}/${screenInfo.screenName}/swt_${value}`,
|
|
27
|
+
`${appId}/${code}/${screenInfo.screenName}/swt_${value}`,
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
return (
|
package/Title/index.tsx
CHANGED
|
@@ -1,129 +1,146 @@
|
|
|
1
|
-
import React, {FC, useContext
|
|
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';
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {Text as RNText, TouchableOpacity, View, ViewStyle} from 'react-native';
|
|
12
3
|
import styles from './styles';
|
|
4
|
+
import {Icon} from '../Icon';
|
|
5
|
+
import {scaleSize, Text} from '../Text';
|
|
13
6
|
import {ApplicationContext} from '../Application';
|
|
14
7
|
import {Colors, Spacing} from '../Consts';
|
|
15
|
-
import {
|
|
8
|
+
import {Badge} from '../Badge';
|
|
9
|
+
import {Typography} from '../Text/types';
|
|
10
|
+
import {TitleProps} from './types';
|
|
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
|
+
showLeftAction = false,
|
|
22
|
+
badgeLabel,
|
|
23
|
+
buttonTitle,
|
|
24
|
+
onPressRightAction = () => {},
|
|
25
|
+
buttonSize = 'small',
|
|
28
26
|
}) => {
|
|
29
27
|
const {theme} = useContext(ApplicationContext);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
const styleSheet: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
} = styles;
|
|
31
|
+
const typography = `${type}_${size}`;
|
|
32
|
+
const isSection = type === 'section';
|
|
33
|
+
const numberOfLines = showLeftAction || !!badgeLabel ? 1 : 2;
|
|
34
|
+
const buttonTypo: Typography =
|
|
35
|
+
buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
|
|
36
|
+
const widthStyle =
|
|
37
|
+
!showLeftAction && !showRightAction && !badgeLabel
|
|
38
|
+
? {width: '100%'}
|
|
39
|
+
: {width: '75%'};
|
|
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
|
-
style={[
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
<View style={{flex: 1}}>
|
|
66
|
+
<View style={[styles.iconLeftView, widthStyle]}>
|
|
67
|
+
<RNText
|
|
68
|
+
numberOfLines={numberOfLines}
|
|
69
|
+
style={[
|
|
70
|
+
styleSheet[typography],
|
|
71
|
+
{
|
|
72
|
+
fontWeight: 'bold',
|
|
73
|
+
marginBottom: Spacing.XS,
|
|
74
|
+
},
|
|
75
|
+
]}>
|
|
76
|
+
{title}
|
|
77
|
+
</RNText>
|
|
78
|
+
<View style={{alignItems: 'center'}}>
|
|
79
|
+
{badgeLabel && (
|
|
80
|
+
<Badge style={{marginLeft: Spacing.XS}} label={badgeLabel} />
|
|
81
|
+
)}
|
|
82
|
+
</View>
|
|
83
|
+
{renderActionLeft()}
|
|
84
|
+
</View>
|
|
85
|
+
<Text
|
|
86
|
+
color={theme.colors.text.secondary}
|
|
87
|
+
typography={'description_default_regular'}>
|
|
88
|
+
{description}
|
|
89
|
+
</Text>
|
|
90
|
+
</View>
|
|
79
91
|
);
|
|
80
92
|
};
|
|
81
|
-
const onLayout = (e: LayoutChangeEvent) => {
|
|
82
|
-
setContainerWidth(e.nativeEvent.layout.width);
|
|
83
|
-
};
|
|
84
93
|
|
|
85
|
-
const
|
|
86
|
-
|
|
94
|
+
const renderActionLeft = () => {
|
|
95
|
+
return (
|
|
96
|
+
<View style={styles.iconLeftView}>
|
|
97
|
+
{showLeftAction && !showRightAction && (
|
|
98
|
+
<View style={[styles.iconLeft, {backgroundColor: Colors.black_06}]}>
|
|
99
|
+
<Icon
|
|
100
|
+
source={'arrow_chevron_right_small'}
|
|
101
|
+
size={scaleSize(18)}
|
|
102
|
+
color={theme.colors.text.default}
|
|
103
|
+
/>
|
|
104
|
+
</View>
|
|
105
|
+
)}
|
|
106
|
+
</View>
|
|
107
|
+
);
|
|
87
108
|
};
|
|
88
109
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<View style={styles.textContent}>
|
|
110
|
+
const renderActionRight = () => {
|
|
111
|
+
if (!showRightAction || showLeftAction) return false;
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<View>
|
|
115
|
+
{!buttonTitle ? (
|
|
96
116
|
<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()}
|
|
117
|
+
style={[
|
|
118
|
+
styles.iconRight,
|
|
119
|
+
{
|
|
120
|
+
backgroundColor: theme.colors.primary + '0F',
|
|
121
|
+
},
|
|
122
|
+
]}>
|
|
123
|
+
<Icon
|
|
124
|
+
source={'arrow_chevron_right_small'}
|
|
125
|
+
size={scaleSize(22)}
|
|
126
|
+
color={theme.colors.primary}
|
|
127
|
+
/>
|
|
115
128
|
</View>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
color={theme.colors.text.secondary}>
|
|
121
|
-
{description}
|
|
129
|
+
) : (
|
|
130
|
+
<TouchableOpacity onPress={onPressRightAction}>
|
|
131
|
+
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
132
|
+
{buttonTitle}
|
|
122
133
|
</Text>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{showAction && titleFlex && type !== 'screen' && renderAction()}
|
|
134
|
+
</TouchableOpacity>
|
|
135
|
+
)}
|
|
126
136
|
</View>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
return (
|
|
140
|
+
<View style={[styles.wrapper, isSection && styles.margin]}>
|
|
141
|
+
{renderIcon()}
|
|
142
|
+
{renderContent()}
|
|
143
|
+
{renderActionRight()}
|
|
127
144
|
</View>
|
|
128
145
|
);
|
|
129
146
|
};
|
package/Title/styles.ts
CHANGED
|
@@ -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,36 @@ 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
|
textContent: {
|
|
49
43
|
marginRight: Spacing.S,
|
|
50
44
|
flex: 1,
|
|
51
45
|
},
|
|
46
|
+
margin: {
|
|
47
|
+
marginTop: Spacing.S,
|
|
48
|
+
},
|
|
49
|
+
iconView: {
|
|
50
|
+
marginRight: Spacing.S,
|
|
51
|
+
},
|
|
52
|
+
iconRight: {
|
|
53
|
+
width: scaleSize(22),
|
|
54
|
+
height: scaleSize(22),
|
|
55
|
+
borderRadius: Radius.M,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
marginLeft: Spacing.S,
|
|
59
|
+
},
|
|
60
|
+
iconLeft: {
|
|
61
|
+
width: scaleSize(18),
|
|
62
|
+
height: scaleSize(18),
|
|
63
|
+
borderRadius: Radius.M,
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
marginHorizontal: Spacing.XS,
|
|
67
|
+
},
|
|
68
|
+
iconLeftView: {
|
|
69
|
+
flexDirection: 'row',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
},
|
|
52
72
|
});
|
package/Title/types.ts
CHANGED
|
@@ -1,52 +1,15 @@
|
|
|
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
|
-
actionTitle?: string;
|
|
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
|
+
showLeftAction?: boolean;
|
|
11
|
+
badgeLabel?: string;
|
|
12
|
+
buttonTitle?: string;
|
|
13
|
+
buttonSize?: 'small' | 'large';
|
|
14
|
+
onPressRightAction?: () => void;
|
|
52
15
|
};
|