@momo-kits/native-kits 0.169.12-debug → 0.169.13-beta.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 (144) hide show
  1. package/ios/Navigation/BottomTab/BottomTabBar.swift +14 -4
  2. package/ios/native-kits.podspec +1 -1
  3. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  4. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +16 -3
  5. package/package.json +1 -1
  6. package/build.gradle.kts +0 -11
  7. package/compose/build.gradle.kts +0 -198
  8. package/compose/compose.podspec +0 -47
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -206
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -421
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -750
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -398
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -103
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -400
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  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/BackGesture.ios.kt +0 -38
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  137. package/gradle/libs.versions.toml +0 -67
  138. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  139. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  140. package/gradle.properties +0 -24
  141. package/gradlew +0 -252
  142. package/gradlew.bat +0 -94
  143. package/ios-demo/README.md +0 -120
  144. package/settings.gradle.kts +0 -64
@@ -1,473 +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
- var inputState by remember { mutableStateOf(InputState()) }
214
-
215
- val theme = AppTheme.current
216
- val colors = remember(disabled, theme, iconColor) {
217
- if (disabled) {
218
- val disabledColor = theme.colors.text.disable
219
- Triple(disabledColor, disabledColor, disabledColor)
220
- } else {
221
- Triple(
222
- theme.colors.text.default,
223
- theme.colors.text.hint,
224
- iconColor
225
- )
226
- }
227
- }
228
-
229
- val (textColor, placeholderColor, iconTintColor) = colors
230
-
231
- val floatingTitleColor = remember(disabled, floatingValueColor, theme) {
232
- if (disabled) theme.colors.text.disable else floatingValueColor
233
- }
234
-
235
- val floatingIconTintColor = remember(disabled, floatingIconColor, theme) {
236
- if (disabled) theme.colors.text.disable else floatingIconColor
237
- }
238
-
239
- val fontSize = 14.sp
240
- val lineHeight = 24.sp
241
- val scaleFontSize = scaleSize(fontSize)
242
- val scaleLineHeight = scaleSize(lineHeight)
243
- val scaledHeight = scaleSize(size.values.height)
244
-
245
- val textStyle = remember(textColor, fontWeight, scaleFontSize, scaleLineHeight) {
246
- TextStyle(
247
- color = textColor,
248
- fontSize = scaleFontSize,
249
- lineHeight = scaleLineHeight,
250
- fontWeight = fontWeight.value
251
- )
252
- }
253
-
254
- val placeholderStyle = remember(placeholderColor, fontWeight) {
255
- TextStyle(
256
- fontSize = fontSize,
257
- lineHeight = lineHeight,
258
- fontWeight = fontWeight.value,
259
- textAlign = TextAlign.Center
260
- )
261
- }
262
-
263
- val keyboardOptionsConfig = remember(secureTextEntry, keyboardType) {
264
- KeyboardOptions.Default.copy(
265
- keyboardType = keyboardType
266
- )
267
- }
268
-
269
- val passwordFontFamily = getFontFamily(AppTheme.current.font, FontWeight.Normal)
270
- val passwordFontSize = scaleSize(24.sp)
271
- val visualTransformation = remember(secureTextEntry, inputState.passHidden, passwordFontFamily, passwordFontSize) {
272
- if (secureTextEntry && !inputState.passHidden)
273
- PasswordVisualTransformation(fontFamily = passwordFontFamily, fontSize = passwordFontSize)
274
- else
275
- VisualTransformation.None
276
- }
277
-
278
- Column(modifier = modifier
279
- .conditional(IsShowBaseLineDebug) {
280
- border(1.dp, Colors.blue_03)
281
- }) {
282
- BasicTextField(
283
- enabled = !disabled,
284
- readOnly = readOnly,
285
- singleLine = true,
286
- value = text.value,
287
- textStyle = textStyle,
288
- visualTransformation = visualTransformation,
289
- keyboardOptions = keyboardOptionsConfig,
290
- cursorBrush = SolidColor(theme.colors.primary),
291
- modifier = inputModifier
292
- .height(scaledHeight)
293
- .onFocusChanged { focusState ->
294
- val wasFocused = inputState.isFocused
295
- inputState = inputState.copy(
296
- isFocused = focusState.isFocused,
297
- hasBeenBlurred = inputState.hasBeenBlurred || wasFocused
298
- )
299
-
300
- if (focusState.isFocused) {
301
- onFocus()
302
- } else if (inputState.hasBeenBlurred) {
303
- onBlur()
304
- }
305
- },
306
- onValueChange = { newText ->
307
- val limitedText = maxLength?.let { newText.take(it) } ?: newText
308
- onChangeText(limitedText)
309
- },
310
- decorationBox = { innerTextField ->
311
- FloatingLabel(
312
- floatingValue = floatingValue,
313
- floatingIcon = floatingIcon,
314
- titleColor = floatingTitleColor,
315
- iconColor = floatingIconTintColor,
316
- offsetY = -scaledHeight / 2,
317
- required = required,
318
- )
319
-
320
- // Input container
321
- Box(
322
- modifier = Modifier
323
- .fillMaxWidth()
324
- .background(
325
- color = AppTheme.current.colors.background.surface,
326
- shape = RoundedCornerShape(size.values.borderRadius)
327
- )
328
- .border(
329
- 1.dp,
330
- getBorderColor(inputState.isFocused, error, disabled),
331
- RoundedCornerShape(size.values.borderRadius)
332
- ),
333
- contentAlignment = Alignment.CenterStart
334
- ) {
335
- Row(
336
- modifier = Modifier.padding(horizontal = Spacing.M),
337
- verticalAlignment = Alignment.CenterVertically
338
- ) {
339
- if (leadingIcon.isNotEmpty()) {
340
- Icon(
341
- source = leadingIcon,
342
- modifier = Modifier.padding(end = Spacing.M),
343
- size = if (size == InputSize.SMALL) 24.dp else 32.dp,
344
- color = leadingIconColor
345
- )
346
- }
347
-
348
- Box(Modifier.weight(1f), contentAlignment = Alignment.CenterStart) {
349
- if (text.value.isEmpty()) {
350
- Text(
351
- text = placeholder,
352
- style = placeholderStyle,
353
- color = placeholderColor
354
- )
355
-
356
- }
357
- innerTextField()
358
- }
359
-
360
- // Clear button
361
- if (!readOnly && inputState.isFocused && text.value.isNotEmpty()) {
362
- Row(Modifier.padding(horizontal = Spacing.XS)) {
363
- Icon(
364
- source = "24_navigation_close_circle_full",
365
- size = 16.dp,
366
- color = theme.colors.text.hint,
367
- modifier = Modifier.clickable(
368
- onClick = {
369
- text.value = ""
370
- onChangeText.invoke("")
371
- },
372
- interactionSource = remember { MutableInteractionSource() },
373
- indication = null
374
- ).setAutomationId("ic_clear")
375
- )
376
- }
377
- }
378
-
379
- // Right icon (password toggle or custom icon)
380
- when {
381
- secureTextEntry && text.value.isNotEmpty() -> {
382
- val iconName = if (inputState.passHidden) "24_security_eye_open" else "24_security_eye_off"
383
- val togglePassword = {
384
- onRightIconPressed()
385
- inputState = inputState.copy(passHidden = !inputState.passHidden)
386
- }
387
- RenderRightIcon(
388
- loading = loading,
389
- icon = iconName,
390
- color = iconTintColor,
391
- onClick = togglePassword,
392
- modifier = Modifier.setAutomationId("ic_show_hide"))
393
- }
394
- else -> {
395
- RenderRightIcon(loading, icon, iconTintColor, onRightIconPressed)
396
- }
397
- }
398
- }
399
- }
400
- },
401
- )
402
-
403
- ErrorView(error, errorSpacing, hintText)
404
- }
405
- }
406
-
407
- internal data class InputColors(
408
- val text: Color,
409
- val placeholder: Color,
410
- val iconTint: Color,
411
- val floatingTitle: Color,
412
- val floatingIcon: Color,
413
- )
414
-
415
- @Composable
416
- internal fun getInputColors(
417
- disabled: Boolean,
418
- iconColor: Color,
419
- floatingValueColor: Color,
420
- floatingIconColor: Color,
421
- ): InputColors {
422
- val theme = AppTheme.current
423
- val disabledColor = theme.colors.text.disable
424
- return InputColors(
425
- text = if (disabled) disabledColor else theme.colors.text.default,
426
- placeholder = if (disabled) disabledColor else theme.colors.text.hint,
427
- iconTint = if (disabled) disabledColor else iconColor,
428
- floatingTitle = if (disabled) disabledColor else floatingValueColor,
429
- floatingIcon = if (disabled) disabledColor else floatingIconColor,
430
- )
431
- }
432
-
433
- @Composable
434
- internal fun FloatingLabel(
435
- floatingValue: String,
436
- floatingIcon: String,
437
- titleColor: Color,
438
- iconColor: Color,
439
- offsetY: Dp,
440
- offsetX: Dp = Spacing.S,
441
- required: Boolean = false,
442
- ) {
443
- if (floatingValue.isEmpty() && floatingIcon.isEmpty()) return
444
- Box(
445
- modifier = Modifier
446
- .wrapContentSize()
447
- .offset(y = offsetY, x = offsetX)
448
- .background(AppTheme.current.colors.background.surface)
449
- .zIndex(10f),
450
- ) {
451
- Row(
452
- modifier = Modifier.padding(horizontal = Spacing.S),
453
- verticalAlignment = Alignment.CenterVertically,
454
- ) {
455
- Text(floatingValue, style = Typography.labelSMedium, color = titleColor)
456
- if (required) {
457
- Text(
458
- "*",
459
- style = Typography.labelSMedium,
460
- color = AppTheme.current.colors.error.primary,
461
- )
462
- }
463
- if (floatingIcon.isNotEmpty()) {
464
- Icon(
465
- source = floatingIcon,
466
- modifier = Modifier.padding(start = Spacing.XS),
467
- size = 16.dp,
468
- color = iconColor,
469
- )
470
- }
471
- }
472
- }
473
- }
@@ -1,113 +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 colors = getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
48
- val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) = colors
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
- if (leadingIcon.isNotEmpty()) {
87
- Icon(
88
- source = leadingIcon,
89
- modifier = Modifier.padding(end = Spacing.M),
90
- size = if (size.name == InputSize.SMALL.name) 24.dp else 32.dp,
91
- color = leadingIconColor
92
- )
93
- }
94
- Box(Modifier.weight(1f)) {
95
- Text(
96
- text = value.value.ifEmpty { placeholder },
97
- style = TextStyle(
98
- fontSize = fontSize,
99
- lineHeight = lineHeight
100
- ),
101
- color = if (value.value.isEmpty()) placeholderColor else textColor
102
- )
103
- }
104
- RenderRightIcon(
105
- loading, icon, iconTintColor,
106
- onRightIconPressed
107
- )
108
- }
109
- }
110
- }
111
- ErrorView(error, errorSpacing, hintText)
112
- }
113
- }