@momo-kits/foundation 0.92.2-tracking.4 → 0.92.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/Components.tsx +18 -17
- package/Application/NavigationContainer.tsx +7 -2
- package/Application/StackScreen.tsx +56 -67
- package/Button/index.tsx +28 -12
- package/CheckBox/index.tsx +27 -9
- package/CheckBox/types.ts +6 -4
- package/Icon/index.tsx +8 -8
- package/IconButton/index.tsx +15 -7
- package/Image/index.tsx +7 -18
- package/Image/types.ts +0 -1
- package/Input/Input.tsx +30 -7
- package/Input/InputDropDown.tsx +28 -7
- package/Input/InputMoney.tsx +26 -7
- package/Input/InputOTP.tsx +22 -7
- package/Input/InputSearch.tsx +13 -6
- package/Input/InputTextArea.tsx +20 -3
- package/Input/index.tsx +9 -1
- package/Popup/PopupNotify.tsx +1 -2
- package/Popup/PopupPromotion.tsx +5 -2
- package/Radio/index.tsx +21 -7
- package/Radio/types.ts +7 -4
- package/Switch/index.tsx +22 -14
- package/Switch/types.ts +6 -4
- package/package.json +1 -1
package/Switch/index.tsx
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
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
|
+
import {getAccessibilityID} from '../Application/utils';
|
|
6
7
|
|
|
7
8
|
const {
|
|
8
|
-
|
|
9
|
+
ScreenContext,
|
|
10
|
+
MiniAppContext,
|
|
9
11
|
} = require('react-native/Libraries/Components/ScreenContext');
|
|
10
12
|
|
|
11
|
-
const Switch: FC<SwitchProps> =
|
|
12
|
-
|
|
13
|
-
onChange,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
params,
|
|
17
|
-
accessibilityLabel,
|
|
18
|
-
}) => {
|
|
13
|
+
const Switch: FC<SwitchProps> = props => {
|
|
14
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
15
|
+
const {value, onChange, disabled, style, params, componentId} = props;
|
|
16
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
17
|
+
|
|
19
18
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
20
19
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
21
20
|
|
|
@@ -24,19 +23,24 @@ const Switch: FC<SwitchProps> = ({
|
|
|
24
23
|
backgroundColor = value ? Colors.green_09 : Colors.black_05;
|
|
25
24
|
}
|
|
26
25
|
|
|
26
|
+
const accessibilityID = getAccessibilityID?.(
|
|
27
|
+
`${appId}/${code}/${screenInfo.screenName}/swt_${value}`,
|
|
28
|
+
);
|
|
29
|
+
|
|
27
30
|
return (
|
|
28
|
-
<
|
|
31
|
+
<ScreenContext.Provider
|
|
29
32
|
value={{
|
|
33
|
+
...screenInfo,
|
|
30
34
|
componentName: 'Button',
|
|
31
35
|
params,
|
|
32
36
|
state: disabled ? 'disabled' : 'enabled',
|
|
33
|
-
componentId
|
|
37
|
+
componentId,
|
|
34
38
|
componentValue: value,
|
|
35
39
|
action: 'click',
|
|
36
40
|
}}>
|
|
37
41
|
<TouchableOpacity
|
|
42
|
+
{...accessibilityID}
|
|
38
43
|
disabled={disabled}
|
|
39
|
-
accessibilityLabel={accessibilityLabel}
|
|
40
44
|
onPress={() => onChange?.(!value)}
|
|
41
45
|
style={[
|
|
42
46
|
style,
|
|
@@ -47,8 +51,12 @@ const Switch: FC<SwitchProps> = ({
|
|
|
47
51
|
<View style={[styles.circleSmall, {backgroundColor}]} />
|
|
48
52
|
</View>
|
|
49
53
|
</TouchableOpacity>
|
|
50
|
-
</
|
|
54
|
+
</ScreenContext.Provider>
|
|
51
55
|
);
|
|
52
56
|
};
|
|
53
57
|
|
|
58
|
+
Switch.defaultProps = {
|
|
59
|
+
value: false,
|
|
60
|
+
disabled: false,
|
|
61
|
+
};
|
|
54
62
|
export {Switch};
|
package/Switch/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type SwitchProps = {
|
|
4
4
|
/**
|
|
5
5
|
* `value`: Represents whether the Switch component is currently in the 'on' (`true`) or 'off' (`false`) state.
|
|
6
6
|
*/
|
|
@@ -24,5 +24,7 @@ export interface SwitchProps extends TouchableOpacityProps {
|
|
|
24
24
|
*/
|
|
25
25
|
style?: ViewStyle;
|
|
26
26
|
|
|
27
|
-
params?: any
|
|
28
|
-
|
|
27
|
+
params?: any
|
|
28
|
+
|
|
29
|
+
componentId?: string
|
|
30
|
+
};
|