@momo-kits/native-kits 0.169.13-beta.3-debug → 0.169.13-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/ios/native-kits.podspec +1 -1
  2. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  3. package/package.json +1 -1
  4. package/build.gradle.kts +0 -11
  5. package/compose/build.gradle.kts +0 -202
  6. package/compose/compose.podspec +0 -47
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  14. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiActionsTest.kt +0 -647
  15. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiExprTest.kt +0 -1411
  16. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt +0 -130
  17. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt +0 -524
  18. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitNodesTest.kt +0 -559
  19. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderPlanTest.kt +0 -741
  20. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt +0 -221
  21. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt +0 -270
  22. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStylePlanTest.kt +0 -849
  23. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt +0 -212
  24. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt +0 -239
  25. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiViewTest.kt +0 -252
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -206
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -421
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -750
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -398
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -103
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -400
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiActions.kt +0 -154
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiExpr.kt +0 -1038
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiKitNodes.kt +0 -848
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt +0 -47
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt +0 -39
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt +0 -463
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiRenderer.kt +0 -1146
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiStyle.kt +0 -667
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiTracking.kt +0 -240
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiValidate.kt +0 -185
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiView.kt +0 -200
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  150. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  151. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  152. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  153. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  154. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  155. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  156. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  157. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  158. package/gradle/libs.versions.toml +0 -69
  159. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  160. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  161. package/gradle.properties +0 -24
  162. package/gradlew +0 -252
  163. package/gradlew.bat +0 -94
  164. package/ios-demo/README.md +0 -120
  165. package/scripts/sdui-visual/README.md +0 -64
  166. package/settings.gradle.kts +0 -64
@@ -1,262 +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.interaction.MutableInteractionSource
7
- import androidx.compose.foundation.layout.Box
8
- import androidx.compose.foundation.layout.Column
9
- import androidx.compose.foundation.layout.Row
10
- import androidx.compose.foundation.layout.Spacer
11
- import androidx.compose.foundation.layout.fillMaxWidth
12
- import androidx.compose.foundation.layout.height
13
- import androidx.compose.foundation.layout.offset
14
- import androidx.compose.foundation.layout.padding
15
- import androidx.compose.foundation.layout.width
16
- import androidx.compose.foundation.layout.wrapContentSize
17
- import androidx.compose.foundation.shape.RoundedCornerShape
18
- import androidx.compose.foundation.text.BasicTextField
19
- import androidx.compose.foundation.text.KeyboardOptions
20
- import androidx.compose.runtime.Composable
21
- import androidx.compose.runtime.MutableState
22
- import androidx.compose.runtime.getValue
23
- import androidx.compose.runtime.mutableStateOf
24
- import androidx.compose.runtime.remember
25
- import androidx.compose.runtime.setValue
26
- import androidx.compose.ui.Alignment
27
- import androidx.compose.ui.Modifier
28
- import androidx.compose.ui.focus.onFocusChanged
29
- import androidx.compose.ui.graphics.Color
30
- import androidx.compose.ui.graphics.SolidColor
31
- import androidx.compose.ui.semantics.contentDescription
32
- import androidx.compose.ui.semantics.semantics
33
- import androidx.compose.ui.semantics.testTag
34
- import androidx.compose.ui.text.TextRange
35
- import androidx.compose.ui.text.TextStyle
36
- import androidx.compose.ui.text.input.KeyboardType
37
- import androidx.compose.ui.text.input.TextFieldValue
38
- import androidx.compose.ui.unit.dp
39
- import androidx.compose.ui.unit.sp
40
- import androidx.compose.ui.zIndex
41
- import vn.momo.kits.const.AppTheme
42
- import vn.momo.kits.const.Spacing
43
- import vn.momo.kits.application.IsShowBaseLineDebug
44
- import vn.momo.kits.const.Colors
45
- import vn.momo.kits.const.Typography
46
- import vn.momo.kits.const.getFontFamily
47
- import vn.momo.kits.const.scaleSize
48
- import vn.momo.kits.modifier.conditional
49
- import vn.momo.kits.modifier.setAutomationId
50
-
51
- private const val MONEY_CURRENCY = "đ"
52
-
53
- private data class MoneyEdit(val start: Int, val end: Int, val inserted: String)
54
-
55
- private fun digitsOf(text: String) = text.filter { it in '0'..'9' }
56
-
57
- private fun normalizeDigits(text: String) = digitsOf(text).let { digits ->
58
- digits.trimStart('0').ifEmpty { digits.take(1) }
59
- }
60
-
61
- private fun moneyDisplay(digits: String): String {
62
- if (digits.isEmpty()) return ""
63
- return digits.reversed().chunked(3).joinToString(".").reversed() + MONEY_CURRENCY
64
- }
65
-
66
- // Caret position right after the `digitIndex`-th digit of `display`.
67
- private fun caretFromDigitIndex(display: String, digitIndex: Int): Int {
68
- var count = 0
69
- display.forEachIndexed { index, char ->
70
- if (char in '0'..'9' && ++count == digitIndex) return index + 1
71
- }
72
- return 0
73
- }
74
-
75
- // Finds which range of `old` was replaced to produce `next`, given the post-edit caret.
76
- private fun detectEdit(old: String, next: String, caret: Int): MoneyEdit {
77
- val tail = next.length - caret
78
- if (tail in 0..old.length && next.substring(caret) == old.substring(old.length - tail)) {
79
- var prefix = 0
80
- while (prefix < minOf(caret, old.length - tail) && old[prefix] == next[prefix]) prefix++
81
- return MoneyEdit(prefix, old.length - tail, next.substring(prefix, caret))
82
- }
83
- val minLength = minOf(old.length, next.length)
84
- var prefix = 0
85
- while (prefix < minLength && old[prefix] == next[prefix]) prefix++
86
- var suffix = 0
87
- while (suffix < minLength - prefix && old[old.length - 1 - suffix] == next[next.length - 1 - suffix]) suffix++
88
- return MoneyEdit(prefix, old.length - suffix, next.substring(prefix, next.length - suffix))
89
- }
90
-
91
- // Separators and currency are never deleted: removing a separator removes the digit before it, removing
92
- // only the currency is a no-op. Returns the new digits and the caret as a digit index.
93
- private fun applyEdit(display: String, edit: MoneyEdit): Pair<String, Int> {
94
- val digits = digitsOf(display)
95
- var left = digitsOf(display.substring(0, edit.start)).length
96
- var removed = digitsOf(display.substring(edit.start, edit.end)).length
97
- val inserted = digitsOf(edit.inserted)
98
- if (removed == 0 && inserted.isEmpty() && left > 0 && '.' in display.substring(edit.start, edit.end)) {
99
- left -= 1
100
- removed = 1
101
- }
102
- if (removed == 0 && inserted.isEmpty()) return digits to left
103
- val next = digits.substring(0, left) + inserted + digits.substring(left + removed)
104
- val trimmed = next.trimStart('0').ifEmpty { next.take(1) }
105
- return trimmed to maxOf(0, left + inserted.length - (next.length - trimmed.length))
106
- }
107
-
108
- @Composable
109
- fun InputMoney(
110
- text: MutableState<String> = remember { mutableStateOf("0") },
111
- floatingValue: String = "",
112
- floatingValueColor: Color = AppTheme.current.colors.text.hint,
113
- floatingIcon: String = "",
114
- floatingIconColor: Color = AppTheme.current.colors.text.default,
115
- placeholder: String = "0đ",
116
- size: InputSize = InputSize.SMALL,
117
- onChangeText: (String) -> Unit = {},
118
- error: String = "",
119
- errorSpacing: Boolean = false,
120
- disabled: Boolean = false,
121
- icon: String = "",
122
- iconColor: Color = AppTheme.current.colors.text.default,
123
- onPressIcon: () -> Unit = {},
124
- leadingIcon: String = "",
125
- leadingIconColor: Color = AppTheme.current.colors.text.hint,
126
- onFocus: () -> Unit = {},
127
- onBlur: () -> Unit = {},
128
- loading: Boolean = false,
129
- required: Boolean = false,
130
- fontWeight: InputFontWeight = InputFontWeight.BOLD,
131
- keyboardType: KeyboardType = KeyboardType.Number,
132
- ) {
133
- var isFocused by remember { mutableStateOf(false) }
134
- var field by remember { mutableStateOf(TextFieldValue()) }
135
- val digits = normalizeDigits(text.value)
136
- val current = if (digitsOf(field.text) == digits) field else moneyDisplay(digits).let {
137
- TextFieldValue(it, TextRange(caretFromDigitIndex(it, digits.length)))
138
- }
139
- val colors = getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
140
- val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) = colors
141
-
142
- val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
143
-
144
- Column(modifier = Modifier
145
- .conditional(IsShowBaseLineDebug) {
146
- border(1.dp, Colors.blue_03)
147
- }
148
- .semantics {
149
- contentDescription = floatingValue; testTag = testId
150
- }) {
151
- BasicTextField(
152
- enabled = !disabled,
153
- singleLine = true,
154
- value = current,
155
- textStyle = TextStyle(
156
- color = textColor,
157
- fontSize = scaleSize(20.sp),
158
- lineHeight = scaleSize(24.sp),
159
- fontWeight = fontWeight.value,
160
- fontFamily = getFontFamily(AppTheme.current.font, fontWeight.value)
161
- ),
162
- keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
163
- cursorBrush = SolidColor(AppTheme.current.colors.primary),
164
- modifier = Modifier.height(size.values.height).onFocusChanged {
165
- if (it.isFocused) onFocus() else if (isFocused) onBlur()
166
- isFocused = it.isFocused
167
- },
168
- onValueChange = { value ->
169
- if (value.text == current.text) {
170
- // Keeps the caret out of the currency suffix.
171
- val max = if (current.text.isEmpty()) 0 else current.text.length - MONEY_CURRENCY.length
172
- field = value.copy(
173
- selection = TextRange(
174
- value.selection.start.coerceAtMost(max),
175
- value.selection.end.coerceAtMost(max)
176
- )
177
- )
178
- } else {
179
- val (newDigits, caretDigit) = applyEdit(
180
- current.text,
181
- detectEdit(current.text, value.text, value.selection.min)
182
- )
183
- val display = moneyDisplay(newDigits)
184
- field = TextFieldValue(display, TextRange(caretFromDigitIndex(display, caretDigit)))
185
- if (newDigits != digits) {
186
- text.value = newDigits
187
- onChangeText(newDigits)
188
- }
189
- }
190
- },
191
- decorationBox = { innerTextField ->
192
- FloatingLabel(
193
- floatingValue = floatingValue,
194
- floatingIcon = floatingIcon,
195
- titleColor = floatingTitleColor,
196
- iconColor = floatingIconTintColor,
197
- offsetY = -size.values.height / 2,
198
- required = required,
199
- )
200
- // Input container
201
- Box(
202
- modifier = Modifier.fillMaxWidth()
203
- .border(
204
- 1.dp,
205
- getBorderColor(isFocused, error, disabled),
206
- RoundedCornerShape(size.values.borderRadius)
207
- ),
208
- contentAlignment = Alignment.CenterStart
209
- ) {
210
- Row(
211
- modifier = Modifier.padding(horizontal = Spacing.M),
212
- verticalAlignment = Alignment.CenterVertically
213
- ) {
214
- if (leadingIcon.isNotEmpty()) {
215
- Icon(
216
- source = leadingIcon,
217
- modifier = Modifier.padding(end = Spacing.XS),
218
- size = if (size.name == InputSize.SMALL.name) 24.dp else 32.dp,
219
- color = leadingIconColor
220
- )
221
- }
222
- Box(Modifier.weight(9f), contentAlignment = Alignment.CenterStart) {
223
- if (text.value.isEmpty()) {
224
- Text(
225
- text = placeholder,
226
- style = TextStyle(
227
- fontSize = 20.sp,
228
- lineHeight = 24.sp,
229
- fontWeight = fontWeight.value
230
- ),
231
- color = placeholderColor
232
- )
233
- }
234
- // Composed even when empty so the caret shows over the placeholder.
235
- innerTextField()
236
- }
237
- if (isFocused && text.value.isNotEmpty()) {
238
- Row {
239
- Spacer(Modifier.width(Spacing.XS))
240
- Icon(
241
- source = "24_navigation_close_circle_full",
242
- size = 16.dp,
243
- color = AppTheme.current.colors.text.hint,
244
- modifier = Modifier.clickable(
245
- onClick = {
246
- text.value = ""
247
- onChangeText.invoke("")
248
- },
249
- interactionSource = remember { MutableInteractionSource() },
250
- indication = null
251
- ).setAutomationId("ic_clear")
252
- )
253
- }
254
- }
255
- RenderRightIcon(loading, icon, iconTintColor, onPressIcon)
256
- }
257
- }
258
- },
259
- )
260
- ErrorView(error, errorSpacing, "")
261
- }
262
- }
@@ -1,237 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import vn.momo.kits.modifier.InternalApi
4
-
5
- import androidx.compose.animation.core.LinearEasing
6
- import androidx.compose.animation.core.RepeatMode
7
- import androidx.compose.animation.core.animateFloat
8
- import androidx.compose.animation.core.infiniteRepeatable
9
- import androidx.compose.animation.core.rememberInfiniteTransition
10
- import androidx.compose.animation.core.tween
11
- import androidx.compose.foundation.background
12
- import androidx.compose.foundation.border
13
- import androidx.compose.ui.draw.alpha
14
- import androidx.compose.foundation.clickable
15
- import androidx.compose.foundation.layout.Arrangement
16
- import androidx.compose.foundation.layout.Box
17
- import androidx.compose.foundation.layout.Column
18
- import androidx.compose.foundation.layout.Row
19
- import androidx.compose.foundation.layout.Spacer
20
- import androidx.compose.foundation.layout.fillMaxWidth
21
- import androidx.compose.foundation.layout.height
22
- import androidx.compose.foundation.layout.offset
23
- import androidx.compose.foundation.layout.padding
24
- import androidx.compose.foundation.layout.size
25
- import androidx.compose.foundation.layout.width
26
- import androidx.compose.foundation.layout.wrapContentSize
27
- import androidx.compose.foundation.shape.RoundedCornerShape
28
- import androidx.compose.foundation.text.BasicTextField
29
- import androidx.compose.foundation.text.KeyboardOptions
30
- import androidx.compose.runtime.Composable
31
- import androidx.compose.runtime.getValue
32
- import androidx.compose.runtime.mutableStateOf
33
- import androidx.compose.runtime.remember
34
- import androidx.compose.runtime.setValue
35
- import androidx.compose.ui.Alignment
36
- import androidx.compose.ui.Modifier
37
- import androidx.compose.ui.focus.onFocusChanged
38
- import androidx.compose.ui.text.TextStyle
39
- import androidx.compose.ui.text.input.KeyboardType
40
- import androidx.compose.ui.unit.dp
41
- import androidx.compose.ui.unit.sp
42
- import androidx.compose.ui.zIndex
43
- import vn.momo.kits.const.AppTheme
44
- import vn.momo.kits.const.Radius
45
- import vn.momo.kits.const.Spacing
46
- import vn.momo.kits.application.IsShowBaseLineDebug
47
- import vn.momo.kits.const.Colors
48
- import vn.momo.kits.const.Typography
49
- import vn.momo.kits.const.scaleSize
50
- import vn.momo.kits.modifier.conditional
51
-
52
- @Composable
53
- @InternalApi
54
- fun OTPCaret() {
55
- val duration = 500
56
- val backgroundColor = AppTheme.current.colors.primary
57
-
58
- val infiniteTransition = rememberInfiniteTransition()
59
- val alpha by infiniteTransition.animateFloat(
60
- initialValue = 1f,
61
- targetValue = 0f,
62
- animationSpec = infiniteRepeatable(
63
- animation = tween(
64
- durationMillis = duration,
65
- delayMillis = duration,
66
- easing = LinearEasing
67
- ),
68
- repeatMode = RepeatMode.Reverse
69
- )
70
- )
71
-
72
- Row(
73
- verticalAlignment = Alignment.CenterVertically
74
- ) {
75
- Box(
76
- modifier = Modifier
77
- .size(1.dp, scaleSize(12f).dp)
78
- .background(backgroundColor.copy(alpha = alpha))
79
- )
80
- Text(
81
- text = "-",
82
- color = AppTheme.current.colors.text.hint,
83
- style = Typography.descriptionDefaultRegular
84
- )
85
- }
86
- }
87
-
88
- @Composable
89
- fun InputOTP(
90
- value: String = "",
91
- length: Int? = null,
92
- errorMessage: String = "",
93
- errorSpacing: Boolean = false,
94
- floatingValue: String = "Label",
95
- placeholder: String = "",
96
- onChangeText: (String) -> Unit,
97
- onFocus: () -> Unit = {},
98
- onBlur: () -> Unit = {},
99
- dataType: String = "number",
100
- modifier: Modifier = Modifier
101
- ) {
102
- val maxLength = length ?: 10
103
- var isFocused by remember { mutableStateOf(false) }
104
-
105
- val handleChangeText: (String) -> Unit = { text ->
106
- val fitsLength = text.length <= maxLength
107
- val matchesType = dataType != "number" || text.all { it.isDigit() }
108
- if (fitsLength && matchesType && text.length != value.length) {
109
- onChangeText(text)
110
- }
111
- }
112
-
113
- fun onClearText(){
114
- handleChangeText("")
115
- }
116
-
117
- val fontSize = scaleSize(20.sp)
118
-
119
- Column(modifier = modifier.conditional(IsShowBaseLineDebug) {
120
- border(1.dp, Colors.blue_03)
121
- }) {
122
- BasicTextField(
123
- value = value,
124
- textStyle = TextStyle(fontSize = fontSize),
125
- onValueChange = handleChangeText,
126
- singleLine = true,
127
- keyboardOptions = KeyboardOptions.Default.copy(keyboardType = if (dataType == "number") KeyboardType.Number else KeyboardType.Ascii),
128
- modifier = Modifier.height(56.dp).onFocusChanged {
129
- if (it.isFocused) onFocus() else if (isFocused) onBlur()
130
- isFocused = it.isFocused
131
- },
132
- decorationBox = { innerTextField ->
133
- Box {
134
- Box(
135
- modifier = Modifier.fillMaxWidth().height(56.dp).alpha(0f)
136
- ) { innerTextField() }
137
- if (floatingValue.isNotEmpty()) {
138
- Box(
139
- modifier = Modifier.wrapContentSize()
140
- .offset(y = ((-56).dp / 2))
141
- .align(Alignment.Center)
142
- .background(AppTheme.current.colors.background.surface)
143
- .zIndex(10f),
144
- ) {
145
- Row(
146
- modifier = Modifier
147
- .padding(horizontal = Spacing.S),
148
- verticalAlignment = Alignment.Bottom
149
- ) {
150
- Text(
151
- floatingValue,
152
- style = Typography.labelSMedium,
153
- color = AppTheme.current.colors.text.hint
154
- )
155
- }
156
- }
157
- }
158
- Box(
159
- modifier = Modifier
160
- .fillMaxWidth()
161
- .height(56.dp)
162
- .border(
163
- 1.dp,
164
- getBorderColor(isFocused, errorMessage, false),
165
- RoundedCornerShape(
166
- Radius.S
167
- )
168
- ), contentAlignment = Alignment.Center
169
- ) {
170
- Row(
171
- modifier = Modifier.padding(vertical = 8.dp),
172
- horizontalArrangement = Arrangement.SpaceBetween,
173
- verticalAlignment = Alignment.CenterVertically
174
- ) {
175
- if (length != null) {
176
- for (i in 0 until length) {
177
- if (isFocused && value.length == i) {
178
- OTPCaret()
179
- } else {
180
- val digit = value.getOrNull(i)
181
- var textColor = AppTheme.current.colors.text.hint
182
- var typo = Typography.descriptionDefaultRegular
183
- if (digit != null) {
184
- textColor = AppTheme.current.colors.text.default
185
- typo = Typography.headerDefaultBold
186
- }
187
- Text(
188
- text = digit?.toString() ?: "-",
189
- color = textColor,
190
- style = typo
191
- )
192
- }
193
- if (i != length - 1) Spacer(Modifier.width(Spacing.L))
194
- }
195
- } else {
196
- if (value.isEmpty() && !isFocused && placeholder.isNotEmpty()) {
197
- return@BasicTextField Text(
198
- text = placeholder,
199
- color = AppTheme.current.colors.text.hint
200
- )
201
- } else {
202
- for (i in value.indices) {
203
- Text(
204
- style = Typography.headerDefaultBold,
205
- text = value[i].toString()
206
- )
207
- if (i != value.length - 1 || (isFocused && value.length != maxLength)) {
208
- Spacer(Modifier.width(Spacing.L))
209
- }
210
- }
211
- if (isFocused && value.length != maxLength) OTPCaret()
212
- }
213
- }
214
- }
215
- }
216
- Box(
217
- modifier = Modifier.align(Alignment.Center).zIndex(10f)
218
- ) {
219
- Row(
220
- horizontalArrangement = Arrangement.End,
221
- modifier = Modifier.fillMaxWidth()
222
- ) {
223
- Icon(
224
- "24_navigation_close_circle_full",
225
- size = 12.dp,
226
- modifier = Modifier.padding(end = 12.dp).clickable {
227
- onClearText()
228
- }
229
- )
230
- }
231
- }
232
- }
233
- }
234
- )
235
- ErrorView(errorMessage, errorSpacing, "")
236
- }
237
- }