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