@momo-kits/native-kits 0.152.4-scale.4 → 0.152.5-klib.1

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