@momo-kits/native-kits 0.162.3-fontscale.4-debug → 0.162.3-fontscale.4

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