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