@momo-kits/foundation 0.81.43 → 0.81.49
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.tsx +29 -12
- package/Application/Components.tsx +178 -174
- package/Application/ModalScreen.tsx +4 -17
- package/Application/NavigationContainer.tsx +9 -30
- package/Application/Navigator.ts +14 -9
- package/Application/StackScreen.tsx +25 -28
- package/Application/index.ts +10 -1
- package/Application/types.ts +30 -17
- package/Application/utils.tsx +14 -0
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Badge/Badge.tsx +1 -1
- package/Badge/BadgeRibbon.tsx +2 -2
- package/Badge/styles.ts +5 -2
- package/Button/index.tsx +4 -5
- package/CheckBox/index.tsx +1 -2
- package/Icon/index.tsx +7 -2
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +0 -1
- package/Input/Input.tsx +26 -7
- package/Input/InputDropDown.tsx +1 -6
- package/Input/InputMoney.tsx +14 -6
- package/Input/InputOTP.tsx +12 -9
- package/Input/InputSearch.tsx +8 -12
- package/Input/InputTextArea.tsx +4 -6
- package/Input/common.tsx +5 -3
- package/Input/index.tsx +2 -6
- package/Input/styles.ts +1 -3
- package/Layout/Card.tsx +8 -9
- package/Layout/Item.tsx +0 -1
- package/Layout/ItemList.tsx +39 -33
- package/Layout/Screen.tsx +1 -3
- package/Layout/Section.tsx +4 -4
- package/Pagination/PaginationNumber.tsx +1 -1
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Popup/PopupNotify.tsx +28 -32
- package/Popup/PopupPromotion.tsx +24 -28
- package/Radio/index.tsx +1 -2
- package/Skeleton/index.tsx +1 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +2 -2
- package/Text/styles.ts +38 -0
- package/Text/types.ts +18 -24
- package/Title/index.tsx +2 -2
- package/package.json +2 -2
- package/publish.sh +1 -1
- package/verify.js +37 -39
package/Input/Input.tsx
CHANGED
|
@@ -37,6 +37,7 @@ const Input = forwardRef(
|
|
|
37
37
|
leadingIconColor,
|
|
38
38
|
fontWeight = 'Regular',
|
|
39
39
|
onPressIcon,
|
|
40
|
+
secureTextEntry,
|
|
40
41
|
style,
|
|
41
42
|
...props
|
|
42
43
|
}: InputProps,
|
|
@@ -45,8 +46,8 @@ const Input = forwardRef(
|
|
|
45
46
|
const {theme} = useContext(ApplicationContext);
|
|
46
47
|
const [focused, setFocused] = useState(false);
|
|
47
48
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
49
|
+
const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
|
|
48
50
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
49
|
-
const accessibilityLabel = `Input/${floatingValue ?? placeholder}`;
|
|
50
51
|
|
|
51
52
|
const onClearText = () => {
|
|
52
53
|
inputRef?.current?.clear();
|
|
@@ -70,11 +71,29 @@ const Input = forwardRef(
|
|
|
70
71
|
|
|
71
72
|
const renderIcon = (color: string | undefined) => {
|
|
72
73
|
if (loading) {
|
|
73
|
-
return <Loader type={'spinner'} color={color} />;
|
|
74
|
+
return <Loader type={'spinner'} color={color} style={styles.icon} />;
|
|
75
|
+
}
|
|
76
|
+
if (secureTextEntry) {
|
|
77
|
+
return (
|
|
78
|
+
<TouchableOpacity
|
|
79
|
+
onPress={() => setSecureTextInput(!secureTextInput)}
|
|
80
|
+
style={styles.icon}>
|
|
81
|
+
<Icon
|
|
82
|
+
color={color}
|
|
83
|
+
size={24}
|
|
84
|
+
source={
|
|
85
|
+
secureTextInput ? '24_security_eye_off' : '24_security_eye_open'
|
|
86
|
+
}
|
|
87
|
+
/>
|
|
88
|
+
</TouchableOpacity>
|
|
89
|
+
);
|
|
74
90
|
}
|
|
75
91
|
if (icon) {
|
|
76
92
|
return (
|
|
77
|
-
<TouchableOpacity
|
|
93
|
+
<TouchableOpacity
|
|
94
|
+
onPress={onPressIcon}
|
|
95
|
+
disabled={!onPressIcon}
|
|
96
|
+
style={styles.icon}>
|
|
78
97
|
<Icon color={color} source={icon} size={24} />
|
|
79
98
|
</TouchableOpacity>
|
|
80
99
|
);
|
|
@@ -83,6 +102,7 @@ const Input = forwardRef(
|
|
|
83
102
|
|
|
84
103
|
const renderInputView = () => {
|
|
85
104
|
const disabledColor = theme.colors.text.disable;
|
|
105
|
+
const secure = secureTextInput && secureTextEntry;
|
|
86
106
|
let textColor = theme.colors.text.default;
|
|
87
107
|
let placeholderColor = theme.colors.text.hint;
|
|
88
108
|
let iconTintColor = iconColor;
|
|
@@ -120,8 +140,8 @@ const Input = forwardRef(
|
|
|
120
140
|
)}
|
|
121
141
|
<TextInput
|
|
122
142
|
{...props}
|
|
123
|
-
accessibilityLabel={accessibilityLabel}
|
|
124
143
|
editable={!disabled}
|
|
144
|
+
secureTextEntry={secure}
|
|
125
145
|
textAlignVertical="center"
|
|
126
146
|
ref={inputRef}
|
|
127
147
|
style={[
|
|
@@ -130,6 +150,7 @@ const Input = forwardRef(
|
|
|
130
150
|
color: textColor,
|
|
131
151
|
fontFamily: `${theme.font}-${fontWeight}`,
|
|
132
152
|
},
|
|
153
|
+
secure && haveValue && {fontSize: size === 'small' ? 18 : 22},
|
|
133
154
|
]}
|
|
134
155
|
textBreakStrategy="highQuality"
|
|
135
156
|
value={value}
|
|
@@ -160,9 +181,7 @@ const Input = forwardRef(
|
|
|
160
181
|
};
|
|
161
182
|
|
|
162
183
|
return (
|
|
163
|
-
<View
|
|
164
|
-
style={[style, styles.wrapper]}
|
|
165
|
-
accessibilityLabel={accessibilityLabel}>
|
|
184
|
+
<View style={[style, styles.wrapper]}>
|
|
166
185
|
{renderInputView()}
|
|
167
186
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
168
187
|
</View>
|
package/Input/InputDropDown.tsx
CHANGED
|
@@ -30,7 +30,6 @@ const InputDropDown = ({
|
|
|
30
30
|
}: InputDropDownProps) => {
|
|
31
31
|
const {theme} = useContext(ApplicationContext);
|
|
32
32
|
const full = !!value || !!placeholder;
|
|
33
|
-
const accessibilityLabel = `InputDropDown/${floatingValue ?? placeholder}`;
|
|
34
33
|
|
|
35
34
|
const renderIcon = (color: string | undefined) => {
|
|
36
35
|
if (loading) {
|
|
@@ -82,7 +81,6 @@ const InputDropDown = ({
|
|
|
82
81
|
<TextInput
|
|
83
82
|
{...props}
|
|
84
83
|
onPressIn={onPress}
|
|
85
|
-
accessibilityLabel={accessibilityLabel}
|
|
86
84
|
editable={false}
|
|
87
85
|
textAlignVertical="top"
|
|
88
86
|
style={[
|
|
@@ -106,10 +104,7 @@ const InputDropDown = ({
|
|
|
106
104
|
};
|
|
107
105
|
|
|
108
106
|
return (
|
|
109
|
-
<TouchableOpacity
|
|
110
|
-
onPress={onPress}
|
|
111
|
-
style={[style, full && styles.wrapper]}
|
|
112
|
-
accessibilityLabel={accessibilityLabel}>
|
|
107
|
+
<TouchableOpacity onPress={onPress} style={[style, full && styles.wrapper]}>
|
|
113
108
|
{renderInputView()}
|
|
114
109
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
115
110
|
</TouchableOpacity>
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useContext,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import {
|
|
3
9
|
NativeSyntheticEvent,
|
|
4
10
|
TextInput,
|
|
@@ -38,7 +44,6 @@ const InputMoney = forwardRef(
|
|
|
38
44
|
const {theme} = useContext(ApplicationContext);
|
|
39
45
|
const [focused, setFocused] = useState(false);
|
|
40
46
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
41
|
-
const accessibilityLabel = `InputMoney/${floatingValue}`;
|
|
42
47
|
|
|
43
48
|
const validateText = (text: string) => {
|
|
44
49
|
const valueFormat = formatMoneyToNumber(text, 'đ');
|
|
@@ -63,6 +68,12 @@ const InputMoney = forwardRef(
|
|
|
63
68
|
onChangeText?.(formatMoneyToNumber(text, 'đ').toString());
|
|
64
69
|
};
|
|
65
70
|
|
|
71
|
+
useImperativeHandle(ref, () => {
|
|
72
|
+
return {
|
|
73
|
+
setText: _onChangeText,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
66
77
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
67
78
|
setFocused(true);
|
|
68
79
|
onFocus?.(e);
|
|
@@ -103,7 +114,6 @@ const InputMoney = forwardRef(
|
|
|
103
114
|
<View style={styles.inputView}>
|
|
104
115
|
<TextInput
|
|
105
116
|
{...props}
|
|
106
|
-
accessibilityLabel={accessibilityLabel}
|
|
107
117
|
editable={!disabled}
|
|
108
118
|
textAlignVertical="top"
|
|
109
119
|
ref={inputRef}
|
|
@@ -142,9 +152,7 @@ const InputMoney = forwardRef(
|
|
|
142
152
|
};
|
|
143
153
|
|
|
144
154
|
return (
|
|
145
|
-
<View
|
|
146
|
-
style={[style, styles.wrapper]}
|
|
147
|
-
accessibilityLabel={accessibilityLabel}>
|
|
155
|
+
<View style={[style, styles.wrapper]}>
|
|
148
156
|
{renderInputView()}
|
|
149
157
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
150
158
|
</View>
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -57,7 +57,7 @@ const OTPCaret: FC<CaretProps> = ({index, length}) => {
|
|
|
57
57
|
opacity,
|
|
58
58
|
}}
|
|
59
59
|
/>
|
|
60
|
-
<Text color={theme.colors.text.hint} typography={'
|
|
60
|
+
<Text color={theme.colors.text.hint} typography={'body_default_regular'}>
|
|
61
61
|
-
|
|
62
62
|
</Text>
|
|
63
63
|
</View>
|
|
@@ -88,7 +88,6 @@ const InputOTP = forwardRef(
|
|
|
88
88
|
const [focused, setFocused] = useState(false);
|
|
89
89
|
const inputRef = useRef<TextInput>(null);
|
|
90
90
|
const {theme} = useContext(ApplicationContext);
|
|
91
|
-
const accessibilityLabel = `InputOTP/${floatingValue ?? placeholder}`;
|
|
92
91
|
|
|
93
92
|
useImperativeHandle(ref, () => ({
|
|
94
93
|
onChangeText: (text: string) => {
|
|
@@ -135,7 +134,9 @@ const InputOTP = forwardRef(
|
|
|
135
134
|
? theme.colors.text.default
|
|
136
135
|
: theme.colors.text.hint
|
|
137
136
|
}
|
|
138
|
-
typography={
|
|
137
|
+
typography={
|
|
138
|
+
!!value[i] ? 'header_m_bold' : 'body_default_regular'
|
|
139
|
+
}>
|
|
139
140
|
{value[i] || '-'}
|
|
140
141
|
</Text>
|
|
141
142
|
)}
|
|
@@ -150,7 +151,9 @@ const InputOTP = forwardRef(
|
|
|
150
151
|
|
|
151
152
|
if (!focused && value.length === 0 && !!placeholder) {
|
|
152
153
|
return (
|
|
153
|
-
<Text
|
|
154
|
+
<Text
|
|
155
|
+
color={theme.colors.text.hint}
|
|
156
|
+
typography={'description_default_regular'}>
|
|
154
157
|
{placeholder}
|
|
155
158
|
</Text>
|
|
156
159
|
);
|
|
@@ -167,7 +170,7 @@ const InputOTP = forwardRef(
|
|
|
167
170
|
marginRight: Spacing.L,
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
|
-
typography={'
|
|
173
|
+
typography={'header_m_bold'}>
|
|
171
174
|
{letter}
|
|
172
175
|
</Text>
|
|
173
176
|
);
|
|
@@ -191,7 +194,9 @@ const InputOTP = forwardRef(
|
|
|
191
194
|
styles.otpFloatingView,
|
|
192
195
|
{backgroundColor: theme.colors.background.surface},
|
|
193
196
|
]}>
|
|
194
|
-
<Text typography={'
|
|
197
|
+
<Text typography={'description_default_regular'}>
|
|
198
|
+
{floatingValue}
|
|
199
|
+
</Text>
|
|
195
200
|
</View>
|
|
196
201
|
)}
|
|
197
202
|
<View style={styles.otpInputsView}>
|
|
@@ -200,7 +205,6 @@ const InputOTP = forwardRef(
|
|
|
200
205
|
<View style={styles.inputView}>
|
|
201
206
|
<TextInput
|
|
202
207
|
{...props}
|
|
203
|
-
accessibilityLabel={accessibilityLabel}
|
|
204
208
|
ref={inputRef}
|
|
205
209
|
value={value}
|
|
206
210
|
onChangeText={_onChangeText}
|
|
@@ -220,8 +224,7 @@ const InputOTP = forwardRef(
|
|
|
220
224
|
<TouchableOpacity
|
|
221
225
|
activeOpacity={1}
|
|
222
226
|
onPress={onFocusInput}
|
|
223
|
-
style={[style, styles.otpWrapper]}
|
|
224
|
-
accessibilityLabel={accessibilityLabel}>
|
|
227
|
+
style={[style, styles.otpWrapper]}>
|
|
225
228
|
{renderInputView()}
|
|
226
229
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
227
230
|
</TouchableOpacity>
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -25,10 +25,10 @@ const InputSearch = forwardRef(
|
|
|
25
25
|
icon,
|
|
26
26
|
buttonText = 'Hủy',
|
|
27
27
|
showButtonText = true,
|
|
28
|
-
showBorder = true,
|
|
29
28
|
style,
|
|
30
29
|
defaultValue,
|
|
31
30
|
onPressButtonText,
|
|
31
|
+
hasColorBG = true,
|
|
32
32
|
...props
|
|
33
33
|
}: InputSearchProps,
|
|
34
34
|
ref,
|
|
@@ -37,7 +37,6 @@ const InputSearch = forwardRef(
|
|
|
37
37
|
const [focused, setFocused] = useState(false);
|
|
38
38
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
39
39
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
40
|
-
const accessibilityLabel = `InputMoney/${placeholder}`;
|
|
41
40
|
|
|
42
41
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
43
42
|
setFocused(true);
|
|
@@ -63,7 +62,6 @@ const InputSearch = forwardRef(
|
|
|
63
62
|
return (
|
|
64
63
|
<TextInput
|
|
65
64
|
{...props}
|
|
66
|
-
accessibilityLabel={accessibilityLabel}
|
|
67
65
|
textAlignVertical="center"
|
|
68
66
|
ref={inputRef}
|
|
69
67
|
style={[
|
|
@@ -118,19 +116,17 @@ const InputSearch = forwardRef(
|
|
|
118
116
|
</View>
|
|
119
117
|
);
|
|
120
118
|
};
|
|
119
|
+
|
|
120
|
+
const backgroundColor = hasColorBG ? theme.colors.background.default : theme.colors.background.surface
|
|
121
|
+
|
|
121
122
|
return (
|
|
122
|
-
<View
|
|
123
|
-
style={[style, styles.searchInputContainer]}
|
|
124
|
-
accessibilityLabel={accessibilityLabel}>
|
|
123
|
+
<View style={[style, styles.searchInputContainer]}>
|
|
125
124
|
<View
|
|
126
125
|
style={[
|
|
127
126
|
styles.searchInputWrapper,
|
|
128
127
|
{
|
|
129
|
-
backgroundColor
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
showBorder && {borderColor: theme.colors.border.default},
|
|
133
|
-
focused && {borderColor: theme.colors.primary},
|
|
128
|
+
backgroundColor,
|
|
129
|
+
}
|
|
134
130
|
]}>
|
|
135
131
|
<Icon
|
|
136
132
|
source={'navigation_search'}
|
|
@@ -142,7 +138,7 @@ const InputSearch = forwardRef(
|
|
|
142
138
|
</View>
|
|
143
139
|
{showButtonText && (
|
|
144
140
|
<TouchableOpacity onPress={onPressButtonText}>
|
|
145
|
-
<Text typography={'
|
|
141
|
+
<Text typography={'action_default_bold'} style={styles.textButton}>
|
|
146
142
|
{buttonText}
|
|
147
143
|
</Text>
|
|
148
144
|
</TouchableOpacity>
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -46,7 +46,6 @@ const InputTextArea = forwardRef(
|
|
|
46
46
|
const [focused, setFocused] = useState(false);
|
|
47
47
|
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
48
48
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
49
|
-
const accessibilityLabel = `InputTextArea/${floatingValue ?? placeholder}`;
|
|
50
49
|
|
|
51
50
|
const onClearText = () => {
|
|
52
51
|
inputRef?.current?.clear();
|
|
@@ -71,7 +70,9 @@ const InputTextArea = forwardRef(
|
|
|
71
70
|
const renderCountingView = () => {
|
|
72
71
|
return (
|
|
73
72
|
<View style={styles.countingView}>
|
|
74
|
-
<Text
|
|
73
|
+
<Text
|
|
74
|
+
color={theme.colors.text.hint}
|
|
75
|
+
typography={'description_xs_regular'}>
|
|
75
76
|
{`${inputValue.length}/${maxLength}`}
|
|
76
77
|
</Text>
|
|
77
78
|
</View>
|
|
@@ -108,7 +109,6 @@ const InputTextArea = forwardRef(
|
|
|
108
109
|
<View style={styles.textAreaView}>
|
|
109
110
|
<TextInput
|
|
110
111
|
{...props}
|
|
111
|
-
accessibilityLabel={accessibilityLabel}
|
|
112
112
|
ref={inputRef}
|
|
113
113
|
editable={!disabled}
|
|
114
114
|
textAlignVertical="top"
|
|
@@ -148,9 +148,7 @@ const InputTextArea = forwardRef(
|
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
return (
|
|
151
|
-
<View
|
|
152
|
-
style={[style, styles.wrapper]}
|
|
153
|
-
accessibilityLabel={accessibilityLabel}>
|
|
151
|
+
<View style={[style, styles.wrapper]}>
|
|
154
152
|
{renderInputView()}
|
|
155
153
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
156
154
|
</View>
|
package/Input/common.tsx
CHANGED
|
@@ -64,7 +64,7 @@ export const ErrorView: FC<{errorMessage?: string; errorSpacing?: boolean}> = ({
|
|
|
64
64
|
style={Styles.flex}
|
|
65
65
|
color={errorColor}
|
|
66
66
|
numberOfLines={2}
|
|
67
|
-
typography={'
|
|
67
|
+
typography={'description_default_regular'}>
|
|
68
68
|
{errorMessage}
|
|
69
69
|
</Text>
|
|
70
70
|
</View>
|
|
@@ -104,10 +104,12 @@ export const FloatingView: FC<FloatingViewProps> = ({
|
|
|
104
104
|
},
|
|
105
105
|
style,
|
|
106
106
|
]}>
|
|
107
|
-
<Text color={floatingTextColor} typography={'
|
|
107
|
+
<Text color={floatingTextColor} typography={'label_s_medium'}>
|
|
108
108
|
{floatingValue}
|
|
109
109
|
{required && (
|
|
110
|
-
<Text
|
|
110
|
+
<Text
|
|
111
|
+
typography={'label_s_medium'}
|
|
112
|
+
color={theme.colors.error.primary}>
|
|
111
113
|
*
|
|
112
114
|
</Text>
|
|
113
115
|
)}
|
package/Input/index.tsx
CHANGED
|
@@ -109,12 +109,6 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
109
109
|
*/
|
|
110
110
|
showButtonText?: boolean;
|
|
111
111
|
|
|
112
|
-
/**
|
|
113
|
-
* Optional. If `true`, a border will be displayed around the InputSearch component.
|
|
114
|
-
* Defaults to `true` if not provided.
|
|
115
|
-
*/
|
|
116
|
-
showBorder?: boolean;
|
|
117
|
-
|
|
118
112
|
onPressButtonText?: () => void;
|
|
119
113
|
|
|
120
114
|
/**
|
|
@@ -126,6 +120,8 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
126
120
|
* Optional. Represents the name or key of the icon to be displayed in the Input component.
|
|
127
121
|
*/
|
|
128
122
|
icon?: string;
|
|
123
|
+
|
|
124
|
+
hasColorBG?: boolean
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
|
package/Input/styles.ts
CHANGED
|
@@ -53,8 +53,7 @@ export default StyleSheet.create({
|
|
|
53
53
|
marginRight: Spacing.M,
|
|
54
54
|
},
|
|
55
55
|
icon: {
|
|
56
|
-
|
|
57
|
-
height: 24,
|
|
56
|
+
marginLeft: Spacing.S
|
|
58
57
|
},
|
|
59
58
|
iconWrapper: {
|
|
60
59
|
width: 24,
|
|
@@ -101,7 +100,6 @@ export default StyleSheet.create({
|
|
|
101
100
|
searchInputWrapper: {
|
|
102
101
|
flexDirection: 'row',
|
|
103
102
|
borderRadius: Radius.XL,
|
|
104
|
-
borderWidth: 1,
|
|
105
103
|
paddingHorizontal: Spacing.S,
|
|
106
104
|
alignItems: 'center',
|
|
107
105
|
flex: 1,
|
package/Layout/Card.tsx
CHANGED
|
@@ -29,7 +29,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
29
29
|
useShadow = false,
|
|
30
30
|
...props
|
|
31
31
|
}) => {
|
|
32
|
-
const {showGrid} = useContext(ApplicationContext);
|
|
32
|
+
const {showGrid, theme} = useContext(ApplicationContext);
|
|
33
33
|
const {numberOfColumns} = useGridSystem();
|
|
34
34
|
|
|
35
35
|
const gutterSize = 8;
|
|
@@ -47,6 +47,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
47
47
|
return span * sizePerSpan + (span - 1) * gutterSize;
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
|
+
|
|
50
51
|
/**
|
|
51
52
|
* render overlay only dev mode
|
|
52
53
|
*/
|
|
@@ -107,8 +108,9 @@ const Card: React.FC<CardProps> = ({
|
|
|
107
108
|
if (Array.isArray(children)) {
|
|
108
109
|
let cursor = 0;
|
|
109
110
|
let rows: any[] = [];
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
const arrayChild = children.filter(item => !!item);
|
|
112
|
+
for (let i = 0; i < arrayChild.length; ++i) {
|
|
113
|
+
const item = arrayChild[i];
|
|
112
114
|
const totalSpan = rows
|
|
113
115
|
.concat([item])
|
|
114
116
|
.map(i => i.props?.widthSpan)
|
|
@@ -124,7 +126,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
124
126
|
rows = [item];
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
if (i ==
|
|
129
|
+
if (i == arrayChild.length - 1) {
|
|
128
130
|
cursor += 1;
|
|
129
131
|
element.push(addRowView(rows, cursor, true));
|
|
130
132
|
}
|
|
@@ -138,23 +140,20 @@ const Card: React.FC<CardProps> = ({
|
|
|
138
140
|
return element;
|
|
139
141
|
};
|
|
140
142
|
|
|
141
|
-
const {theme} = useContext(ApplicationContext);
|
|
142
143
|
return (
|
|
143
144
|
<GridContext.Provider value={gridContext}>
|
|
144
145
|
<View
|
|
145
146
|
{...props}
|
|
146
|
-
accessibilityLabel={`Card`}
|
|
147
147
|
style={[
|
|
148
|
+
{backgroundColor: theme.colors.background.surface},
|
|
148
149
|
style,
|
|
149
150
|
styles.protectedStyle,
|
|
150
151
|
styles.card,
|
|
151
152
|
{
|
|
152
153
|
width: widthSection,
|
|
153
154
|
marginHorizontal: margin,
|
|
154
|
-
backgroundColor: backgroundImage
|
|
155
|
-
? undefined
|
|
156
|
-
: theme.colors.background.surface,
|
|
157
155
|
},
|
|
156
|
+
!!backgroundImage && {backgroundColor: undefined},
|
|
158
157
|
useShadow && Shadow.Light,
|
|
159
158
|
]}>
|
|
160
159
|
{!!backgroundImage && (
|
package/Layout/Item.tsx
CHANGED
package/Layout/ItemList.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {forwardRef, useContext} from 'react';
|
|
2
2
|
import {FlatList, FlatListProps, View} from 'react-native';
|
|
3
3
|
import Item, {SpanNumber} from './Item';
|
|
4
4
|
import {GridContext} from './index';
|
|
@@ -11,39 +11,45 @@ export interface ItemListProps extends FlatListProps<any> {
|
|
|
11
11
|
widthSpan?: SpanNumber;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const ItemList
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
const ItemList = forwardRef(
|
|
15
|
+
(
|
|
16
|
+
{
|
|
17
|
+
renderItem,
|
|
18
|
+
widthSpan,
|
|
19
|
+
style,
|
|
20
|
+
contentContainerStyle,
|
|
21
|
+
...props
|
|
22
|
+
}: ItemListProps,
|
|
23
|
+
ref,
|
|
24
|
+
) => {
|
|
25
|
+
const {gutterSize, numberOfColumns} = useContext(GridContext);
|
|
26
|
+
const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
|
|
27
|
+
const numColumns = Math.floor(numberOfColumns / widthItem);
|
|
28
|
+
const indexBegin = props?.data?.map((_i, index) => index * numColumns);
|
|
29
|
+
const _renderItem = (item: any) => {
|
|
30
|
+
if (indexBegin?.includes(item?.index)) {
|
|
31
|
+
return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
|
|
32
|
+
}
|
|
33
|
+
return (
|
|
34
|
+
<View style={{paddingLeft: gutterSize}}>
|
|
35
|
+
<Item widthSpan={widthItem}>{renderItem?.(item)}</Item>
|
|
36
|
+
</View>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
29
40
|
return (
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
<FlatList
|
|
42
|
+
ref={ref as React.RefObject<FlatList>}
|
|
43
|
+
{...props}
|
|
44
|
+
numColumns={numColumns}
|
|
45
|
+
renderItem={_renderItem}
|
|
46
|
+
horizontal={false}
|
|
47
|
+
ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
|
|
48
|
+
style={[style, styles.protectedStyle]}
|
|
49
|
+
contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
|
|
50
|
+
/>
|
|
33
51
|
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<FlatList
|
|
38
|
-
{...props}
|
|
39
|
-
numColumns={numColumns}
|
|
40
|
-
renderItem={_renderItem}
|
|
41
|
-
horizontal={false}
|
|
42
|
-
ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
|
|
43
|
-
style={[style, styles.protectedStyle]}
|
|
44
|
-
contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
52
|
+
},
|
|
53
|
+
);
|
|
48
54
|
|
|
49
55
|
export default ItemList;
|
package/Layout/Screen.tsx
CHANGED
|
@@ -301,9 +301,7 @@ const Screen = forwardRef(
|
|
|
301
301
|
};
|
|
302
302
|
|
|
303
303
|
return (
|
|
304
|
-
<View
|
|
305
|
-
style={[Styles.flex, {backgroundColor}]}
|
|
306
|
-
accessibilityLabel={`ScreenContainer`}>
|
|
304
|
+
<View style={[Styles.flex, {backgroundColor}]}>
|
|
307
305
|
{!!headerBackground && (
|
|
308
306
|
<>
|
|
309
307
|
<Image
|
package/Layout/Section.tsx
CHANGED
|
@@ -107,8 +107,9 @@ const Section: React.FC<SectionProps> = ({
|
|
|
107
107
|
if (Array.isArray(children)) {
|
|
108
108
|
let cursor = 0;
|
|
109
109
|
let rows: any[] = [];
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const arrayChild = children.filter(item => !!item);
|
|
111
|
+
for (let i = 0; i < arrayChild.length; ++i) {
|
|
112
|
+
const item = arrayChild[i];
|
|
112
113
|
const totalSpan = rows
|
|
113
114
|
.concat([item])
|
|
114
115
|
.map(i => i.props?.widthSpan)
|
|
@@ -124,7 +125,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
124
125
|
rows = [item];
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
if (i ==
|
|
128
|
+
if (i == arrayChild.length - 1) {
|
|
128
129
|
cursor += 1;
|
|
129
130
|
element.push(addRowView(rows, cursor, true));
|
|
130
131
|
}
|
|
@@ -150,7 +151,6 @@ const Section: React.FC<SectionProps> = ({
|
|
|
150
151
|
}}>
|
|
151
152
|
<View
|
|
152
153
|
{...props}
|
|
153
|
-
accessibilityLabel={`Section`}
|
|
154
154
|
style={[
|
|
155
155
|
style,
|
|
156
156
|
styles.protectedStyle,
|
|
@@ -13,7 +13,7 @@ const PaginationNumber: FC<ChildPaginationProps> = ({
|
|
|
13
13
|
return (
|
|
14
14
|
<View style={[style, styles.row]}>
|
|
15
15
|
<View style={styles.paginationNumberContainer}>
|
|
16
|
-
<Text color={Colors.black_01} typography={'
|
|
16
|
+
<Text color={Colors.black_01} typography={'label_default_medium'}>{`${
|
|
17
17
|
activeIndex + 1
|
|
18
18
|
}/${dataLength}`}</Text>
|
|
19
19
|
</View>
|