@momo-kits/native-kits 0.167.1-duo.10-debug → 0.167.1-duo.10

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