@momo-kits/foundation 0.92.2 → 0.92.3-tracking.10

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.
@@ -28,12 +28,12 @@ import {Radius} from '../../Consts';
28
28
  import {Icon} from '../../Icon';
29
29
  import {Text} from '../../Text';
30
30
  import {FloatingButtonProps} from '../types';
31
- import {getAccessibilityID} from '../utils';
32
31
 
33
32
  type Props = BottomTabBarProps & {
34
33
  activeTintColor?: string;
35
34
  inactiveTintColor?: string;
36
35
  floatingButton?: FloatingButtonProps;
36
+ accessibilityLabel?: string;
37
37
  };
38
38
 
39
39
  type Options = {
@@ -317,7 +317,6 @@ export default function BottomTabBar({
317
317
  labelStyle={labelStyle}
318
318
  iconStyle={iconStyle}
319
319
  style={tabStyle}
320
- {...getAccessibilityID(`btn_tabbar_${route.name}`)}
321
320
  />
322
321
  </NavigationRouteContext.Provider>
323
322
  </NavigationContext.Provider>
@@ -9,7 +9,7 @@ import {Text} from '../../Text';
9
9
  import {ApplicationContext} from '../index';
10
10
  import StackScreen from '../StackScreen';
11
11
  import {BottomTabProps, NavigationScreenProps} from '../types';
12
- import {getAccessibilityID, getStackOptions} from '../utils';
12
+ import {getStackOptions} from '../utils';
13
13
  import BottomTabBar from './BottomTabBar';
14
14
 
15
15
  const Tab = createBottomTabNavigator();
@@ -67,8 +67,8 @@ const BottomTab: React.FC<BottomTabProps> = ({
67
67
  backBehavior={'firstRoute'}
68
68
  tabBar={props => (
69
69
  <BottomTabBar
70
- {...getAccessibilityID('tbr_main_bottom')}
71
70
  {...props}
71
+ accessibilityLabel={'BottomTabBar'}
72
72
  floatingButton={floatingButton}
73
73
  />
74
74
  )}
@@ -15,7 +15,7 @@ import {
15
15
  View,
16
16
  ViewStyle,
17
17
  } from 'react-native';
18
- import {ApplicationContext} from './index';
18
+ import {ApplicationContext, MiniAppContext} from './index';
19
19
  import {Colors, Radius, Spacing, Styles} from '../Consts';
20
20
  import {Image} from '../Image';
21
21
  import {
@@ -29,11 +29,6 @@ import {scaleSize, Text} from '../Text';
29
29
  import {Icon} from '../Icon';
30
30
  import {PopupNotify} from '../Popup';
31
31
  import {Badge, BadgeDot} from '../Badge';
32
- import {getAccessibilityID} from './utils';
33
-
34
- const {
35
- MiniAppContext,
36
- } = require('react-native/Libraries/Components/ScreenContext');
37
32
 
38
33
  const NavigationButton: React.FC<NavigationButtonProps> = ({
39
34
  icon,
@@ -42,7 +37,7 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
42
37
  useBorder = true,
43
38
  badgeType,
44
39
  badgeValue,
45
- accessibilityID = '',
40
+ accessibilityLabel = '',
46
41
  }) => {
47
42
  const {theme} = useContext(ApplicationContext);
48
43
  let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
@@ -70,10 +65,9 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
70
65
  }, [badgeType, badgeValue]);
71
66
 
72
67
  return (
73
- <View
74
- {...getAccessibilityID(accessibilityID)}
75
- style={{width: scaleSize(28)}}>
68
+ <View style={{width: scaleSize(28)}}>
76
69
  <TouchableOpacity
70
+ accessibilityLabel={accessibilityLabel}
77
71
  style={[styles.navigationButton, buttonStyle]}
78
72
  onPress={onPress}>
79
73
  <Icon
@@ -98,7 +92,7 @@ const HeaderTitle: React.FC<any> = props => {
98
92
  return (
99
93
  <Animated.Text
100
94
  {...props}
101
- {...getAccessibilityID('title_navigation_header')}
95
+ accessibilityLabel={'title_navigation_header'}
102
96
  style={[
103
97
  styles.title,
104
98
  {fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
@@ -127,26 +121,25 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
127
121
 
128
122
  const goBackSafe = () => {
129
123
  const goBack = () => {
130
- const canGoBack = navigator?.ref.current?.canGoBack();
131
- if (!canGoBack) {
132
- const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
133
- const params = {
134
- ...context,
135
- screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
136
- trigger_id: '111154000000000000',
137
- icon_name: 'back',
138
- };
139
- navigator?.maxApi?.showToastDebug?.({
140
- appId: `auto - ${context.appId}`,
141
- message: 'service_icon_clicked',
142
- params,
143
- });
144
- navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
145
- }
124
+ const canGoBack = navigator?.ref?.current?.canGoBack?.();
125
+ const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
126
+ const params = {
127
+ appId: context.appId,
128
+ code: context.code,
129
+ screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
130
+ trigger_id: '111154000000000000',
131
+ icon_name: 'back',
132
+ };
133
+ navigator?.maxApi?.showToastDebug?.({
134
+ appId: `auto - ${context.appId}`,
135
+ message: 'service_icon_clicked',
136
+ params,
137
+ });
138
+ navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
146
139
  if (canGoBack) {
147
- navigator?.ref.current?.goBack();
140
+ navigator?.ref?.current?.goBack?.();
148
141
  } else if (navigator?.maxApi) {
149
- navigator?.maxApi?.dismiss(navigator.dismissData);
142
+ navigator?.maxApi?.dismiss?.(navigator?.dismissData);
150
143
  } else {
151
144
  const currentTime = new Date().getTime();
152
145
  const requestId = `navigationBackPress#${currentTime}`;
@@ -178,7 +171,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
178
171
  return (
179
172
  <View style={styles.headerLeft}>
180
173
  <NavigationButton
181
- accessibilityID="btn_navigation_back"
174
+ accessibilityLabel="btn_navigation_back"
182
175
  icon="ic_back"
183
176
  tintColor={tintColor}
184
177
  onPress={goBackSafe}
@@ -253,7 +246,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
253
246
  </View>
254
247
  <View style={[Styles.flex, {paddingHorizontal: 8}]}>
255
248
  <Text
256
- {...getAccessibilityID('title_navigation_header')}
249
+ accessibilityLabel={'title_navigation_header'}
257
250
  typography="header_default_bold"
258
251
  color={tintColor}>
259
252
  {title}
@@ -381,7 +374,7 @@ const HeaderToolkitAction: React.FC<any> = ({
381
374
  if (pinTool)
382
375
  return (
383
376
  <NavigationButton
384
- accessibilityID="btn_navigation_pin"
377
+ accessibilityLabel="btn_navigation_pin"
385
378
  icon={pinTool.icon as string}
386
379
  tintColor={tintColor}
387
380
  badgeValue={badgeValue}
@@ -412,13 +405,13 @@ const HeaderToolkitAction: React.FC<any> = ({
412
405
  },
413
406
  ]}>
414
407
  <TouchableOpacity
415
- {...getAccessibilityID('btn_navigation_more')}
408
+ accessibilityLabel={'btn_navigation_more'}
416
409
  onPress={onMore}>
417
410
  <Icon color={tintColor} source="navigation_more_horiz" size={20} />
418
411
  </TouchableOpacity>
419
412
  <View style={[styles.divider, {backgroundColor: tintColor}]} />
420
413
  <TouchableOpacity
421
- {...getAccessibilityID('btn_navigation_close')}
414
+ accessibilityLabel={'btn_navigation_close'}
422
415
  onPress={onClose}>
423
416
  <Icon
424
417
  color={tintColor}
@@ -1,4 +1,4 @@
1
- import React, {useContext, useEffect, useRef, useState} from 'react';
1
+ import React, {useEffect, useRef, useState} from 'react';
2
2
  import {SafeAreaProvider} from 'react-native-safe-area-context';
3
3
  import {
4
4
  NavigationContainer as ReactNavigationContainer,
@@ -15,10 +15,6 @@ import {LocalizationObject, NavigationContainerProps} from './types';
15
15
  import {ApplicationContext} from './index';
16
16
  import kitLocalization from '../Assets/language.json';
17
17
 
18
- const {
19
- MiniAppContext,
20
- } = require('react-native/Libraries/Components/ScreenContext');
21
-
22
18
  /**
23
19
  * link for deprecated
24
20
  */
@@ -35,7 +31,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
35
31
  localization,
36
32
  initialParams,
37
33
  }) => {
38
- const context = useContext<any>(MiniAppContext);
39
34
  const navigationRef = useRef<NavigationContainerRef>(null);
40
35
  const isReady = useRef(false);
41
36
  const navigator = useRef(new Navigator(navigationRef, isReady));
@@ -69,7 +64,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
69
64
  * @param key
70
65
  */
71
66
  const translate = (key: string) => {
72
- const language: 'vi' | 'en' = context?.language ?? 'vi';
67
+ const language: 'vi' | 'en' = 'vi';
73
68
  const mergedLocalization: LocalizationObject = {
74
69
  vi: {...localization?.vi, ...kitLocalization.vi},
75
70
  en: {...localization?.en, ...kitLocalization.en},
@@ -1,23 +1,25 @@
1
1
  import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
2
2
  import {ScreenParams} from './types';
3
3
  import Navigation from './Navigation';
4
- import {ApplicationContext} from './index';
4
+ import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
5
5
  import {GridSystem} from '../Layout';
6
6
  import {useHeaderHeight} from '@react-navigation/stack';
7
7
  import {Alert, InteractionManager} from 'react-native';
8
8
 
9
- const {
10
- ScreenContext,
11
- MiniAppContext,
12
- } = require('react-native/Libraries/Components/ScreenContext');
13
-
14
9
  const StackScreen: React.FC<ScreenParams> = props => {
15
10
  const {theme, showGrid, navigator} = useContext(ApplicationContext);
16
11
  const startTime = useRef(Date.now());
17
12
  const endTime = useRef(Date.now());
18
13
  const timeLoad = useRef(0);
19
- const timeout = useRef<any>();
20
-
14
+ const timeInteraction = useRef(0);
15
+ const timeoutLoad = useRef<any>();
16
+ const tracked = useRef<any>({
17
+ releaseLoad: undefined,
18
+ releaseInteraction: undefined,
19
+ timeoutLoad: undefined,
20
+ timeoutInteraction: undefined,
21
+ });
22
+ const interaction = useRef<any>();
21
23
  const context = useContext<any>(MiniAppContext);
22
24
 
23
25
  const {screen: Component, options, initialParams} = props.route.params;
@@ -39,16 +41,6 @@ const StackScreen: React.FC<ScreenParams> = props => {
39
41
  * set options for screen
40
42
  */
41
43
  useLayoutEffect(() => {
42
- const host = (global as any).miniAppApi?.currentHost || {};
43
- host.screenName = screenName;
44
- InteractionManager.runAfterInteractions(() => {
45
- navigator?.maxApi?.showToastDebug?.({
46
- appId: `auto - ${context.appId}`,
47
- message: `${screenName} screen_interaction_time ${
48
- Date.now() - startTime.current
49
- }`,
50
- });
51
- });
52
44
  if (options) {
53
45
  navigation.setOptions(options);
54
46
  }
@@ -58,73 +50,86 @@ const StackScreen: React.FC<ScreenParams> = props => {
58
50
  * tracking for screen
59
51
  */
60
52
  useEffect(() => {
61
- if (__DEV__) {
62
- if (!screenName || screenName === 'screen') {
63
- Alert.alert(
64
- 'Design system',
65
- `Unvalidated screen name "${screenName}" !`,
66
- );
67
- }
53
+ if (__DEV__ && (!screenName || screenName == 'Invalid')) {
54
+ Alert.alert('Design system', `Unvalidated screen name "${screenName}" !`);
68
55
  }
69
56
 
70
- const tracking = {
71
- ...context,
72
- screen_name: screenName,
57
+ navigator?.maxApi?.of?.({screenName});
58
+
59
+ tracked.current.timeoutLoad = setTimeout(() => {
60
+ onScreenLoad();
61
+ }, 5000);
62
+ tracked.current.timeoutInteraction = setTimeout(() => {
63
+ onScreenInteraction();
64
+ }, 5000);
65
+ return () => {
66
+ onScreenLoad();
67
+ onScreenInteraction();
73
68
  };
69
+ }, []);
74
70
 
75
- const routes = props.navigation.getState()?.routes || [];
76
- const routesLength = routes.length;
77
- let pre_screen_name = '';
78
- if (routesLength > 1) {
79
- pre_screen_name = routes[routesLength - 2]?.params?.screen?.name;
71
+ /**
72
+ * tracking for screen load
73
+ */
74
+ const onScreenLoad = () => {
75
+ clearTimeout(tracked.current.timeoutLoad);
76
+ if (!tracked.current?.releaseLoad) {
77
+ navigator?.maxApi?.dispatchFunction?.('autoTracking', {
78
+ appId: context.appId,
79
+ code: context.code,
80
+ screenName,
81
+ componentName: 'Screen',
82
+ state: 'load',
83
+ time: timeLoad.current,
84
+ });
85
+ navigator?.maxApi?.showToastDebug?.({
86
+ appId: `auto - ${context.appId}`,
87
+ message: `${screenName} screen_load_time ${timeLoad.current}`,
88
+ });
89
+ tracked.current.releaseLoad = true;
80
90
  }
91
+ };
81
92
 
82
- const params = {
83
- ...tracking,
84
- pre_screen_name,
85
- trigger_id: '111378000000000000',
86
- };
87
- navigator?.maxApi?.trackEvent?.('service_frame_displayed', params);
88
- navigator?.maxApi?.showToastDebug?.({
89
- appId: `auto - ${context.appId}`,
90
- message: `${screenName} service_frame_displayed`,
91
- params,
92
- });
93
+ /**
94
+ * tracking for screen load
95
+ */
96
+ const onScreenInteraction = () => {
97
+ clearTimeout(tracked.current.timeoutInteraction);
98
+ if (!tracked.current?.releaseInteraction) {
99
+ navigator?.maxApi?.dispatchFunction?.('autoTracking', {
100
+ appId: context.appId,
101
+ code: context.code,
102
+ screenName,
103
+ componentName: 'Screen',
104
+ state: 'interaction',
105
+ time: timeInteraction.current,
106
+ });
93
107
 
94
- return props.navigation.addListener('beforeRemove', () => {
95
- const params = {
96
- ...tracking,
97
- trigger_id: '111154000000000000',
98
- icon_name: 'back',
99
- };
100
- navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
101
108
  navigator?.maxApi?.showToastDebug?.({
102
109
  appId: `auto - ${context.appId}`,
103
- message: `${screenName} service_icon_clicked`,
104
- params,
110
+ message: `${screenName} screen_interaction_time ${timeInteraction.current}`,
105
111
  });
106
- });
107
- }, []);
112
+ tracked.current.releaseInteraction = true;
113
+ }
114
+ };
108
115
 
109
116
  return (
110
117
  <ScreenContext.Provider
111
118
  value={{
112
- appId: context.appId,
113
- code: context.code,
114
119
  screenName,
115
120
  autoTracking: (data: any) => {
116
121
  navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
117
122
  },
118
123
  onElementLoad: () => {
119
124
  endTime.current = Date.now();
120
- clearTimeout(timeout.current);
121
- timeout.current = setTimeout(() => {
125
+ interaction.current?.cancel?.();
126
+ interaction.current = InteractionManager.runAfterInteractions(() => {
127
+ timeInteraction.current = Date.now() - startTime.current;
128
+ });
129
+ clearTimeout(timeoutLoad.current);
130
+ timeoutLoad.current = setTimeout(() => {
122
131
  if (timeLoad.current === 0) {
123
132
  timeLoad.current = endTime.current - startTime.current;
124
- navigator?.maxApi?.showToastDebug?.({
125
- appId: `auto - ${context.appId}`,
126
- message: `${screenName} screen_load_time ${timeLoad.current}`,
127
- });
128
133
  }
129
134
  }, 2000);
130
135
  },
@@ -132,7 +137,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
132
137
  <Component
133
138
  heightHeader={heightHeader}
134
139
  {...data}
135
- onScreenLoad={() => {}}
140
+ onScreenLoad={onScreenLoad}
141
+ onScreenInteraction={onScreenInteraction}
136
142
  />
137
143
  {showGrid && <GridSystem />}
138
144
  </ScreenContext.Provider>
@@ -1,3 +1,4 @@
1
+ import {Platform} from 'react-native';
1
2
  import {NavigationContainer} from './NavigationContainer';
2
3
  import Screen from '../Layout/Screen';
3
4
  import {
@@ -11,20 +12,19 @@ import {
11
12
  import BottomTab from './BottomTab';
12
13
  import {createContext} from 'react';
13
14
  import {defaultContext} from '../Consts';
14
- import {MiniAppInfo} from './types';
15
15
 
16
+ const Context = createContext({});
16
17
  const ApplicationContext = createContext(defaultContext);
17
- const MiniAppContext = createContext<MiniAppInfo>({
18
- appId: '',
19
- buildNumber: 0,
20
- code: '',
21
- toolkitConfig: {},
22
- fromCode: '',
23
- });
18
+
19
+ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
20
+ const ScreenContext = (Platform as any).ScreenContext ?? Context;
21
+ const ComponentContext = (Platform as any).ComponentContext ?? Context;
24
22
 
25
23
  export {
26
24
  ApplicationContext,
27
25
  MiniAppContext,
26
+ ScreenContext,
27
+ ComponentContext,
28
28
  NavigationContainer,
29
29
  Screen,
30
30
  BottomTab,
@@ -130,7 +130,7 @@ export type NavigationButtonProps = {
130
130
  onPress: () => void;
131
131
  badgeType?: 'dot' | 'number';
132
132
  badgeValue?: number;
133
- accessibilityID?: string;
133
+ accessibilityLabel?: string;
134
134
  };
135
135
 
136
136
  export type PinnedToolType = {
@@ -158,41 +158,6 @@ const getAccessibilityID = (
158
158
  }
159
159
  };
160
160
 
161
- const cleanNameForTracking = (word = ''): string => {
162
- return word
163
- .normalize('NFD')
164
- .replace(/[\u0300-\u036f |\s]/g, '')
165
- .toLowerCase();
166
- };
167
-
168
- const formatComponentName = (word = '') => {
169
- const accentsMap = {
170
- a: 'á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ẫ|ậ|ă|ắ|ằ|ẳ|ẵ|ặ',
171
- A: 'Á|À|Ả|Ã|Ạ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ',
172
- e: 'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
173
- E: 'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
174
- i: 'í|ì|ỉ|ĩ|ị',
175
- I: 'Í|Ì|Ỉ|Ĩ|Ị',
176
- o: 'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
177
- O: 'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
178
- u: 'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
179
- U: 'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
180
- y: 'ý|ỳ|ỷ|ỹ|ỵ',
181
- Y: 'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
182
- d: 'đ',
183
- D: 'Đ',
184
- };
185
-
186
- for (const [nonAccent, accentGroup] of Object.entries(accentsMap)) {
187
- const accents = new RegExp(accentGroup, 'g');
188
- word = word.replace(accents, nonAccent);
189
- }
190
-
191
- word = word.replace(/\s+/g, '_').toLowerCase();
192
-
193
- return word;
194
- };
195
-
196
161
  const formatNameLength = (name = '') => {
197
162
  let formattedName = name;
198
163
  if (formattedName.length > 100) {
@@ -205,8 +170,6 @@ export {
205
170
  getDialogOptions,
206
171
  getModalOptions,
207
172
  getOptions,
208
- formatComponentName,
209
173
  formatNameLength,
210
174
  getAccessibilityID,
211
- cleanNameForTracking,
212
175
  };
package/Button/index.tsx CHANGED
@@ -7,23 +7,13 @@ import {
7
7
  View,
8
8
  } from 'react-native';
9
9
  import LinearGradient from 'react-native-linear-gradient';
10
- import {ApplicationContext} from '../Application';
10
+ import {ApplicationContext, ComponentContext} from '../Application';
11
11
  import {Text} from '../Text';
12
12
  import {Typography} from '../Text/types';
13
13
  import {Colors, Spacing} from '../Consts';
14
14
  import styles from './styles';
15
15
  import {Icon} from '../Icon';
16
16
  import {Loader} from '../Loader';
17
- import {
18
- cleanNameForTracking,
19
- formatComponentName,
20
- getAccessibilityID,
21
- } from '../Application/utils';
22
-
23
- const {
24
- ScreenContext,
25
- MiniAppContext,
26
- } = require('react-native/Libraries/Components/ScreenContext');
27
17
 
28
18
  const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
29
19
 
@@ -81,8 +71,6 @@ export interface ButtonProps extends TouchableOpacityProps {
81
71
  onPress: () => void;
82
72
 
83
73
  params?: any;
84
-
85
- componentId?: string;
86
74
  }
87
75
 
88
76
  const Button: FC<ButtonProps> = ({
@@ -96,14 +84,16 @@ const Button: FC<ButtonProps> = ({
96
84
  title = 'Button',
97
85
  onPress,
98
86
  params,
99
- componentId,
100
87
  accessibilityLabel,
101
88
  ...rest
102
89
  }) => {
103
90
  const {theme, config} = useContext(ApplicationContext);
104
- const {appId, code} = useContext<any>(MiniAppContext);
105
91
  const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
106
92
  let gradientPros;
93
+ let state = 'enabled';
94
+ if (loading) {
95
+ state = 'loading';
96
+ }
107
97
  if (gradient?.length > 0 && type == 'primary') {
108
98
  gradientPros = {
109
99
  colors: gradient,
@@ -112,7 +102,6 @@ const Button: FC<ButtonProps> = ({
112
102
  };
113
103
  }
114
104
 
115
- const screenInfo = useContext<any>(ScreenContext);
116
105
  const getSizeStyle = () => {
117
106
  const styleSheet: {[key: string]: any} = styles;
118
107
  return styleSheet[size ?? 'small'];
@@ -310,28 +299,18 @@ const Button: FC<ButtonProps> = ({
310
299
  const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
311
300
 
312
301
  return (
313
- <ScreenContext.Provider
302
+ <ComponentContext.Provider
314
303
  value={{
315
- ...screenInfo,
316
304
  componentName: 'Button',
317
305
  params,
318
- state: loading
319
- ? 'loading'
320
- : type === 'disabled'
321
- ? 'disabled'
322
- : 'enabled',
323
- componentId,
324
- componentValue: formatComponentName(title),
306
+ state: state,
307
+ componentId: accessibilityLabel,
308
+ componentValue: title,
325
309
  action: 'click',
326
310
  }}>
327
311
  <TouchableOpacity
328
312
  {...rest}
329
- {...getAccessibilityID(
330
- `${appId}/${code}/${screenInfo.screenName}/btn_${cleanNameForTracking(
331
- title,
332
- )}`,
333
- accessibilityLabel,
334
- )}
313
+ accessibilityLabel={accessibilityLabel}
335
314
  activeOpacity={activeOpacity}
336
315
  onPress={onPressButton}
337
316
  style={buttonStyle}>
@@ -343,7 +322,7 @@ const Button: FC<ButtonProps> = ({
343
322
  )}
344
323
  {gradientPros && <View style={styles.strokeView} />}
345
324
  </TouchableOpacity>
346
- </ScreenContext.Provider>
325
+ </ComponentContext.Provider>
347
326
  );
348
327
  };
349
328
 
@@ -2,33 +2,22 @@ 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 {
9
- cleanNameForTracking,
10
- formatNameLength,
11
- getAccessibilityID,
12
- } from '../Application/utils';
13
-
14
- const {
15
- ScreenContext,
16
- MiniAppContext,
17
- } = require('react-native/Libraries/Components/ScreenContext');
8
+ import {formatNameLength} from '../Application/utils';
18
9
 
19
10
  const CheckBox: FC<CheckBoxProps> = ({
20
11
  value,
21
- disabled,
12
+ disabled = false,
22
13
  onChange,
23
14
  style,
24
15
  label,
25
16
  indeterminate,
26
17
  params,
27
- componentId,
18
+ accessibilityLabel,
28
19
  }) => {
29
- const {appId, code} = useContext<any>(MiniAppContext);
30
20
  const {theme} = useContext(ApplicationContext);
31
- const screenInfo = useContext<any>(ScreenContext);
32
21
  const haveValue = value || indeterminate;
33
22
  const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
34
23
  let borderColor = theme.colors.text.default;
@@ -48,26 +37,19 @@ const CheckBox: FC<CheckBoxProps> = ({
48
37
  }
49
38
  }
50
39
 
51
- const accessibilityID = getAccessibilityID(
52
- `${appId}/${code}/${screenInfo.screenName}/cbx_${cleanNameForTracking(
53
- label,
54
- )}_${indeterminate ? 'na' : value}`,
55
- );
56
-
57
40
  return (
58
- <ScreenContext.Provider
41
+ <ComponentContext.Provider
59
42
  value={{
60
- ...screenInfo,
61
- componentName: 'Button',
43
+ componentName: 'CheckBox',
62
44
  params,
63
45
  state: disabled ? 'disabled' : 'filled',
64
- componentId,
46
+ componentId: accessibilityLabel,
65
47
  action: 'click',
66
48
  componentLabel: formatNameLength(label || ''),
67
- componentValue: indeterminate ? 'indetermine' : value,
49
+ componentValue: indeterminate ? 'undetermined' : value,
68
50
  }}>
69
51
  <TouchableOpacity
70
- {...accessibilityID}
52
+ accessibilityLabel={accessibilityLabel}
71
53
  activeOpacity={0.8}
72
54
  onPress={() => onChange?.(!value)}
73
55
  disabled={disabled}
@@ -87,12 +69,8 @@ const CheckBox: FC<CheckBoxProps> = ({
87
69
  </View>
88
70
  {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
89
71
  </TouchableOpacity>
90
- </ScreenContext.Provider>
72
+ </ComponentContext.Provider>
91
73
  );
92
74
  };
93
75
 
94
- CheckBox.defaultProps = {
95
- disabled: false,
96
- };
97
-
98
76
  export {CheckBox};