@momo-kits/native-kits 0.89.28 → 0.89.29

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.
@@ -88,7 +88,7 @@ fun HeaderImage(
88
88
  }
89
89
 
90
90
  HeaderType.SURFACE -> {
91
- val height =statusBarHeight + 52.dp
91
+ val height = statusBarHeight + 52.dp
92
92
  Box(
93
93
  modifier = Modifier.fillMaxWidth().height(height)
94
94
  .background(AppTheme.current.colors.background.surface)
@@ -182,7 +182,10 @@ fun Header(
182
182
  onClick = goBack
183
183
  )
184
184
  .padding(Spacing.XS)
185
- .semantics { contentDescription = "btn_navigation_back"; testTag = "btn_navigation_back" },
185
+ .semantics {
186
+ contentDescription = "btn_navigation_back"; testTag =
187
+ "btn_navigation_back"
188
+ },
186
189
  contentAlignment = Alignment.Center
187
190
  ) {
188
191
  Icon(
@@ -75,7 +75,7 @@ fun OTPCaret() {
75
75
 
76
76
  @Composable
77
77
  fun InputOTP(
78
- length: Int = 4,
78
+ length: Int? = null,
79
79
  errorMessage: String = "",
80
80
  errorSpacing: Boolean = false,
81
81
  floatingValue: String = "Label",
@@ -92,7 +92,10 @@ fun InputOTP(
92
92
  var isBlurred = false
93
93
 
94
94
  val handleChangeText: (String) -> Unit = { text ->
95
- if (text.length <= MAX_LENGTH && (text.length <= value.length || value.length < length) && (dataType != "number" || !text.any { !it.isDigit() })) {
95
+ if (text.length <= MAX_LENGTH &&
96
+ (dataType != "number" || !text.any { !it.isDigit() }) &&
97
+ (text.length < value.length || value.length < text.length)
98
+ ) {
96
99
  value = text
97
100
  onChangeText(text)
98
101
  }
@@ -153,27 +156,41 @@ fun InputOTP(
153
156
  horizontalArrangement = Arrangement.SpaceBetween,
154
157
  verticalAlignment = Alignment.CenterVertically
155
158
  ) {
156
- for (i in 0 until length) {
159
+ if (length != null) {
160
+ for (i in 0 until length) {
161
+ if (isFocused && value.length == i) {
162
+ OTPCaret()
163
+ } else {
164
+ val textColor =
165
+ if (value.getOrNull(i) != null) AppTheme.current.colors.text.default else AppTheme.current.colors.text.hint
166
+ val typo =
167
+ if (value.getOrNull(i) != null) Typography.titleS else Typography.descriptionDefault
168
+ Text(
169
+ text = value.getOrNull(i)?.toString() ?: "-",
170
+ color = textColor,
171
+ style = typo
172
+ )
173
+ }
174
+ if (i != length - 1) Spacer(Modifier.width(Spacing.L))
175
+ }
176
+ } else {
157
177
  if (value.isEmpty() && !isFocused && placeholder.isNotEmpty()) {
158
178
  return@BasicTextField Text(
159
179
  text = placeholder,
160
180
  color = AppTheme.current.colors.text.hint
161
181
  )
162
- }
163
- if (isFocused && value.length == i) {
164
- OTPCaret();
165
182
  } else {
166
- val textColor =
167
- if (value.getOrNull(i) != null) AppTheme.current.colors.text.default else AppTheme.current.colors.text.hint
168
- val typo =
169
- if (value.getOrNull(i) != null) Typography.titleS else Typography.descriptionDefault
170
- Text(
171
- text = value.getOrNull(i)?.toString() ?: "-",
172
- color = textColor,
173
- style = typo
174
- )
183
+ for (i in value.indices) {
184
+ Text(
185
+ style = Typography.titleS,
186
+ text = value[i].toString()
187
+ )
188
+ if (i != value.length - 1 || (isFocused && value.length != MAX_LENGTH)) {
189
+ Spacer(Modifier.width(Spacing.L))
190
+ }
191
+ }
192
+ if (isFocused && value.length != MAX_LENGTH) OTPCaret()
175
193
  }
176
- if (i != length - 1) Spacer(Modifier.width(Spacing.L))
177
194
  }
178
195
  }
179
196
  }
@@ -182,4 +199,4 @@ fun InputOTP(
182
199
  )
183
200
  ErrorView(errorMessage, errorSpacing, "")
184
201
  }
185
- }
202
+ }
@@ -25,9 +25,10 @@ fun Text(
25
25
  overflow: TextOverflow = TextOverflow.Clip,
26
26
  textDecoration: TextDecoration? = null,
27
27
  onTextLayout: ((TextLayoutResult) -> Unit)? = null,
28
+ fontFamily: String = "SFProText"
28
29
  ) {
29
30
  val fontSize = scaleSize(style.fontSize.value).sp
30
- val fontFamily = getFontFamily("SFProText", style.fontWeight)
31
+ val font = getFontFamily(fontFamily, style.fontWeight)
31
32
 
32
33
  androidx.compose.material3.Text(
33
34
  modifier = modifier,
@@ -36,7 +37,7 @@ fun Text(
36
37
  style = style,
37
38
  textAlign = textAlign,
38
39
  fontSize = fontSize,
39
- fontFamily = fontFamily,
40
+ fontFamily = font,
40
41
  maxLines = maxLines,
41
42
  textDecoration = textDecoration,
42
43
  onTextLayout = onTextLayout,
@@ -27,10 +27,10 @@ fun scaleSize(size: Float): Float {
27
27
 
28
28
  @OptIn(InternalResourceApi::class)
29
29
  @Composable
30
- fun getFont(font: String): FontFamily {
30
+ fun getFont(font: String, ext: String = "ttf"): FontFamily {
31
31
  val fontResource = FontResource(
32
32
  "font:${font}",
33
- setOf(ResourceItem(setOf(), "font/${font}.ttf", -1, -1))
33
+ setOf(ResourceItem(setOf(), "font/${font}.${ext}", -1, -1))
34
34
  )
35
35
  return FontFamily(Font(fontResource))
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.89.28",
3
+ "version": "0.89.29",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},