@momo-kits/native-kits 0.169.8-beta.7-debug → 0.169.8

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 (157) hide show
  1. package/ios/Input/InputSearch.swift +6 -23
  2. package/ios/Navigation/BottomTab/BottomTabBar.swift +0 -9
  3. package/ios/Navigation/Component/Header.swift +46 -31
  4. package/ios/Navigation/Component/HeaderJourney.swift +1 -2
  5. package/ios/Navigation/Component/HeaderLocation.swift +1 -2
  6. package/ios/Navigation/Component/HeaderRight.swift +15 -18
  7. package/ios/Navigation/Component/HeaderUser.swift +1 -2
  8. package/ios/Navigation/Component/SideBar.swift +13 -4
  9. package/ios/Navigation/Navigation.swift +1 -31
  10. package/ios/Navigation/StackScreen.swift +14 -43
  11. package/ios/native-kits.podspec +1 -1
  12. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  13. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
  14. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +1 -13
  15. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
  16. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
  17. package/package.json +1 -1
  18. package/build.gradle.kts +0 -11
  19. package/compose/build.gradle.kts +0 -198
  20. package/compose/compose.podspec +0 -47
  21. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  22. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  23. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  24. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  25. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  26. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  27. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -267
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -195
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -263
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -307
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -306
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -457
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -120
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -210
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -292
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -63
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -746
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -400
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -100
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -207
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -132
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -398
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -22
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  142. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  143. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  144. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  145. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  146. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  147. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  148. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -144
  149. package/gradle/libs.versions.toml +0 -67
  150. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  151. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  152. package/gradle.properties +0 -24
  153. package/gradlew +0 -252
  154. package/gradlew.bat +0 -94
  155. package/ios/Layout/HeaderLayout.swift +0 -60
  156. package/ios-demo/README.md +0 -120
  157. 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 (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
- 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
- }