@momo-kits/native-kits 0.155.1-hello.2 → 0.155.1-hello.2-debug

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 (117) hide show
  1. package/.gitlab-ci.yml +15 -0
  2. package/.npmignore.backup +22 -0
  3. package/build.gradle.kts +11 -0
  4. package/compose/build.gradle.kts +180 -0
  5. package/compose/compose.podspec +54 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +113 -0
  7. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +95 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +715 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +35 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +343 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +353 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +98 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +138 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +78 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +151 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +190 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +119 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +447 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +175 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +244 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +233 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +257 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +240 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +59 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +44 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +95 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +43 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +355 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +106 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +72 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +99 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +99 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +95 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +132 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +217 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +180 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +208 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +189 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +15 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +241 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +122 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +163 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +331 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +499 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +233 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +190 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +277 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +135 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
  107. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +152 -0
  108. package/gradle/libs.versions.toml +57 -0
  109. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  110. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  111. package/gradle.properties +26 -0
  112. package/gradlew +252 -0
  113. package/gradlew.bat +94 -0
  114. package/local.properties +8 -0
  115. package/package.json +1 -1
  116. package/publish_release.sh +103 -0
  117. package/settings.gradle.kts +52 -0
@@ -0,0 +1,447 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.clickable
6
+ import androidx.compose.foundation.interaction.MutableInteractionSource
7
+ import androidx.compose.foundation.layout.Box
8
+ import androidx.compose.foundation.layout.Column
9
+ import androidx.compose.foundation.layout.Row
10
+ import androidx.compose.foundation.layout.Spacer
11
+ import androidx.compose.foundation.layout.fillMaxWidth
12
+ import androidx.compose.foundation.layout.height
13
+ import androidx.compose.foundation.layout.offset
14
+ import androidx.compose.foundation.layout.padding
15
+ import androidx.compose.foundation.layout.size
16
+ import androidx.compose.foundation.layout.wrapContentSize
17
+ import androidx.compose.foundation.shape.RoundedCornerShape
18
+ import androidx.compose.foundation.text.BasicTextField
19
+ import androidx.compose.foundation.text.KeyboardOptions
20
+ import androidx.compose.material3.CircularProgressIndicator
21
+ import androidx.compose.runtime.Composable
22
+ import androidx.compose.runtime.MutableState
23
+ import androidx.compose.runtime.getValue
24
+ import androidx.compose.runtime.mutableStateOf
25
+ import androidx.compose.runtime.remember
26
+ import androidx.compose.runtime.setValue
27
+ import androidx.compose.ui.Alignment
28
+ import androidx.compose.ui.Modifier
29
+ import androidx.compose.ui.focus.onFocusChanged
30
+ import androidx.compose.ui.graphics.Color
31
+ import androidx.compose.ui.text.AnnotatedString
32
+ import androidx.compose.ui.text.SpanStyle
33
+ import androidx.compose.ui.text.TextStyle
34
+ import androidx.compose.ui.text.font.FontFamily
35
+ import androidx.compose.ui.text.font.FontWeight
36
+ import androidx.compose.ui.text.input.KeyboardType
37
+ import androidx.compose.ui.text.input.OffsetMapping
38
+ import androidx.compose.ui.text.input.TransformedText
39
+ import androidx.compose.ui.text.input.VisualTransformation
40
+ import androidx.compose.ui.text.style.TextAlign
41
+ import androidx.compose.ui.unit.Dp
42
+ import androidx.compose.ui.unit.TextUnit
43
+ import androidx.compose.ui.unit.dp
44
+ import androidx.compose.ui.unit.sp
45
+ import androidx.compose.ui.zIndex
46
+ import vn.momo.kits.const.AppTheme
47
+ import vn.momo.kits.const.Radius
48
+ import vn.momo.kits.const.Spacing
49
+ import vn.momo.kits.application.ApplicationContext
50
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
51
+ import vn.momo.kits.const.Colors
52
+ import vn.momo.kits.const.Typography
53
+ import vn.momo.kits.const.getFont
54
+ import vn.momo.kits.const.scaleSize
55
+ import vn.momo.kits.modifier.conditional
56
+ import vn.momo.kits.modifier.setAutomationId
57
+ import vn.momo.uikits.resources.Res
58
+ import vn.momo.uikits.resources.sfprotext_regular
59
+
60
+ data class InputSizeDetail(
61
+ val borderWidth: Dp,
62
+ val borderRadius: Dp,
63
+ val height: Dp,
64
+ )
65
+
66
+ enum class InputSize(val values: InputSizeDetail) {
67
+ SMALL(
68
+ InputSizeDetail(
69
+ borderWidth = 1.dp,
70
+ borderRadius = Radius.S,
71
+ height = 48.dp
72
+ )
73
+ ),
74
+ LARGE(
75
+ InputSizeDetail(
76
+ borderWidth = 1.dp,
77
+ borderRadius = Radius.S,
78
+ height = 56.dp
79
+ )
80
+ )
81
+ }
82
+
83
+ enum class InputFontWeight(val value: FontWeight) {
84
+ REGULAR(
85
+ FontWeight(400)
86
+ ),
87
+ BOLD(
88
+ FontWeight(700)
89
+ )
90
+ }
91
+
92
+ // Consolidated input state for better performance
93
+ data class InputState(
94
+ val isFocused: Boolean = false,
95
+ val passHidden: Boolean = false,
96
+ val hasBeenBlurred: Boolean = false
97
+ )
98
+
99
+ private class PasswordVisualTransformation(
100
+ private val fontFamily: FontFamily,
101
+ private val fontSize: TextUnit
102
+ ) : VisualTransformation {
103
+ private val mask: Char = '\u2022'
104
+
105
+ override fun filter(text: AnnotatedString): TransformedText {
106
+
107
+ val maskedText = AnnotatedString(
108
+ text = mask.toString().repeat(text.length),
109
+ spanStyles = listOf(
110
+ AnnotatedString.Range(
111
+ SpanStyle(fontSize = fontSize, letterSpacing = 0.sp, fontFamily = fontFamily),
112
+ 0,
113
+ text.length
114
+ )
115
+ )
116
+ )
117
+ return TransformedText(maskedText, OffsetMapping.Identity)
118
+ }
119
+
120
+ override fun equals(other: Any?): Boolean {
121
+ if (this === other) return true
122
+ if (other !is PasswordVisualTransformation) return false
123
+ return mask == other.mask && fontSize == other.fontSize
124
+ }
125
+
126
+ override fun hashCode(): Int {
127
+ return 31 * mask.hashCode() + fontSize.hashCode()
128
+ }
129
+ }
130
+
131
+ @Composable
132
+ fun getBorderColor(isFocused: Boolean, error: String, disabled: Boolean): Color {
133
+ val theme = AppTheme.current
134
+ return remember(isFocused, error, disabled, theme) {
135
+ when {
136
+ disabled -> theme.colors.border.disable
137
+ error.isNotEmpty() -> theme.colors.error.primary
138
+ isFocused -> theme.colors.primary
139
+ else -> theme.colors.border.default
140
+ }
141
+ }
142
+ }
143
+
144
+ @Composable
145
+ fun RenderRightIcon(loading: Boolean, icon: String, color: Color, onClick: () -> Unit) {
146
+ if (loading) {
147
+ Box {
148
+ CircularProgressIndicator(
149
+ modifier = Modifier.size(16.dp),
150
+ color = color,
151
+ trackColor = Color.Transparent,
152
+ strokeWidth = 2.dp
153
+ )
154
+ }
155
+ }
156
+ if (icon.isNotEmpty()) {
157
+ Icon(
158
+ source = icon,
159
+ color = color,
160
+ size = 24.dp,
161
+ modifier = Modifier.clickable(
162
+ onClick = onClick,
163
+ interactionSource = remember { MutableInteractionSource() },
164
+ indication = null
165
+ )
166
+ )
167
+ }
168
+ }
169
+
170
+ @Composable
171
+ fun ErrorView(errorMessage: String, errorSpacing: Boolean, hintText: String) {
172
+ val theme = AppTheme.current
173
+ val errorColor = remember(theme) { theme.colors.error.primary }
174
+ val hintColor = remember(theme) { theme.colors.text.hint }
175
+ val hintTextDefault = remember(hintText) { hintText.ifEmpty { "Không thể chỉnh sửa" } }
176
+
177
+ if (errorMessage.isNotEmpty() || hintText.isNotEmpty()) {
178
+ val color = if (errorMessage.isNotEmpty()) errorColor else hintColor
179
+ Row(
180
+ Modifier.padding(top = Spacing.XS),
181
+ verticalAlignment = Alignment.Top
182
+ ) {
183
+ Icon(
184
+ size = 16.dp,
185
+ color = color,
186
+ source = "ic_error"
187
+ )
188
+ Text(
189
+ errorMessage.ifEmpty { hintTextDefault },
190
+ style = Typography.descriptionDefaultRegular,
191
+ modifier = Modifier.padding(start = Spacing.XS),
192
+ color = color,
193
+ )
194
+ }
195
+ } else if (errorSpacing) {
196
+ Spacer(Modifier.padding(top = Spacing.XS).height(18.dp))
197
+ }
198
+ }
199
+
200
+ @Composable
201
+ fun Input(
202
+ text: MutableState<String> = remember { mutableStateOf("") },
203
+ floatingValue: String = "",
204
+ floatingValueColor: Color = AppTheme.current.colors.text.hint,
205
+ floatingIcon: String = "",
206
+ floatingIconColor: Color = AppTheme.current.colors.text.default,
207
+ placeholder: String = "",
208
+ size: InputSize = InputSize.SMALL,
209
+ onChangeText: (String) -> Unit = {},
210
+ hintText: String = "",
211
+ error: String = "",
212
+ errorSpacing: Boolean = false,
213
+ disabled: Boolean = false,
214
+ readOnly: Boolean = false,
215
+ secureTextEntry: Boolean = false,
216
+ icon: String = "",
217
+ iconColor: Color = AppTheme.current.colors.text.default,
218
+ onRightIconPressed: () -> Unit = {},
219
+ leadingIcon: String = "",
220
+ leadingIconColor: Color = AppTheme.current.colors.text.hint,
221
+ onFocus: () -> Unit = {},
222
+ onBlur: () -> Unit = {},
223
+ loading: Boolean = false,
224
+ required: Boolean = false,
225
+ fontWeight: InputFontWeight = InputFontWeight.REGULAR,
226
+ keyboardType: KeyboardType = KeyboardType.Text,
227
+ modifier: Modifier = Modifier,
228
+ ) {
229
+ // Consolidated state management
230
+ var inputState by remember { mutableStateOf(InputState()) }
231
+
232
+ // Memoized color calculations
233
+ val theme = AppTheme.current
234
+ val colors = remember(disabled, theme) {
235
+ if (disabled) {
236
+ val disabledColor = theme.colors.text.disable
237
+ Triple(disabledColor, disabledColor, disabledColor)
238
+ } else {
239
+ Triple(
240
+ theme.colors.text.default, // textColor
241
+ theme.colors.text.hint, // placeholderColor
242
+ iconColor // iconTintColor
243
+ )
244
+ }
245
+ }
246
+
247
+ val (textColor, placeholderColor, iconTintColor) = colors
248
+
249
+ val floatingTitleColor = remember(disabled, floatingValueColor, theme) {
250
+ if (disabled) theme.colors.text.disable else floatingValueColor
251
+ }
252
+
253
+ val floatingIconTintColor = remember(disabled, floatingIconColor, theme) {
254
+ if (disabled) theme.colors.text.disable else floatingIconColor
255
+ }
256
+
257
+ val testId = remember(disabled, floatingValue) {
258
+ if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
259
+ }
260
+
261
+ val fontSize = 14.sp
262
+ val lineHeight = 24.sp
263
+ val scaleFontSize = scaleSize(fontSize)
264
+ val scaleLineHeight = scaleSize(lineHeight)
265
+
266
+ val textStyle = remember(textColor, fontWeight) {
267
+ TextStyle(
268
+ color = textColor,
269
+ fontSize = scaleFontSize,
270
+ lineHeight = scaleLineHeight,
271
+ fontWeight = fontWeight.value
272
+ )
273
+ }
274
+
275
+ val placeholderStyle = remember(placeholderColor, fontWeight) {
276
+ TextStyle(
277
+ fontSize = fontSize,
278
+ lineHeight = lineHeight,
279
+ fontWeight = fontWeight.value,
280
+ textAlign = TextAlign.Center
281
+ )
282
+ }
283
+
284
+ val keyboardOptionsConfig = remember(secureTextEntry, keyboardType) {
285
+ KeyboardOptions.Default.copy(
286
+ keyboardType = keyboardType
287
+ )
288
+ }
289
+
290
+ val passwordFontFamily = getFont(Res.font.sfprotext_regular)
291
+ val passwordFontSize = scaleSize(24.sp)
292
+ val visualTransformation = remember(secureTextEntry, inputState.passHidden, passwordFontFamily) {
293
+ if (secureTextEntry && !inputState.passHidden)
294
+ PasswordVisualTransformation(fontFamily = passwordFontFamily, fontSize = passwordFontSize)
295
+ else
296
+ VisualTransformation.None
297
+ }
298
+
299
+ val application = ApplicationContext.current
300
+
301
+ Column(modifier = modifier
302
+ .conditional(application.isShowBaselineDebug()) {
303
+ border(1.dp, Colors.blue_03)
304
+ }
305
+ .setAutomationId(testId)) {
306
+ BasicTextField(
307
+ enabled = !disabled,
308
+ readOnly = readOnly,
309
+ singleLine = true,
310
+ value = text.value,
311
+ textStyle = textStyle,
312
+ visualTransformation = visualTransformation,
313
+ keyboardOptions = keyboardOptionsConfig,
314
+ modifier = Modifier
315
+ .height(scaleSize(size.values.height.value, 1.1f).dp)
316
+ .onFocusChanged { focusState ->
317
+ val wasFocused = inputState.isFocused
318
+ inputState = inputState.copy(
319
+ isFocused = focusState.isFocused,
320
+ hasBeenBlurred = inputState.hasBeenBlurred || wasFocused
321
+ )
322
+
323
+ if (focusState.isFocused) {
324
+ onFocus()
325
+ } else if (inputState.hasBeenBlurred) {
326
+ onBlur()
327
+ }
328
+ },
329
+ onValueChange = onChangeText,
330
+ decorationBox = { innerTextField ->
331
+ // Floating label
332
+ if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
333
+ Box(
334
+ modifier = Modifier
335
+ .wrapContentSize()
336
+ .offset(y = (-size.values.height / 2), x = Spacing.S)
337
+ .background(theme.colors.background.surface)
338
+ .zIndex(10f),
339
+ ) {
340
+ Row(
341
+ modifier = Modifier.padding(horizontal = Spacing.S),
342
+ verticalAlignment = Alignment.CenterVertically
343
+ ) {
344
+ Text(
345
+ floatingValue,
346
+ style = Typography.labelSMedium,
347
+ color = floatingTitleColor
348
+ )
349
+ if (required) {
350
+ Text(
351
+ "*",
352
+ style = Typography.labelSMedium,
353
+ color = theme.colors.error.primary,
354
+ )
355
+ }
356
+ if (floatingIcon.isNotEmpty()) {
357
+ Icon(
358
+ source = floatingIcon,
359
+ modifier = Modifier.padding(start = Spacing.XS),
360
+ size = 16.dp,
361
+ color = floatingIconTintColor
362
+ )
363
+ }
364
+ }
365
+ }
366
+ }
367
+
368
+ // Input container
369
+ Box(
370
+ modifier = Modifier
371
+ .fillMaxWidth()
372
+ .background(
373
+ color = AppTheme.current.colors.background.surface,
374
+ shape = RoundedCornerShape(size.values.borderRadius)
375
+ )
376
+ .border(
377
+ 1.dp,
378
+ getBorderColor(inputState.isFocused, error, disabled),
379
+ RoundedCornerShape(size.values.borderRadius)
380
+ ),
381
+ contentAlignment = Alignment.CenterStart
382
+ ) {
383
+ Row(
384
+ modifier = Modifier.padding(horizontal = Spacing.M),
385
+ verticalAlignment = Alignment.CenterVertically
386
+ ) {
387
+ // Leading icon
388
+ if (leadingIcon.isNotEmpty()) {
389
+ Icon(
390
+ source = leadingIcon,
391
+ modifier = Modifier.padding(end = Spacing.M),
392
+ size = if (size == InputSize.SMALL) 24.dp else 32.dp,
393
+ color = leadingIconColor
394
+ )
395
+ }
396
+
397
+ Box(Modifier.weight(1f), contentAlignment = Alignment.CenterStart) {
398
+ if (text.value.isEmpty()) {
399
+ Text(
400
+ text = placeholder,
401
+ style = placeholderStyle,
402
+ color = placeholderColor
403
+ )
404
+
405
+ }
406
+ innerTextField()
407
+ }
408
+
409
+ // Clear button
410
+ if (inputState.isFocused && text.value.isNotEmpty()) {
411
+ Row(Modifier.padding(horizontal = Spacing.XS)) {
412
+ Icon(
413
+ source = "24_navigation_close_circle_full",
414
+ size = 16.dp,
415
+ color = theme.colors.text.hint,
416
+ modifier = Modifier.clickable(
417
+ onClick = { text.value = "" },
418
+ interactionSource = remember { MutableInteractionSource() },
419
+ indication = null
420
+ )
421
+ )
422
+ }
423
+ }
424
+
425
+ // Right icon (password toggle or custom icon)
426
+ when {
427
+ secureTextEntry -> {
428
+ val iconName = if (inputState.passHidden) "24_security_eye_open" else "24_security_eye_off"
429
+ val togglePassword = {
430
+ onRightIconPressed()
431
+ inputState = inputState.copy(passHidden = !inputState.passHidden)
432
+ }
433
+ RenderRightIcon(loading, iconName, iconTintColor, togglePassword)
434
+ }
435
+ else -> {
436
+ RenderRightIcon(loading, icon, iconTintColor, onRightIconPressed)
437
+ }
438
+ }
439
+ }
440
+ }
441
+ },
442
+ )
443
+
444
+ // Error/hint display
445
+ ErrorView(error, errorSpacing, hintText)
446
+ }
447
+ }
@@ -0,0 +1,175 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.clickable
6
+ import androidx.compose.foundation.layout.Box
7
+ import androidx.compose.foundation.layout.Column
8
+ import androidx.compose.foundation.layout.Row
9
+ import androidx.compose.foundation.layout.fillMaxWidth
10
+ import androidx.compose.foundation.layout.height
11
+ import androidx.compose.foundation.layout.offset
12
+ import androidx.compose.foundation.layout.padding
13
+ import androidx.compose.foundation.layout.wrapContentSize
14
+ import androidx.compose.foundation.shape.RoundedCornerShape
15
+ import androidx.compose.runtime.Composable
16
+ import androidx.compose.runtime.MutableState
17
+ import androidx.compose.runtime.getValue
18
+ import androidx.compose.runtime.mutableStateOf
19
+ import androidx.compose.runtime.remember
20
+ import androidx.compose.ui.Alignment
21
+ import androidx.compose.ui.Modifier
22
+ import androidx.compose.ui.graphics.Color
23
+ import androidx.compose.ui.semantics.contentDescription
24
+ import androidx.compose.ui.semantics.semantics
25
+ import androidx.compose.ui.semantics.testTag
26
+ import androidx.compose.ui.text.TextStyle
27
+ import androidx.compose.ui.unit.dp
28
+ import androidx.compose.ui.unit.sp
29
+ import androidx.compose.ui.zIndex
30
+ import vn.momo.kits.const.AppTheme
31
+ import vn.momo.kits.const.Spacing
32
+ import vn.momo.kits.application.ApplicationContext
33
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
34
+ import vn.momo.kits.const.Colors
35
+ import vn.momo.kits.const.Typography
36
+ import vn.momo.kits.const.scaleSize
37
+ import vn.momo.kits.modifier.conditional
38
+
39
+ @Composable
40
+ fun InputDropDown(
41
+ value: MutableState<String> = remember { mutableStateOf("") },
42
+ floatingValue: String = "",
43
+ floatingValueColor: Color = AppTheme.current.colors.text.hint,
44
+ floatingIcon: String = "",
45
+ floatingIconColor: Color = AppTheme.current.colors.text.default,
46
+ placeholder: String = "",
47
+ size: InputSize = InputSize.SMALL,
48
+ onPress: () -> Unit = {},
49
+ hintText: String = "",
50
+ error: String = "",
51
+ errorSpacing: Boolean = false,
52
+ disabled: Boolean = false,
53
+ icon: String = "arrow_chevron_down_small",
54
+ iconColor: Color = AppTheme.current.colors.text.default,
55
+ onRightIconPressed: () -> Unit = {},
56
+ leadingIcon: String = "",
57
+ leadingIconColor: Color = AppTheme.current.colors.text.hint,
58
+ loading: Boolean = false,
59
+ required: Boolean = false,
60
+ ) {
61
+ val isFocused by remember { mutableStateOf(false) }
62
+
63
+ val disabledColor = AppTheme.current.colors.text.disable
64
+ var textColor = AppTheme.current.colors.text.default
65
+ var placeholderColor = AppTheme.current.colors.text.hint
66
+ var iconTintColor = iconColor
67
+ val floatingTitleColor = when {
68
+ disabled -> AppTheme.current.colors.text.disable
69
+ else -> floatingValueColor
70
+ }
71
+ val floatingIconTintColor = when {
72
+ disabled -> AppTheme.current.colors.text.disable
73
+ else -> floatingIconColor
74
+ }
75
+
76
+ if (disabled) {
77
+ textColor = disabledColor
78
+ placeholderColor = disabledColor
79
+ iconTintColor = disabledColor
80
+ }
81
+
82
+ val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
83
+
84
+ val fontSize = scaleSize(16.sp)
85
+ val lineHeight = scaleSize(24.sp)
86
+
87
+ val application = ApplicationContext.current
88
+
89
+ Column(modifier = Modifier
90
+ .conditional(application.isShowBaselineDebug()) {
91
+ border(1.dp, Colors.blue_03)
92
+ }
93
+ .clickable(enabled = !disabled, onClick = onPress)
94
+ .semantics {
95
+ contentDescription = floatingValue; testTag = testId
96
+ }) {
97
+ Box {
98
+ if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
99
+ Box(
100
+ modifier = Modifier.wrapContentSize()
101
+ .offset(y = -Spacing.S, x = Spacing.S)
102
+ .background(AppTheme.current.colors.background.surface)
103
+ .zIndex(10f),
104
+ ) {
105
+ Row(
106
+ modifier = Modifier
107
+ .padding(horizontal = Spacing.S),
108
+ verticalAlignment = Alignment.CenterVertically
109
+ ) {
110
+ Text(
111
+ floatingValue,
112
+ style = Typography.labelSMedium,
113
+ color = floatingTitleColor
114
+ )
115
+ if (required) {
116
+ Text(
117
+ "*",
118
+ style = Typography.labelSMedium,
119
+ color = AppTheme.current.colors.error.primary,
120
+ )
121
+ }
122
+ if (floatingIcon.isNotEmpty()) {
123
+ Icon(
124
+ source = floatingIcon,
125
+ modifier = Modifier.padding(start = Spacing.XS),
126
+ size = 16.dp,
127
+ color = floatingIconTintColor
128
+ )
129
+ }
130
+ }
131
+ }
132
+ }
133
+ Box(
134
+ modifier = Modifier.fillMaxWidth()
135
+ .height(if (size == InputSize.SMALL) 48.dp else 56.dp)
136
+ .border(
137
+ 1.dp,
138
+ getBorderColor(isFocused, error, disabled),
139
+ RoundedCornerShape(size.values.borderRadius)
140
+ ),
141
+ contentAlignment = Alignment.CenterStart
142
+ ) {
143
+ Row(
144
+ modifier = Modifier.padding(horizontal = Spacing.M),
145
+ verticalAlignment = Alignment.CenterVertically
146
+ ) {
147
+ //leading icon
148
+ if (leadingIcon.isNotEmpty()) {
149
+ Icon(
150
+ source = leadingIcon,
151
+ modifier = Modifier.padding(end = Spacing.M),
152
+ size = if (size.name == InputSize.SMALL.name) 24.dp else 32.dp,
153
+ color = leadingIconColor
154
+ )
155
+ }
156
+ Box(Modifier.weight(1f)) {
157
+ Text(
158
+ text = value.value.ifEmpty { placeholder },
159
+ style = TextStyle(
160
+ fontSize = fontSize,
161
+ lineHeight = lineHeight
162
+ ),
163
+ color = if (value.value.isEmpty()) placeholderColor else textColor
164
+ )
165
+ }
166
+ RenderRightIcon(
167
+ loading, icon, iconTintColor,
168
+ onRightIconPressed
169
+ )
170
+ }
171
+ }
172
+ }
173
+ ErrorView(error, errorSpacing, hintText)
174
+ }
175
+ }