@momo-kits/foundation 0.81.37-tracking.1 → 0.81.37-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/Button/index.tsx +0 -5
- package/CheckBox/index.tsx +34 -21
- package/IconButton/index.tsx +21 -8
- package/Radio/index.tsx +33 -19
- package/Switch/index.tsx +27 -14
- package/package.json +1 -1
package/Button/index.tsx
CHANGED
|
@@ -85,7 +85,6 @@ const Button: FC<ButtonProps> = ({
|
|
|
85
85
|
loading = false,
|
|
86
86
|
title = 'Button',
|
|
87
87
|
onPress,
|
|
88
|
-
accessibilityLabel,
|
|
89
88
|
...rest
|
|
90
89
|
}) => {
|
|
91
90
|
const {theme, config} = useContext(ApplicationContext);
|
|
@@ -303,14 +302,10 @@ const Button: FC<ButtonProps> = ({
|
|
|
303
302
|
componentName: 'Button',
|
|
304
303
|
params: {
|
|
305
304
|
title,
|
|
306
|
-
accessibilityLabel,
|
|
307
305
|
},
|
|
308
306
|
}}>
|
|
309
307
|
<TouchableOpacity
|
|
310
308
|
{...rest}
|
|
311
|
-
accessibilityLabel={`${screenInfo.screenName}/Button/${
|
|
312
|
-
accessibilityLabel ?? title
|
|
313
|
-
}`}
|
|
314
309
|
activeOpacity={activeOpacity}
|
|
315
310
|
onPress={onPressButton}
|
|
316
311
|
style={buttonStyle}>
|
package/CheckBox/index.tsx
CHANGED
|
@@ -6,6 +6,10 @@ import {ApplicationContext} from '../Application';
|
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
8
|
|
|
9
|
+
const {
|
|
10
|
+
ScreenContext,
|
|
11
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
12
|
+
|
|
9
13
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
10
14
|
value,
|
|
11
15
|
disabled,
|
|
@@ -19,6 +23,7 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
19
23
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
20
24
|
let borderColor = theme.colors.text.default;
|
|
21
25
|
let backgroundColor = theme.colors.background.surface;
|
|
26
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
22
27
|
|
|
23
28
|
if (haveValue) {
|
|
24
29
|
borderColor = theme.colors.primary;
|
|
@@ -35,27 +40,35 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
<ScreenContext.Provider
|
|
44
|
+
value={{
|
|
45
|
+
...screenInfo,
|
|
46
|
+
componentName: 'CheckBox',
|
|
47
|
+
params: {
|
|
48
|
+
value,
|
|
49
|
+
},
|
|
50
|
+
}}>
|
|
51
|
+
<TouchableOpacity
|
|
52
|
+
activeOpacity={0.8}
|
|
53
|
+
onPress={() => onChange?.(!value)}
|
|
54
|
+
disabled={disabled}
|
|
55
|
+
style={[style, styles.container]}>
|
|
56
|
+
<View
|
|
57
|
+
style={[
|
|
58
|
+
{borderColor, backgroundColor, borderWidth: 1},
|
|
59
|
+
styles.checkbox,
|
|
60
|
+
]}>
|
|
61
|
+
{haveValue && (
|
|
62
|
+
<Icon
|
|
63
|
+
color={theme.colors.background.surface}
|
|
64
|
+
size={20}
|
|
65
|
+
source={iconSource}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
</View>
|
|
69
|
+
{!!label && <Text typography={'description_default'}>{label}</Text>}
|
|
70
|
+
</TouchableOpacity>
|
|
71
|
+
</ScreenContext.Provider>
|
|
59
72
|
);
|
|
60
73
|
};
|
|
61
74
|
|
package/IconButton/index.tsx
CHANGED
|
@@ -10,6 +10,10 @@ import {Colors} from '../Consts';
|
|
|
10
10
|
import {Icon} from '../Icon';
|
|
11
11
|
import styles from './styles';
|
|
12
12
|
|
|
13
|
+
const {
|
|
14
|
+
ScreenContext,
|
|
15
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
16
|
+
|
|
13
17
|
export interface IconButtonProps extends TouchableOpacityProps {
|
|
14
18
|
/**
|
|
15
19
|
* Represents the name or key of the icon to be displayed on the IconButton.
|
|
@@ -36,6 +40,7 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
36
40
|
...rest
|
|
37
41
|
}) => {
|
|
38
42
|
const {theme} = useContext(ApplicationContext);
|
|
43
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
39
44
|
|
|
40
45
|
/**
|
|
41
46
|
* get size icon button
|
|
@@ -121,14 +126,22 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
121
126
|
const iconSize = size === 'small' ? 16 : 24;
|
|
122
127
|
|
|
123
128
|
return (
|
|
124
|
-
<
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
<ScreenContext.Provider
|
|
130
|
+
value={{
|
|
131
|
+
...screenInfo,
|
|
132
|
+
componentName: 'IconButton',
|
|
133
|
+
params: {
|
|
134
|
+
icon,
|
|
135
|
+
},
|
|
136
|
+
}}>
|
|
137
|
+
<TouchableOpacity
|
|
138
|
+
{...rest}
|
|
139
|
+
activeOpacity={activeOpacity}
|
|
140
|
+
onPress={onPressButton}
|
|
141
|
+
style={buttonStyle}>
|
|
142
|
+
<Icon size={iconSize} source={icon} color={getIconColor()} />
|
|
143
|
+
</TouchableOpacity>
|
|
144
|
+
</ScreenContext.Provider>
|
|
132
145
|
);
|
|
133
146
|
};
|
|
134
147
|
|
package/Radio/index.tsx
CHANGED
|
@@ -7,6 +7,10 @@ import styles from './styles';
|
|
|
7
7
|
import {ApplicationContext} from '../Application';
|
|
8
8
|
import {Spacing} from '../Consts';
|
|
9
9
|
|
|
10
|
+
const {
|
|
11
|
+
ScreenContext,
|
|
12
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
13
|
+
|
|
10
14
|
const Radio: FC<RadioProps> = ({
|
|
11
15
|
value,
|
|
12
16
|
groupValue,
|
|
@@ -37,28 +41,38 @@ const Radio: FC<RadioProps> = ({
|
|
|
37
41
|
};
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
45
|
+
|
|
40
46
|
return (
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
flexDirection: 'row',
|
|
49
|
-
alignItems: 'center',
|
|
47
|
+
<ScreenContext.Provider
|
|
48
|
+
value={{
|
|
49
|
+
...screenInfo,
|
|
50
|
+
componentName: 'Radio',
|
|
51
|
+
params: {
|
|
52
|
+
value,
|
|
50
53
|
},
|
|
51
|
-
|
|
52
|
-
<
|
|
54
|
+
}}>
|
|
55
|
+
<TouchableOpacity
|
|
56
|
+
onPress={onChange}
|
|
57
|
+
disabled={disabled}
|
|
53
58
|
style={[
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
style,
|
|
60
|
+
{
|
|
61
|
+
flexDirection: 'row',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
},
|
|
64
|
+
]}>
|
|
65
|
+
<View
|
|
66
|
+
style={[
|
|
67
|
+
styles.radio,
|
|
68
|
+
checkBoxStyle,
|
|
69
|
+
disabledStyle,
|
|
70
|
+
{marginRight: label ? Spacing.XS : 0},
|
|
71
|
+
]}
|
|
72
|
+
/>
|
|
73
|
+
{!!label && <Text typography={'description_default'}>{label}</Text>}
|
|
74
|
+
</TouchableOpacity>
|
|
75
|
+
</ScreenContext.Provider>
|
|
62
76
|
);
|
|
63
77
|
};
|
|
64
78
|
|
package/Switch/index.tsx
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import React, {FC} from 'react';
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {SwitchProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {Colors} from '../Consts';
|
|
6
6
|
|
|
7
|
+
const {
|
|
8
|
+
ScreenContext,
|
|
9
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
10
|
+
|
|
7
11
|
const Switch: FC<SwitchProps> = props => {
|
|
8
12
|
const {value, onChange, disabled, style} = props;
|
|
9
13
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
10
14
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
15
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
11
16
|
|
|
12
17
|
let backgroundColor = value ? Colors.green_03 : Colors.black_07;
|
|
13
18
|
if (disabled) {
|
|
@@ -15,19 +20,27 @@ const Switch: FC<SwitchProps> = props => {
|
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
return (
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
<ScreenContext.Provider
|
|
24
|
+
value={{
|
|
25
|
+
...screenInfo,
|
|
26
|
+
componentName: 'Switch',
|
|
27
|
+
params: {
|
|
28
|
+
value,
|
|
29
|
+
},
|
|
30
|
+
}}>
|
|
31
|
+
<TouchableOpacity
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
onPress={() => onChange?.(!value)}
|
|
34
|
+
style={[
|
|
35
|
+
style,
|
|
36
|
+
styles.container,
|
|
37
|
+
{backgroundColor, alignItems: circleAlign},
|
|
38
|
+
]}>
|
|
39
|
+
<View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
|
|
40
|
+
<View style={[styles.circleSmall, {backgroundColor}]} />
|
|
41
|
+
</View>
|
|
42
|
+
</TouchableOpacity>
|
|
43
|
+
</ScreenContext.Provider>
|
|
31
44
|
);
|
|
32
45
|
};
|
|
33
46
|
|