@momo-kits/native-kits 0.89.30-rc.4 → 0.89.30-rc.6

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.
@@ -3,7 +3,6 @@ package vn.momo.kits.components
3
3
  import androidx.compose.foundation.background
4
4
  import androidx.compose.foundation.border
5
5
  import androidx.compose.foundation.clickable
6
- import androidx.compose.foundation.interaction.MutableInteractionSource
7
6
  import androidx.compose.foundation.layout.Arrangement
8
7
  import androidx.compose.foundation.layout.Box
9
8
  import androidx.compose.foundation.layout.Row
@@ -13,14 +12,15 @@ import androidx.compose.foundation.layout.height
13
12
  import androidx.compose.foundation.layout.padding
14
13
  import androidx.compose.foundation.layout.size
15
14
  import androidx.compose.foundation.shape.RoundedCornerShape
16
- import androidx.compose.material.ripple.rememberRipple
17
15
  import androidx.compose.material3.CircularProgressIndicator
18
16
  import androidx.compose.runtime.Composable
19
- import androidx.compose.runtime.remember
20
17
  import androidx.compose.ui.Alignment
21
18
  import androidx.compose.ui.Modifier
22
19
  import androidx.compose.ui.draw.clip
23
20
  import androidx.compose.ui.graphics.Color
21
+ import androidx.compose.ui.semantics.contentDescription
22
+ import androidx.compose.ui.semantics.semantics
23
+ import androidx.compose.ui.semantics.testTag
24
24
  import androidx.compose.ui.text.TextStyle
25
25
  import androidx.compose.ui.text.style.TextOverflow
26
26
  import androidx.compose.ui.unit.Dp
@@ -221,9 +221,6 @@ fun getTypeStyle(
221
221
  * @param iconLeft [String] the icon at the left of title
222
222
  * @param title [String] title of button
223
223
  * @param loading [Boolean] used when you want to use loading animation
224
- * @param enabled controls the enabled state of this button. When `false`,
225
- * this component will not respond to user input, and it will appear
226
- * visually disabled and disabled to accessibility services.
227
224
  * @param useTintColor [Boolean] controls color of the icon.
228
225
  */
229
226
  @Composable
@@ -235,23 +232,23 @@ fun Button(
235
232
  iconLeft: String = "",
236
233
  title: String = "Button",
237
234
  loading: Boolean = false,
238
- enabled: Boolean = true,
239
235
  useTintColor: Boolean = true,
240
236
  isFull: Boolean = true,
241
237
  modifier: Modifier = Modifier,
242
238
  ) {
239
+ val testId = "btn_${type.toString().lowercase()}_$title"
243
240
  val customModifier = if (isFull) {
244
241
  modifier
245
242
  .fillMaxWidth()
246
243
  .clip(RoundedCornerShape(size.value.radius)).clickable(
247
- enabled = enabled,
244
+ enabled = type != ButtonType.DISABLED,
248
245
  onClick = onClick
249
246
  )
250
247
 
251
248
  } else {
252
249
  modifier
253
250
  .clip(RoundedCornerShape(size.value.radius)).clickable(
254
- enabled = enabled,
251
+ enabled = type != ButtonType.DISABLED,
255
252
  onClick = onClick
256
253
  )
257
254
  }
@@ -261,7 +258,10 @@ fun Button(
261
258
  .padding(horizontal = size.value.padding)
262
259
  .defaultMinSize(
263
260
  minWidth = size.value.width
264
- ).height(size.value.height),
261
+ ).height(size.value.height)
262
+ .semantics {
263
+ contentDescription = testId; testTag = testId
264
+ },
265
265
  horizontalArrangement = Arrangement.Center,
266
266
  verticalAlignment = Alignment.CenterVertically,
267
267
  ) {
@@ -110,7 +110,7 @@ fun IconButton(
110
110
  .then(getIconStyle(type))
111
111
  .clip(RoundedCornerShape(size.value.radius))
112
112
  .clickable(
113
- enabled = type == ButtonType.DISABLED,
113
+ enabled = type != ButtonType.DISABLED,
114
114
  onClick = onClick
115
115
  ),
116
116
  contentAlignment = Alignment.Center
@@ -36,7 +36,6 @@ fun Image(
36
36
  options: Options? = null,
37
37
  loading: Boolean = true,
38
38
  ) {
39
- modifier.semantics {contentDescription = "img|$source"; testTag = "img|$source"}
40
39
  var imageOptions = Options()
41
40
  var imageState by remember { mutableStateOf(ImageState.Loading) }
42
41
 
@@ -51,7 +50,7 @@ fun Image(
51
50
 
52
51
  Box(modifier = modifier) {
53
52
  AsyncImage(
54
- modifier = modifier,
53
+ modifier = Modifier.matchParentSize().semantics {contentDescription = "img|$source"; testTag = "img|$source"},
55
54
  model = source,
56
55
  contentDescription = null,
57
56
  contentScale = imageOptions.contentScale,
@@ -29,6 +29,9 @@ import androidx.compose.ui.Alignment
29
29
  import androidx.compose.ui.Modifier
30
30
  import androidx.compose.ui.focus.onFocusChanged
31
31
  import androidx.compose.ui.graphics.Color
32
+ import androidx.compose.ui.semantics.contentDescription
33
+ import androidx.compose.ui.semantics.semantics
34
+ import androidx.compose.ui.semantics.testTag
32
35
  import androidx.compose.ui.text.TextStyle
33
36
  import androidx.compose.ui.text.font.FontWeight
34
37
  import androidx.compose.ui.text.input.KeyboardType
@@ -198,7 +201,11 @@ fun Input(
198
201
  iconTintColor = disabledColor
199
202
  }
200
203
 
201
- Column {
204
+ val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
205
+
206
+ Column(modifier = Modifier.semantics {
207
+ contentDescription = testId; testTag = testId
208
+ }) {
202
209
  BasicTextField(
203
210
  enabled = !disabled,
204
211
  readOnly = readOnly,
@@ -21,6 +21,9 @@ import androidx.compose.runtime.setValue
21
21
  import androidx.compose.ui.Alignment
22
22
  import androidx.compose.ui.Modifier
23
23
  import androidx.compose.ui.graphics.Color
24
+ import androidx.compose.ui.semantics.contentDescription
25
+ import androidx.compose.ui.semantics.semantics
26
+ import androidx.compose.ui.semantics.testTag
24
27
  import androidx.compose.ui.text.TextStyle
25
28
  import androidx.compose.ui.unit.dp
26
29
  import androidx.compose.ui.unit.sp
@@ -51,7 +54,7 @@ fun InputDropDown(
51
54
  loading: Boolean = false,
52
55
  required: Boolean = false,
53
56
  ) {
54
- var isFocused by remember { mutableStateOf(false) }
57
+ val isFocused by remember { mutableStateOf(false) }
55
58
 
56
59
  val disabledColor = AppTheme.current.colors.text.disable
57
60
  var textColor = AppTheme.current.colors.text.default
@@ -72,8 +75,11 @@ fun InputDropDown(
72
75
  iconTintColor = disabledColor
73
76
  }
74
77
 
78
+ val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
75
79
 
76
- Column(modifier = Modifier.clickable(enabled = !disabled, onClick = onPress)) {
80
+ Column(modifier = Modifier.clickable(enabled = !disabled, onClick = onPress).semantics {
81
+ contentDescription = testId; testTag = testId
82
+ }) {
77
83
  Box {
78
84
  if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
79
85
  Box(
@@ -27,6 +27,9 @@ import androidx.compose.ui.Alignment
27
27
  import androidx.compose.ui.Modifier
28
28
  import androidx.compose.ui.focus.onFocusChanged
29
29
  import androidx.compose.ui.graphics.Color
30
+ import androidx.compose.ui.semantics.contentDescription
31
+ import androidx.compose.ui.semantics.semantics
32
+ import androidx.compose.ui.semantics.testTag
30
33
  import androidx.compose.ui.text.AnnotatedString
31
34
  import androidx.compose.ui.text.TextStyle
32
35
  import androidx.compose.ui.text.input.KeyboardType
@@ -104,8 +107,11 @@ fun InputMoney(
104
107
  iconTintColor = disabledColor
105
108
  }
106
109
 
110
+ val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
107
111
 
108
- Column {
112
+ Column(modifier = Modifier.semantics {
113
+ contentDescription = testId; testTag = testId
114
+ }) {
109
115
  BasicTextField(
110
116
  enabled = !disabled,
111
117
  singleLine = true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.89.30-rc.4",
3
+ "version": "0.89.30-rc.6",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},