@momo-kits/native-kits 0.168.1-beta.11-debug → 0.168.1-beta.13

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