@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/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
- ComponentContext,
9
+ ScreenContext,
10
+ MiniAppContext,
9
11
  } = require('react-native/Libraries/Components/ScreenContext');
10
12
 
11
- const Switch: FC<SwitchProps> = ({
12
- value = false,
13
- onChange,
14
- disabled = false,
15
- style,
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
- <ComponentContext.Provider
31
+ <ScreenContext.Provider
29
32
  value={{
33
+ ...screenInfo,
30
34
  componentName: 'Button',
31
35
  params,
32
36
  state: disabled ? 'disabled' : 'enabled',
33
- componentId: accessibilityLabel,
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
- </ComponentContext.Provider>
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 {TouchableOpacityProps, ViewStyle} from 'react-native';
1
+ import {ViewStyle} from 'react-native';
2
2
 
3
- export interface SwitchProps extends TouchableOpacityProps {
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.2-tracking.4",
3
+ "version": "0.92.2",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {