@momo-kits/foundation 0.81.52 → 0.81.53-beta.0

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.
Files changed (60) hide show
  1. package/Application/BottomSheet.tsx +216 -0
  2. package/Application/BottomTab/BottomTabBar.tsx +278 -0
  3. package/Application/{BottomTab.tsx → BottomTab/index.tsx} +43 -18
  4. package/Application/Components.tsx +71 -53
  5. package/Application/ModalScreen.tsx +12 -183
  6. package/Application/Navigation.ts +2 -2
  7. package/Application/NavigationContainer.tsx +54 -53
  8. package/Application/Navigator.ts +53 -35
  9. package/Application/StackScreen.tsx +225 -30
  10. package/Application/index.ts +8 -12
  11. package/Application/types.ts +45 -27
  12. package/Application/utils.tsx +19 -15
  13. package/Assets/icon_bank.json +1 -1
  14. package/Badge/Badge.tsx +1 -1
  15. package/Button/index.tsx +44 -25
  16. package/CheckBox/index.tsx +37 -26
  17. package/CheckBox/types.ts +5 -3
  18. package/Consts/colors+spacing+radius.ts +14 -0
  19. package/Icon/index.tsx +9 -8
  20. package/Icon/types.ts +2 -2
  21. package/IconButton/index.tsx +24 -14
  22. package/Image/index.tsx +23 -8
  23. package/Image/types.ts +2 -0
  24. package/Input/Input.tsx +116 -26
  25. package/Input/InputDropDown.tsx +66 -51
  26. package/Input/InputMoney.tsx +106 -15
  27. package/Input/InputOTP.tsx +45 -22
  28. package/Input/InputSearch.tsx +92 -44
  29. package/Input/InputTextArea.tsx +26 -6
  30. package/Input/common.tsx +48 -22
  31. package/Input/index.tsx +94 -77
  32. package/Input/styles.ts +35 -5
  33. package/Input/utils.ts +1 -1
  34. package/Layout/Card.tsx +4 -3
  35. package/Layout/FloatingButton.tsx +168 -0
  36. package/Layout/GridSystem.tsx +1 -1
  37. package/Layout/ItemList.tsx +3 -2
  38. package/Layout/Screen.tsx +87 -49
  39. package/Layout/Section.tsx +4 -3
  40. package/Layout/styles.ts +11 -7
  41. package/Layout/utils.ts +4 -4
  42. package/Loader/index.tsx +2 -0
  43. package/Popup/PopupNotify.tsx +55 -44
  44. package/Popup/PopupPromotion.tsx +5 -7
  45. package/Popup/types.ts +1 -7
  46. package/Radio/index.tsx +35 -20
  47. package/Radio/types.ts +5 -3
  48. package/Switch/index.tsx +32 -18
  49. package/Switch/types.ts +5 -3
  50. package/Tag/styles.ts +3 -2
  51. package/Text/index.tsx +24 -5
  52. package/Text/styles.ts +8 -8
  53. package/Title/index.tsx +170 -103
  54. package/Title/styles.ts +36 -9
  55. package/Title/types.ts +16 -48
  56. package/code-scanner.js +125 -16
  57. package/index.ts +7 -0
  58. package/package.json +6 -6
  59. package/publish.sh +16 -21
  60. package/tsconfig.json +1 -1
@@ -1,9 +1,10 @@
1
- import {Animated} from 'react-native';
2
1
  import {StackNavigationOptions} from '@react-navigation/stack';
2
+ import {EventArg} from '@react-navigation/core';
3
3
  import React from 'react';
4
- import Navigator from './Navigator';
4
+ import {Animated, ViewProps} from 'react-native';
5
5
  import {PopupNotifyProps} from '../Popup/types';
6
6
  import Navigation from './Navigation';
7
+ import Navigator from './Navigator';
7
8
 
8
9
  type Screen = React.ComponentType<NavigationScreenProps>;
9
10
 
@@ -70,16 +71,6 @@ export type Context = {
70
71
  translate?: (key: string) => string;
71
72
  };
72
73
 
73
- export type MiniAppInfo = {
74
- [key: string]: any;
75
- code: string;
76
- appId: string;
77
- buildNumber: number;
78
- flowPartnerId?: string;
79
- toolkitConfig?: any;
80
- fromCode?: string;
81
- };
82
-
83
74
  export type LocalizationObject = {
84
75
  vi: {
85
76
  [key: string]: string;
@@ -95,6 +86,7 @@ export type NavigationContainerProps = {
95
86
  theme: Theme;
96
87
  maxApi: any;
97
88
  localization?: LocalizationObject;
89
+ initialParams?: any;
98
90
  };
99
91
 
100
92
  export type NavigationScreenProps = {
@@ -109,18 +101,28 @@ export type ScreenParams = {
109
101
  options?: NavigationOptions;
110
102
  };
111
103
 
112
- export interface ModalParams extends ScreenParams {
104
+ export type ModalParams = {
113
105
  [key: string]: any;
106
+ screen: React.ComponentType;
114
107
  onDismiss?: () => void;
115
108
  barrierDismissible?: boolean;
116
- }
109
+ };
117
110
 
118
- export interface BottomSheetParams extends ScreenParams {
111
+ export type BottomSheetParams = {
119
112
  [key: string]: any;
120
- onDismiss?: () => void;
121
- snapPoint?: '30%' | '50%' | '70%' | '90%' | 'content';
122
- indicatorColor?: string;
123
- }
113
+ screen: React.ComponentType;
114
+ options: {
115
+ title: string;
116
+ surface?: boolean;
117
+ };
118
+ useNativeModal?: boolean;
119
+ surface?: boolean;
120
+ onDismiss?: (type?: string) => void;
121
+ barrierDismissible?: boolean;
122
+ draggable?: boolean;
123
+ useBottomInset?: boolean;
124
+ keyboardVerticalOffset?: number;
125
+ };
124
126
 
125
127
  export type NavigationButtonProps = {
126
128
  icon: string;
@@ -129,6 +131,7 @@ export type NavigationButtonProps = {
129
131
  onPress: () => void;
130
132
  badgeType?: 'dot' | 'number';
131
133
  badgeValue?: number;
134
+ accessibilityLabel?: string;
132
135
  };
133
136
 
134
137
  export type PinnedToolType = {
@@ -152,6 +155,7 @@ export interface NavigationOptions extends StackNavigationOptions {
152
155
  toolkitParams?: {
153
156
  pinnedTool?: PinnedToolType;
154
157
  runtimeTools?: RuntimeToolType[];
158
+ preventClose?: PopupNotifyProps;
155
159
  };
156
160
  }
157
161
 
@@ -162,9 +166,8 @@ export interface HeaderBackProps extends NavigationButtonProps {
162
166
 
163
167
  export type HeaderBackgroundProps = {
164
168
  image?: string | null;
165
- backgroundColor?: string | null;
166
169
  animatedValue?: Animated.Value;
167
- useBorder?: boolean;
170
+ useSurface?: boolean;
168
171
  };
169
172
 
170
173
  export type TitleCustomProps = {
@@ -183,20 +186,25 @@ export type HeaderToolkitProps = {
183
186
  configs: any[];
184
187
  };
185
188
 
186
- export type HeaderAnimatedProps = {
189
+ export interface HeaderAnimatedProps extends ViewProps {
187
190
  animatedValue: Animated.Value;
188
191
  image: string;
189
- onPress?: () => void;
190
- };
192
+ }
191
193
 
192
194
  export type BottomTabItemProps = {
193
195
  name: string;
194
196
  label: string;
195
197
  icon: string;
196
198
  showDot?: boolean;
197
- badgeLabel?: string;
199
+ badgeLabel?: string | number;
198
200
  screen: Screen;
199
201
  options: NavigationOptions;
202
+ initialParams?: any;
203
+ listeners?: {
204
+ tabPress?: (e: EventArg<'tabPress', true, undefined>) => void;
205
+ focus?: (e: EventArg<'focus', false, unknown>) => void;
206
+ blur?: (e: EventArg<'blur', false, unknown>) => void;
207
+ };
200
208
  };
201
209
 
202
210
  export type BottomTabProps = {
@@ -205,12 +213,22 @@ export type BottomTabProps = {
205
213
  initialRouteName?: string;
206
214
  navigation: Navigation;
207
215
  listeners?: {
208
- tabPress?: any;
209
- focus?: any;
216
+ tabPress?: (e: EventArg<'tabPress', true, undefined>) => void;
217
+ focus?: (e: EventArg<'focus', false, unknown>) => void;
218
+ blur?: (e: EventArg<'blur', false, unknown>) => void;
210
219
  };
220
+ floatingButton?: FloatingButtonProps;
221
+ };
222
+
223
+ export type FloatingButtonProps = {
224
+ container?: React.ReactNode;
225
+ icon: string | React.ReactNode;
226
+ label: string;
227
+ onPress: () => void;
211
228
  };
212
229
 
213
230
  export type AnimatedHeader = {
214
231
  type: 'default' | 'surface';
215
232
  component?: (props?: any) => React.ReactElement;
233
+ headerTitle?: (props?: any) => React.ReactElement;
216
234
  };
@@ -94,17 +94,13 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
94
94
  };
95
95
  }
96
96
 
97
- if (typeof params.surface == 'boolean') {
97
+ if (typeof params.surface === 'boolean') {
98
98
  if (params.surface) {
99
99
  options = {
100
100
  ...options,
101
101
  headerTintColor: theme.colors.text.default,
102
102
  headerBackground: () => (
103
- <HeaderBackground
104
- image={null}
105
- backgroundColor={theme.colors.background.surface}
106
- useBorder={true}
107
- />
103
+ <HeaderBackground image={null} useSurface={true} />
108
104
  ),
109
105
  };
110
106
  } else {
@@ -126,19 +122,14 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
126
122
  };
127
123
  }
128
124
 
125
+ if (params.toolkitParams) {
129
126
  options = {
130
127
  ...options,
131
128
  headerRight: (props: any) => {
132
- return (
133
- <HeaderToolkitAction
134
- preventBack={params.preventBack}
135
- pinnedTool={params.toolkitParams?.pinnedTool}
136
- runtimeTools={params.toolkitParams?.runtimeTools}
137
- {...props}
138
- />
139
- );
129
+ return <HeaderToolkitAction {...params.toolkitParams} {...props} />;
140
130
  },
141
131
  };
132
+ }
142
133
 
143
134
  return {
144
135
  ...params,
@@ -146,4 +137,17 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
146
137
  };
147
138
  };
148
139
 
149
- export {getStackOptions, getDialogOptions, getModalOptions, getOptions};
140
+ const formatNameLength = (name = '') => {
141
+ let formattedName = name;
142
+ if (formattedName.length > 100) {
143
+ formattedName = formattedName.substring(0, 100);
144
+ }
145
+ return formattedName;
146
+ };
147
+ export {
148
+ getStackOptions,
149
+ getDialogOptions,
150
+ getModalOptions,
151
+ getOptions,
152
+ formatNameLength,
153
+ };
@@ -503,4 +503,4 @@
503
503
  "zalopay_icon": {
504
504
  "uri": "https://static.momocdn.net/app/img/kits/icon_bank/zalopay_icon.png"
505
505
  }
506
- }
506
+ }
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={'action_xs_bold'}>
49
+ <Text color={Colors.black_01} typography={'action_xxs_bold'}>
50
50
  {formatTitle()}
51
51
  </Text>
52
52
  </View>
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
- useTintColor?: boolean;
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
- useTintColor = true,
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
- if (gradient?.length > 0 && type == 'primary') {
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 color = getTextColor();
220
+ const textColor = getTextColor();
213
221
  return (
214
- <Text typography={typography} color={color} numberOfLines={1}>
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 color = useTintColor ? getTextColor() : undefined;
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={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={color} source={iconLeft} size={iconSize} />
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 color = useTintColor ? getTextColor() : undefined;
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={color} source={iconRight} size={iconSize} />
280
+ <Icon color={textColor} source={iconRight} size={iconSize} />
273
281
  </View>
274
282
  );
275
283
  }
@@ -291,19 +299,30 @@ const Button: FC<ButtonProps> = ({
291
299
  const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
292
300
 
293
301
  return (
294
- <TouchableOpacity
295
- {...rest}
296
- activeOpacity={activeOpacity}
297
- onPress={onPressButton}
298
- style={buttonStyle}>
299
- {renderLeading()}
300
- {renderTitle()}
301
- {renderTrailing()}
302
- {gradientPros && (
303
- <AnimationLinear {...gradientPros} style={styles.gradientView} />
304
- )}
305
- {gradientPros && <View style={styles.strokeView} />}
306
- </TouchableOpacity>
302
+ <ComponentContext.Provider
303
+ value={{
304
+ componentName: 'Button',
305
+ params,
306
+ state: state,
307
+ componentId: accessibilityLabel,
308
+ componentValue: title,
309
+ action: 'click',
310
+ }}>
311
+ <TouchableOpacity
312
+ {...rest}
313
+ accessibilityLabel={accessibilityLabel}
314
+ activeOpacity={activeOpacity}
315
+ onPress={onPressButton}
316
+ style={buttonStyle}>
317
+ {renderLeading()}
318
+ {renderTitle()}
319
+ {renderTrailing()}
320
+ {gradientPros && (
321
+ <AnimationLinear {...gradientPros} style={styles.gradientView} />
322
+ )}
323
+ {gradientPros && <View style={styles.strokeView} />}
324
+ </TouchableOpacity>
325
+ </ComponentContext.Provider>
307
326
  );
308
327
  };
309
328
 
@@ -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
- <TouchableOpacity
39
- activeOpacity={0.8}
40
- onPress={() => onChange?.(!value)}
41
- disabled={disabled}
42
- style={[style, styles.container]}>
43
- <View
44
- style={[
45
- {borderColor, backgroundColor, borderWidth: 1},
46
- styles.checkbox,
47
- ]}>
48
- {haveValue && (
49
- <Icon
50
- color={theme.colors.background.surface}
51
- size={20}
52
- source={iconSource}
53
- />
54
- )}
55
- </View>
56
- {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
57
- </TouchableOpacity>
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 type CheckBoxProps = {
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};
package/Icon/index.tsx CHANGED
@@ -5,7 +5,12 @@ import {IconProps} from './types';
5
5
  import {ApplicationContext} from '../Application';
6
6
  import {Image} from '../Image';
7
7
 
8
- const Icon: React.FC<IconProps> = ({source, size, color, style = {}}) => {
8
+ const Icon: React.FC<IconProps> = ({
9
+ source = 'ic_back',
10
+ size = 24,
11
+ color,
12
+ style = {},
13
+ }) => {
9
14
  const {theme} = useContext(ApplicationContext);
10
15
 
11
16
  /**
@@ -20,22 +25,18 @@ const Icon: React.FC<IconProps> = ({source, size, color, style = {}}) => {
20
25
  };
21
26
 
22
27
  const tintColorProps = color !== null && {
23
- tintColor: color ?? theme.colors.text.default
24
- }
28
+ tintColor: color ?? theme.colors.text.default,
29
+ };
25
30
 
26
31
  return (
27
32
  <Image
28
33
  loading={false}
29
34
  source={getIconSource()}
30
35
  style={[style, {width: size, height: size}]}
36
+ resizeMode="contain"
31
37
  {...tintColorProps}
32
38
  />
33
39
  );
34
40
  };
35
41
 
36
- Icon.defaultProps = {
37
- source: 'ic_back',
38
- size: 24,
39
- };
40
-
41
42
  export {Icon, IconSources, IconBankSources};
package/Icon/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {ImageStyle} from 'react-native-fast-image';
2
+ import {StyleProp} from 'react-native';
2
3
 
3
4
  export type IconProps = {
4
5
  /**
@@ -15,7 +16,6 @@ export type IconProps = {
15
16
 
16
17
  /**
17
18
  * Optional. Represents the color of the icon.
18
- * It can be any valid color in @momo-kits/foundation.
19
19
  */
20
20
  color?: string | null;
21
21
 
@@ -23,5 +23,5 @@ export type IconProps = {
23
23
  * Optional. Used to apply custom styling to the Icon component.
24
24
  * Accepts an object of style properties.
25
25
  */
26
- style?: ImageStyle;
26
+ style?: StyleProp<ImageStyle>;
27
27
  };
@@ -5,7 +5,7 @@ import {
5
5
  TouchableOpacity,
6
6
  TouchableOpacityProps,
7
7
  } from 'react-native';
8
- import {ApplicationContext} from '../Application';
8
+ import {ApplicationContext, ComponentContext} from '../Application';
9
9
  import {Colors} from '../Consts';
10
10
  import {Icon} from '../Icon';
11
11
  import styles from './styles';
@@ -26,13 +26,17 @@ export interface IconButtonProps extends TouchableOpacityProps {
26
26
  * Optional. Defines the size of the IconButton.
27
27
  */
28
28
  size?: 'large' | 'small';
29
+
30
+ params?: any;
29
31
  }
30
32
 
31
33
  const IconButton: React.FC<IconButtonProps> = ({
32
- type,
34
+ type = 'primary',
33
35
  icon,
34
36
  size,
35
37
  onPress,
38
+ params,
39
+ accessibilityLabel,
36
40
  ...rest
37
41
  }) => {
38
42
  const {theme} = useContext(ApplicationContext);
@@ -121,19 +125,25 @@ const IconButton: React.FC<IconButtonProps> = ({
121
125
  const iconSize = size === 'small' ? 16 : 24;
122
126
 
123
127
  return (
124
- <TouchableOpacity
125
- {...rest}
126
- activeOpacity={activeOpacity}
127
- onPress={onPressButton}
128
- style={buttonStyle}>
129
- <Icon size={iconSize} source={icon} color={getIconColor()} />
130
- </TouchableOpacity>
128
+ <ComponentContext.Provider
129
+ value={{
130
+ componentName: 'IconButton',
131
+ params,
132
+ state: type === 'disabled' ? 'disabled' : 'enabled',
133
+ componentId: accessibilityLabel,
134
+ componentValue: icon,
135
+ action: 'click',
136
+ }}>
137
+ <TouchableOpacity
138
+ {...rest}
139
+ accessibilityLabel={accessibilityLabel}
140
+ activeOpacity={activeOpacity}
141
+ onPress={onPressButton}
142
+ style={buttonStyle}>
143
+ <Icon size={iconSize} source={icon} color={getIconColor()} />
144
+ </TouchableOpacity>
145
+ </ComponentContext.Provider>
131
146
  );
132
147
  };
133
148
 
134
- IconButton.defaultProps = {
135
- type: 'primary',
136
- disabled: false,
137
- };
138
-
139
149
  export {IconButton};