@momo-kits/foundation 0.89.5 → 0.89.6-rc.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 +216 -0
- package/Application/BottomTab/BottomTabBar.tsx +278 -0
- package/Application/{BottomTab.tsx → BottomTab/index.tsx} +42 -18
- package/Application/Components.tsx +350 -86
- package/Application/Localize.ts +44 -0
- package/Application/ModalScreen.tsx +14 -185
- package/Application/Navigation.ts +5 -19
- package/Application/NavigationContainer.tsx +62 -72
- package/Application/Navigator.ts +53 -35
- package/Application/StackScreen.tsx +289 -32
- package/Application/index.ts +13 -15
- package/Application/types.ts +64 -35
- package/Application/utils.tsx +76 -30
- package/Assets/icon_bank.json +1 -1
- package/Badge/Badge.tsx +1 -1
- package/Badge/BadgeDotAnimation.tsx +95 -0
- package/Badge/index.tsx +2 -1
- package/Badge/styles.ts +50 -6
- package/Button/index.tsx +44 -26
- package/CheckBox/index.tsx +37 -26
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +14 -0
- package/Icon/index.tsx +9 -8
- package/Icon/types.ts +2 -2
- package/IconButton/index.tsx +24 -14
- package/Image/index.tsx +23 -8
- package/Image/types.ts +2 -0
- package/Input/Input.tsx +116 -26
- package/Input/InputDropDown.tsx +66 -51
- package/Input/InputMoney.tsx +106 -15
- package/Input/InputOTP.tsx +49 -26
- package/Input/InputSearch.tsx +252 -99
- package/Input/InputTextArea.tsx +26 -6
- package/Input/TextTyping.tsx +113 -0
- package/Input/common.tsx +48 -22
- package/Input/index.tsx +112 -77
- package/Input/styles.ts +48 -11
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +4 -3
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +3 -2
- package/Layout/Screen.tsx +242 -121
- package/Layout/Section.tsx +4 -3
- package/Layout/styles.ts +11 -13
- package/Layout/types.ts +1 -1
- package/Layout/utils.ts +4 -4
- package/Loader/index.tsx +2 -0
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +56 -45
- package/Popup/PopupPromotion.tsx +5 -7
- package/Popup/types.ts +1 -7
- package/Radio/index.tsx +35 -20
- package/Radio/types.ts +5 -3
- package/Switch/index.tsx +32 -18
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +9 -2
- package/Tag/styles.ts +3 -2
- package/Tag/types.ts +12 -0
- package/Text/index.tsx +24 -5
- package/Text/styles.ts +8 -8
- package/Text/types.ts +19 -1
- package/Title/index.tsx +170 -103
- package/Title/styles.ts +36 -9
- package/Title/types.ts +16 -48
- package/code-scanner.js +125 -16
- package/index.ts +7 -0
- package/migrate_typo.js +56 -0
- package/package.json +11 -10
- package/publish.sh +16 -21
- package/tsconfig.json +1 -1
- package/verify.js +37 -40
package/Application/utils.tsx
CHANGED
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
HeaderBackground,
|
|
8
8
|
HeaderCustom,
|
|
9
9
|
HeaderLeft,
|
|
10
|
+
HeaderRight,
|
|
10
11
|
HeaderTitle,
|
|
11
|
-
HeaderToolkitAction,
|
|
12
12
|
} from './Components';
|
|
13
|
-
import {NavigationOptions
|
|
13
|
+
import {NavigationOptions} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
|
+
import Navigation from './Navigation';
|
|
16
|
+
import {LayoutChangeEvent} from 'react-native';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* default options for stack screen
|
|
@@ -22,7 +24,7 @@ const getStackOptions = (): StackNavigationOptions => {
|
|
|
22
24
|
headerTitle: HeaderTitle,
|
|
23
25
|
headerBackground: (props: any) => <HeaderBackground {...props} />,
|
|
24
26
|
headerLeft: (props: any) => <HeaderLeft {...props} />,
|
|
25
|
-
headerRight: (props: any) => <
|
|
27
|
+
headerRight: (props: any) => <HeaderRight {...props} />,
|
|
26
28
|
headerTintColor: Colors.black_01,
|
|
27
29
|
};
|
|
28
30
|
};
|
|
@@ -72,39 +74,44 @@ const getModalOptions = (): StackNavigationOptions => {
|
|
|
72
74
|
/**
|
|
73
75
|
* build react-navigation options
|
|
74
76
|
*/
|
|
75
|
-
const getOptions = (params: NavigationOptions,
|
|
77
|
+
const getOptions = (params: NavigationOptions, navigation?: Navigation) => {
|
|
76
78
|
let options = {};
|
|
77
79
|
|
|
80
|
+
/**
|
|
81
|
+
* left header factory
|
|
82
|
+
*/
|
|
78
83
|
if (
|
|
79
84
|
typeof params.onPressLeftHeader === 'function' ||
|
|
80
85
|
params.preventBack !== undefined ||
|
|
81
86
|
typeof params.hiddenBack === 'boolean'
|
|
82
87
|
) {
|
|
88
|
+
let headerLeft: any = (props: any) => (
|
|
89
|
+
<HeaderLeft
|
|
90
|
+
{...props}
|
|
91
|
+
preventBack={params.preventBack}
|
|
92
|
+
onPressLeftHeader={params.onPressLeftHeader}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
if (params.hiddenBack) {
|
|
96
|
+
headerLeft = null;
|
|
97
|
+
}
|
|
83
98
|
options = {
|
|
84
99
|
...options,
|
|
85
|
-
headerLeft
|
|
86
|
-
? null
|
|
87
|
-
: (props: any) => (
|
|
88
|
-
<HeaderLeft
|
|
89
|
-
{...props}
|
|
90
|
-
preventBack={params.preventBack}
|
|
91
|
-
onPressLeftHeader={params.onPressLeftHeader}
|
|
92
|
-
/>
|
|
93
|
-
),
|
|
100
|
+
headerLeft,
|
|
94
101
|
};
|
|
95
102
|
}
|
|
96
103
|
|
|
97
|
-
|
|
104
|
+
/**
|
|
105
|
+
* surface header style
|
|
106
|
+
*/
|
|
107
|
+
if (typeof params.surface === 'boolean') {
|
|
108
|
+
console.warn('surface options is deprecated, headerType instead in screen');
|
|
98
109
|
if (params.surface) {
|
|
99
110
|
options = {
|
|
100
111
|
...options,
|
|
101
|
-
headerTintColor:
|
|
112
|
+
headerTintColor: Colors.black_17,
|
|
102
113
|
headerBackground: () => (
|
|
103
|
-
<HeaderBackground
|
|
104
|
-
image={null}
|
|
105
|
-
backgroundColor={theme.colors.background.surface}
|
|
106
|
-
useBorder={true}
|
|
107
|
-
/>
|
|
114
|
+
<HeaderBackground image={null} useSurface={true} />
|
|
108
115
|
),
|
|
109
116
|
};
|
|
110
117
|
} else {
|
|
@@ -116,7 +123,13 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
116
123
|
}
|
|
117
124
|
}
|
|
118
125
|
|
|
126
|
+
/**
|
|
127
|
+
* custom title
|
|
128
|
+
*/
|
|
119
129
|
if (params.customTitle) {
|
|
130
|
+
console.warn(
|
|
131
|
+
'customTitle options is deprecated, please used headerTitle instead'
|
|
132
|
+
);
|
|
120
133
|
options = {
|
|
121
134
|
...options,
|
|
122
135
|
headerTitleAlign: 'left',
|
|
@@ -126,19 +139,39 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
126
139
|
};
|
|
127
140
|
}
|
|
128
141
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
/**
|
|
143
|
+
* header right
|
|
144
|
+
*/
|
|
145
|
+
if (params.headerRight) {
|
|
146
|
+
let headerRight: any = (props: any) => {
|
|
147
|
+
return (
|
|
148
|
+
<HeaderRight
|
|
149
|
+
{...props}
|
|
150
|
+
{...params.headerRight}
|
|
151
|
+
onLayout={(e: LayoutChangeEvent) => {
|
|
152
|
+
navigation?.onHeaderRightChange?.(e.nativeEvent.layout.width);
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
if (typeof params.headerRight === 'function') {
|
|
158
|
+
headerRight = (props: any) => {
|
|
132
159
|
return (
|
|
133
|
-
<
|
|
134
|
-
preventBack={params.preventBack}
|
|
135
|
-
pinnedTool={params.toolkitParams?.pinnedTool}
|
|
136
|
-
runtimeTools={params.toolkitParams?.runtimeTools}
|
|
160
|
+
<HeaderRight
|
|
137
161
|
{...props}
|
|
138
|
-
|
|
162
|
+
onLayout={(e: LayoutChangeEvent) => {
|
|
163
|
+
navigation?.onHeaderRightChange?.(e.nativeEvent.layout.width);
|
|
164
|
+
}}>
|
|
165
|
+
{params.headerRight(props)}
|
|
166
|
+
</HeaderRight>
|
|
139
167
|
);
|
|
140
|
-
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
options = {
|
|
171
|
+
...options,
|
|
172
|
+
headerRight,
|
|
141
173
|
};
|
|
174
|
+
}
|
|
142
175
|
|
|
143
176
|
return {
|
|
144
177
|
...params,
|
|
@@ -146,4 +179,17 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
146
179
|
};
|
|
147
180
|
};
|
|
148
181
|
|
|
149
|
-
|
|
182
|
+
const formatNameLength = (name = '') => {
|
|
183
|
+
let formattedName = name;
|
|
184
|
+
if (formattedName.length > 100) {
|
|
185
|
+
formattedName = formattedName.substring(0, 100);
|
|
186
|
+
}
|
|
187
|
+
return formattedName;
|
|
188
|
+
};
|
|
189
|
+
export {
|
|
190
|
+
getStackOptions,
|
|
191
|
+
getDialogOptions,
|
|
192
|
+
getModalOptions,
|
|
193
|
+
getOptions,
|
|
194
|
+
formatNameLength,
|
|
195
|
+
};
|
package/Assets/icon_bank.json
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>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, {useEffect, useRef} from 'react';
|
|
2
|
+
import {Animated, View} from 'react-native';
|
|
3
|
+
import {BadgeDotProps} from './types';
|
|
4
|
+
import styles from './styles';
|
|
5
|
+
|
|
6
|
+
const DURATION = 500;
|
|
7
|
+
|
|
8
|
+
const BadgeDotAnimation = ({size, style}: BadgeDotProps) => {
|
|
9
|
+
// Refs for animated values
|
|
10
|
+
const scaleAnim = useRef(new Animated.Value(1)).current;
|
|
11
|
+
const waveScaleAnim = useRef(new Animated.Value(1)).current;
|
|
12
|
+
const waveOpacityAnim = useRef(new Animated.Value(0)).current;
|
|
13
|
+
|
|
14
|
+
const dotStyle =
|
|
15
|
+
size === 'small' ? styles.dotAnimationSmall : styles.dotAnimation;
|
|
16
|
+
const waveStyle = size === 'small' ? styles.waveSmall : styles.wave;
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
// Infinite loop animation for the scale and wave effect
|
|
20
|
+
const animation = Animated.loop(
|
|
21
|
+
Animated.parallel([
|
|
22
|
+
// Dot pulse animation
|
|
23
|
+
Animated.sequence([
|
|
24
|
+
Animated.spring(scaleAnim, {
|
|
25
|
+
toValue: 1, // Scale up slightly
|
|
26
|
+
friction: 5, // Controls the "bounciness" of the spring
|
|
27
|
+
tension: 30, // Controls the "stiffness" of the spring
|
|
28
|
+
useNativeDriver: true,
|
|
29
|
+
}),
|
|
30
|
+
Animated.spring(scaleAnim, {
|
|
31
|
+
toValue: 1.1,
|
|
32
|
+
friction: 5,
|
|
33
|
+
tension: 30,
|
|
34
|
+
useNativeDriver: true,
|
|
35
|
+
}),
|
|
36
|
+
]), // Wave animation
|
|
37
|
+
Animated.sequence([
|
|
38
|
+
Animated.timing(waveScaleAnim, {
|
|
39
|
+
toValue: 2.5,
|
|
40
|
+
duration: DURATION * 3,
|
|
41
|
+
useNativeDriver: true,
|
|
42
|
+
}),
|
|
43
|
+
Animated.timing(waveScaleAnim, {
|
|
44
|
+
toValue: 1, // Reset wave size
|
|
45
|
+
duration: 0,
|
|
46
|
+
useNativeDriver: true,
|
|
47
|
+
}),
|
|
48
|
+
]), // Wave opacity animation
|
|
49
|
+
Animated.sequence([
|
|
50
|
+
Animated.timing(waveOpacityAnim, {
|
|
51
|
+
toValue: 0.3, // Wave becomes visible
|
|
52
|
+
duration: DURATION * 2,
|
|
53
|
+
useNativeDriver: true,
|
|
54
|
+
}),
|
|
55
|
+
Animated.timing(waveOpacityAnim, {
|
|
56
|
+
toValue: 0, // Wave fades out
|
|
57
|
+
duration: DURATION,
|
|
58
|
+
useNativeDriver: true,
|
|
59
|
+
}),
|
|
60
|
+
]),
|
|
61
|
+
])
|
|
62
|
+
);
|
|
63
|
+
animation.start();
|
|
64
|
+
|
|
65
|
+
return () => {
|
|
66
|
+
animation.stop();
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<View style={[styles.dotAnimationContainer, style]}>
|
|
72
|
+
{/* Wave Animation */}
|
|
73
|
+
<Animated.View
|
|
74
|
+
style={[
|
|
75
|
+
waveStyle,
|
|
76
|
+
{
|
|
77
|
+
transform: [{scale: waveScaleAnim}],
|
|
78
|
+
opacity: waveOpacityAnim,
|
|
79
|
+
},
|
|
80
|
+
]}
|
|
81
|
+
/>
|
|
82
|
+
{/* Dot Animation */}
|
|
83
|
+
<Animated.View
|
|
84
|
+
style={[
|
|
85
|
+
dotStyle,
|
|
86
|
+
{
|
|
87
|
+
transform: [{scale: scaleAnim}],
|
|
88
|
+
},
|
|
89
|
+
]}
|
|
90
|
+
/>
|
|
91
|
+
</View>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default BadgeDotAnimation;
|
package/Badge/index.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Badge from './Badge';
|
|
2
2
|
import BadgeDot from './BadgeDot';
|
|
3
3
|
import BadgeRibbon from './BadgeRibbon';
|
|
4
|
+
import BadgeDotAnimation from './BadgeDotAnimation';
|
|
4
5
|
import {BadgeProps, BadgeDotProps, BadgeRibbonProps} from './types';
|
|
5
6
|
|
|
6
|
-
export {Badge, BadgeRibbon, BadgeDot};
|
|
7
|
+
export {Badge, BadgeRibbon, BadgeDot, BadgeDotAnimation};
|
|
7
8
|
export type {BadgeProps, BadgeDotProps, BadgeRibbonProps};
|
package/Badge/styles.ts
CHANGED
|
@@ -2,6 +2,10 @@ import {StyleSheet} from 'react-native';
|
|
|
2
2
|
import {Colors, Radius, Spacing} from '../Consts';
|
|
3
3
|
import {scaleSize} from '../Text';
|
|
4
4
|
|
|
5
|
+
const DOT_SIZE = 16;
|
|
6
|
+
|
|
7
|
+
const DOT_SMALL_SIZE = 10;
|
|
8
|
+
|
|
5
9
|
export default StyleSheet.create({
|
|
6
10
|
badge: {
|
|
7
11
|
paddingHorizontal: Spacing.XS,
|
|
@@ -15,21 +19,61 @@ export default StyleSheet.create({
|
|
|
15
19
|
borderColor: Colors.black_01,
|
|
16
20
|
alignSelf: 'baseline',
|
|
17
21
|
},
|
|
22
|
+
dotAnimationContainer: {
|
|
23
|
+
position: 'relative',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
},
|
|
18
27
|
dot: {
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
28
|
+
width: DOT_SIZE,
|
|
29
|
+
height: DOT_SIZE,
|
|
21
30
|
borderWidth: 2,
|
|
22
31
|
borderColor: Colors.black_01,
|
|
23
32
|
backgroundColor: Colors.red_03,
|
|
24
|
-
borderRadius:
|
|
33
|
+
borderRadius: DOT_SIZE / 2,
|
|
25
34
|
},
|
|
26
35
|
dotSmall: {
|
|
27
|
-
width:
|
|
28
|
-
height:
|
|
36
|
+
width: DOT_SMALL_SIZE,
|
|
37
|
+
height: DOT_SMALL_SIZE,
|
|
29
38
|
borderWidth: 1,
|
|
30
39
|
borderColor: Colors.black_01,
|
|
31
40
|
backgroundColor: Colors.red_03,
|
|
32
|
-
borderRadius:
|
|
41
|
+
borderRadius: DOT_SMALL_SIZE / 2,
|
|
42
|
+
},
|
|
43
|
+
dotAnimation: {
|
|
44
|
+
width: DOT_SIZE,
|
|
45
|
+
height: DOT_SIZE,
|
|
46
|
+
borderColor: Colors.black_01,
|
|
47
|
+
backgroundColor: Colors.red_03,
|
|
48
|
+
borderRadius: DOT_SIZE / 2,
|
|
49
|
+
borderWidth: 0,
|
|
50
|
+
},
|
|
51
|
+
dotAnimationSmall: {
|
|
52
|
+
width: DOT_SMALL_SIZE,
|
|
53
|
+
height: DOT_SMALL_SIZE,
|
|
54
|
+
borderColor: Colors.black_01,
|
|
55
|
+
backgroundColor: Colors.red_03,
|
|
56
|
+
borderRadius: DOT_SMALL_SIZE / 2,
|
|
57
|
+
borderWidth: 0,
|
|
58
|
+
},
|
|
59
|
+
wave: {
|
|
60
|
+
width: DOT_SIZE,
|
|
61
|
+
height: DOT_SIZE,
|
|
62
|
+
borderColor: Colors.black_01,
|
|
63
|
+
backgroundColor: Colors.red_03,
|
|
64
|
+
borderRadius: DOT_SIZE / 2,
|
|
65
|
+
opacity: 0,
|
|
66
|
+
position: 'absolute',
|
|
67
|
+
borderWidth: 0,
|
|
68
|
+
},
|
|
69
|
+
waveSmall: {
|
|
70
|
+
width: DOT_SMALL_SIZE,
|
|
71
|
+
height: DOT_SMALL_SIZE,
|
|
72
|
+
borderColor: Colors.black_01,
|
|
73
|
+
backgroundColor: Colors.red_03,
|
|
74
|
+
borderRadius: DOT_SMALL_SIZE / 2,
|
|
75
|
+
borderWidth: 0,
|
|
76
|
+
position: 'absolute',
|
|
33
77
|
},
|
|
34
78
|
ribbon: {
|
|
35
79
|
alignSelf: 'baseline',
|
package/Button/index.tsx
CHANGED
|
@@ -6,9 +6,8 @@ import {
|
|
|
6
6
|
TouchableOpacityProps,
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
|
-
|
|
10
9
|
import LinearGradient from 'react-native-linear-gradient';
|
|
11
|
-
import {ApplicationContext} from '../Application';
|
|
10
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
12
11
|
import {Text} from '../Text';
|
|
13
12
|
import {Typography} from '../Text/types';
|
|
14
13
|
import {Colors, Spacing} from '../Consts';
|
|
@@ -59,7 +58,7 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
59
58
|
/**
|
|
60
59
|
* If true, the icon of button will use the tint color provided by its container.
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
tintColor?: string;
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
64
|
* If true, the icon of button will use be show indicator loading.
|
|
@@ -70,30 +69,39 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
70
69
|
* A callback function that is called when the button is pressed.
|
|
71
70
|
*/
|
|
72
71
|
onPress: () => void;
|
|
72
|
+
|
|
73
|
+
params?: any;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
const Button: FC<ButtonProps> = ({
|
|
76
77
|
type = 'primary',
|
|
77
78
|
size = 'large',
|
|
78
|
-
|
|
79
|
+
tintColor = null,
|
|
79
80
|
full = true,
|
|
80
81
|
iconRight,
|
|
81
82
|
iconLeft,
|
|
82
83
|
loading = false,
|
|
83
84
|
title = 'Button',
|
|
84
85
|
onPress,
|
|
86
|
+
params,
|
|
87
|
+
accessibilityLabel,
|
|
85
88
|
...rest
|
|
86
89
|
}) => {
|
|
87
90
|
const {theme, config} = useContext(ApplicationContext);
|
|
88
91
|
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
89
92
|
let gradientPros;
|
|
90
|
-
|
|
93
|
+
let state = 'enabled';
|
|
94
|
+
if (loading) {
|
|
95
|
+
state = 'loading';
|
|
96
|
+
}
|
|
97
|
+
if (gradient?.length > 0 && type === 'primary') {
|
|
91
98
|
gradientPros = {
|
|
92
99
|
colors: gradient,
|
|
93
100
|
start: {x: 1, y: 0.5},
|
|
94
101
|
end: {x: 0, y: 0.5},
|
|
95
102
|
};
|
|
96
103
|
}
|
|
104
|
+
|
|
97
105
|
const getSizeStyle = () => {
|
|
98
106
|
const styleSheet: {[key: string]: any} = styles;
|
|
99
107
|
return styleSheet[size ?? 'small'];
|
|
@@ -209,9 +217,9 @@ const Button: FC<ButtonProps> = ({
|
|
|
209
217
|
*/
|
|
210
218
|
const renderTitle = () => {
|
|
211
219
|
const typography = getTypography();
|
|
212
|
-
const
|
|
220
|
+
const textColor = getTextColor();
|
|
213
221
|
return (
|
|
214
|
-
<Text typography={typography} color={
|
|
222
|
+
<Text typography={typography} color={textColor} numberOfLines={1}>
|
|
215
223
|
{title}
|
|
216
224
|
</Text>
|
|
217
225
|
);
|
|
@@ -223,7 +231,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
223
231
|
const renderLeading = () => {
|
|
224
232
|
const iconSize = getIconSize();
|
|
225
233
|
const marginRight = getIconSpace();
|
|
226
|
-
const
|
|
234
|
+
const textColor = tintColor ?? getTextColor();
|
|
227
235
|
|
|
228
236
|
if (loading) {
|
|
229
237
|
return (
|
|
@@ -237,7 +245,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
237
245
|
borderRadius: Spacing.M,
|
|
238
246
|
},
|
|
239
247
|
]}>
|
|
240
|
-
<Loader type="spinner" color={
|
|
248
|
+
<Loader type="spinner" color={getTextColor()} />
|
|
241
249
|
</View>
|
|
242
250
|
);
|
|
243
251
|
}
|
|
@@ -248,7 +256,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
248
256
|
styles.leading,
|
|
249
257
|
{width: iconSize, height: iconSize, marginRight},
|
|
250
258
|
]}>
|
|
251
|
-
<Icon color={
|
|
259
|
+
<Icon color={textColor} source={iconLeft} size={iconSize} />
|
|
252
260
|
</View>
|
|
253
261
|
);
|
|
254
262
|
}
|
|
@@ -258,7 +266,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
258
266
|
* render trailing
|
|
259
267
|
*/
|
|
260
268
|
const renderTrailing = () => {
|
|
261
|
-
const
|
|
269
|
+
const textColor = tintColor ?? getTextColor();
|
|
262
270
|
const marginLeft = getIconSpace();
|
|
263
271
|
|
|
264
272
|
if (iconRight) {
|
|
@@ -269,7 +277,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
269
277
|
styles.trailing,
|
|
270
278
|
{width: iconSize, height: iconSize, marginLeft},
|
|
271
279
|
]}>
|
|
272
|
-
<Icon color={
|
|
280
|
+
<Icon color={textColor} source={iconRight} size={iconSize} />
|
|
273
281
|
</View>
|
|
274
282
|
);
|
|
275
283
|
}
|
|
@@ -289,21 +297,31 @@ const Button: FC<ButtonProps> = ({
|
|
|
289
297
|
};
|
|
290
298
|
|
|
291
299
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
292
|
-
|
|
293
300
|
return (
|
|
294
|
-
<
|
|
295
|
-
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
301
|
+
<ComponentContext.Provider
|
|
302
|
+
value={{
|
|
303
|
+
componentName: 'Button',
|
|
304
|
+
params,
|
|
305
|
+
state: state,
|
|
306
|
+
componentId: accessibilityLabel,
|
|
307
|
+
componentValue: title,
|
|
308
|
+
action: 'click',
|
|
309
|
+
}}>
|
|
310
|
+
<TouchableOpacity
|
|
311
|
+
{...rest}
|
|
312
|
+
accessibilityLabel={accessibilityLabel}
|
|
313
|
+
activeOpacity={activeOpacity}
|
|
314
|
+
onPress={onPressButton}
|
|
315
|
+
style={buttonStyle}>
|
|
316
|
+
{renderLeading()}
|
|
317
|
+
{renderTitle()}
|
|
318
|
+
{renderTrailing()}
|
|
319
|
+
{gradientPros && (
|
|
320
|
+
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
321
|
+
)}
|
|
322
|
+
{gradientPros && <View style={styles.strokeView} />}
|
|
323
|
+
</TouchableOpacity>
|
|
324
|
+
</ComponentContext.Provider>
|
|
307
325
|
);
|
|
308
326
|
};
|
|
309
327
|
|
package/CheckBox/index.tsx
CHANGED
|
@@ -2,17 +2,20 @@ import React, {FC, useContext} from 'react';
|
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {CheckBoxProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {ApplicationContext} from '../Application';
|
|
5
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
+
import {formatNameLength} from '../Application/utils';
|
|
8
9
|
|
|
9
10
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
10
11
|
value,
|
|
11
|
-
disabled,
|
|
12
|
+
disabled = false,
|
|
12
13
|
onChange,
|
|
13
14
|
style,
|
|
14
15
|
label,
|
|
15
16
|
indeterminate,
|
|
17
|
+
params,
|
|
18
|
+
accessibilityLabel,
|
|
16
19
|
}) => {
|
|
17
20
|
const {theme} = useContext(ApplicationContext);
|
|
18
21
|
const haveValue = value || indeterminate;
|
|
@@ -35,31 +38,39 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
<ComponentContext.Provider
|
|
42
|
+
value={{
|
|
43
|
+
componentName: 'CheckBox',
|
|
44
|
+
params,
|
|
45
|
+
state: disabled ? 'disabled' : 'filled',
|
|
46
|
+
componentId: accessibilityLabel,
|
|
47
|
+
action: 'click',
|
|
48
|
+
componentLabel: formatNameLength(label || ''),
|
|
49
|
+
componentValue: indeterminate ? 'undetermined' : value,
|
|
50
|
+
}}>
|
|
51
|
+
<TouchableOpacity
|
|
52
|
+
accessibilityLabel={accessibilityLabel}
|
|
53
|
+
activeOpacity={0.8}
|
|
54
|
+
onPress={() => onChange?.(!value)}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
style={[style, styles.container]}>
|
|
57
|
+
<View
|
|
58
|
+
style={[
|
|
59
|
+
{borderColor, backgroundColor, borderWidth: 1},
|
|
60
|
+
styles.checkbox,
|
|
61
|
+
]}>
|
|
62
|
+
{haveValue && (
|
|
63
|
+
<Icon
|
|
64
|
+
color={theme.colors.background.surface}
|
|
65
|
+
size={20}
|
|
66
|
+
source={iconSource}
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
</View>
|
|
70
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
71
|
+
</TouchableOpacity>
|
|
72
|
+
</ComponentContext.Provider>
|
|
58
73
|
);
|
|
59
74
|
};
|
|
60
75
|
|
|
61
|
-
CheckBox.defaultProps = {
|
|
62
|
-
disabled: false,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
76
|
export {CheckBox};
|
package/CheckBox/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {ViewStyle} from 'react-native';
|
|
1
|
+
import {TouchableOpacityProps, ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface CheckBoxProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
5
5
|
* Represents whether the CheckBox is currently checked (`true`) or unchecked (`false`).
|
|
6
6
|
*/
|
|
@@ -35,4 +35,6 @@ export type CheckBoxProps = {
|
|
|
35
35
|
* Accepts an object of style properties.
|
|
36
36
|
*/
|
|
37
37
|
style?: ViewStyle;
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
params?: any;
|
|
40
|
+
}
|
|
@@ -213,6 +213,20 @@ const Shadow = {
|
|
|
213
213
|
elevation: 6,
|
|
214
214
|
},
|
|
215
215
|
}),
|
|
216
|
+
|
|
217
|
+
Pink: Platform.select({
|
|
218
|
+
ios: {
|
|
219
|
+
shadowColor: '#e27eb5',
|
|
220
|
+
shadowOffset: {width: 0, height: 6},
|
|
221
|
+
shadowOpacity: 0.25,
|
|
222
|
+
shadowRadius: 8,
|
|
223
|
+
},
|
|
224
|
+
android: {
|
|
225
|
+
elevation: 16,
|
|
226
|
+
shadowColor: '#e27eb5',
|
|
227
|
+
shadowOpacity: 0.25,
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
216
230
|
};
|
|
217
231
|
|
|
218
232
|
export {Colors, Spacing, Radius, Shadow};
|