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

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 (136) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -189
  4. package/compose/build.gradle.kts.backup +0 -189
  5. package/compose/compose.podspec +0 -47
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -123
  8. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -108
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -294
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -826
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -107
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -140
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -112
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -477
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -214
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -216
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -182
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -217
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -470
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -134
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -203
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -175
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -269
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -253
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -94
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -175
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -360
  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 -557
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -155
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -320
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -81
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -34
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -360
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -128
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -70
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -58
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -184
  129. package/gradle/libs.versions.toml +0 -67
  130. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  131. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  132. package/gradle.properties +0 -26
  133. package/gradlew +0 -252
  134. package/gradlew.bat +0 -94
  135. package/local.properties +0 -8
  136. package/settings.gradle.kts +0 -64
@@ -1,214 +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.semantics.contentDescription
31
- import androidx.compose.ui.semantics.semantics
32
- import androidx.compose.ui.semantics.testTag
33
- import androidx.compose.ui.text.AnnotatedString
34
- import androidx.compose.ui.text.TextStyle
35
- import androidx.compose.ui.text.input.KeyboardType
36
- import androidx.compose.ui.text.input.OffsetMapping
37
- import androidx.compose.ui.text.input.TransformedText
38
- import androidx.compose.ui.text.input.VisualTransformation
39
- import androidx.compose.ui.unit.dp
40
- import androidx.compose.ui.unit.sp
41
- import androidx.compose.ui.zIndex
42
- import vn.momo.kits.const.AppTheme
43
- import vn.momo.kits.const.Spacing
44
- import vn.momo.kits.application.IsShowBaseLineDebug
45
- import vn.momo.kits.const.Colors
46
- import vn.momo.kits.const.Typography
47
- import vn.momo.kits.modifier.conditional
48
- import vn.momo.kits.utils.formatNumberToMoney
49
-
50
- class CustomConverter : VisualTransformation {
51
- override fun filter(text: AnnotatedString): TransformedText {
52
- if (text.text.isEmpty()) {
53
- return TransformedText(
54
- AnnotatedString("0"),
55
- object : OffsetMapping {
56
- override fun originalToTransformed(offset: Int): Int = 0
57
- override fun transformedToOriginal(offset: Int): Int = 0
58
- }
59
- )
60
- }
61
-
62
- if (text.text == "0") {
63
- return TransformedText(AnnotatedString("0"), OffsetMapping.Identity)
64
- }
65
-
66
- val formattedText = formatNumberToMoney(text.text.toLong())
67
-
68
- return TransformedText(
69
- AnnotatedString(formattedText),
70
- object : OffsetMapping {
71
- override fun originalToTransformed(offset: Int): Int = formattedText.length
72
- override fun transformedToOriginal(offset: Int): Int = text.length
73
- }
74
- )
75
- }
76
- }
77
-
78
- @Composable
79
- fun InputMoney(
80
- text: MutableState<String> = remember { mutableStateOf("0") },
81
- floatingValue: String = "",
82
- floatingValueColor: Color = AppTheme.current.colors.text.hint,
83
- floatingIcon: String = "",
84
- floatingIconColor: Color = AppTheme.current.colors.text.default,
85
- placeholder: String = "0đ",
86
- size: InputSize = InputSize.SMALL,
87
- onChangeText: (String) -> Unit = {},
88
- error: String = "",
89
- errorSpacing: Boolean = false,
90
- disabled: Boolean = false,
91
- icon: String = "",
92
- iconColor: Color = AppTheme.current.colors.text.default,
93
- onPressIcon: () -> Unit = {},
94
- leadingIcon: String = "",
95
- leadingIconColor: Color = AppTheme.current.colors.text.hint,
96
- onFocus: () -> Unit = {},
97
- onBlur: () -> Unit = {},
98
- loading: Boolean = false,
99
- required: Boolean = false,
100
- fontWeight: InputFontWeight = InputFontWeight.BOLD,
101
- keyboardType: KeyboardType = KeyboardType.Number,
102
- ) {
103
- var isFocused by remember { mutableStateOf(false) }
104
- var isBlurred = false
105
- val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) =
106
- getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
107
-
108
- val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
109
-
110
- Column(modifier = Modifier
111
- .conditional(IsShowBaseLineDebug) {
112
- border(1.dp, Colors.blue_03)
113
- }
114
- .semantics {
115
- contentDescription = floatingValue; testTag = testId
116
- }) {
117
- BasicTextField(
118
- enabled = !disabled,
119
- singleLine = true,
120
- value = text.value,
121
- textStyle = TextStyle(
122
- color = textColor,
123
- fontSize = 20.sp,
124
- lineHeight = 24.sp,
125
- fontWeight = fontWeight.value
126
- ),
127
- visualTransformation = CustomConverter(),
128
- keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
129
- modifier = Modifier.height(size.values.height).onFocusChanged {
130
- isFocused = it.isFocused
131
- if (it.isFocused) {
132
- onFocus()
133
- }
134
- if (!it.isFocused && isBlurred) onBlur()
135
- if (it.isFocused && !isBlurred) isBlurred = true
136
- },
137
- onValueChange = {
138
- val numericValue = it.filter { char -> char.isDigit() }
139
- onChangeText(numericValue)
140
- },
141
- decorationBox = { innerTextField ->
142
- // Floating Icon
143
- FloatingLabel(
144
- floatingValue = floatingValue,
145
- floatingIcon = floatingIcon,
146
- titleColor = floatingTitleColor,
147
- iconColor = floatingIconTintColor,
148
- offsetY = -size.values.height / 2,
149
- required = required,
150
- )
151
- //input box wrapper
152
- Box(
153
- modifier = Modifier.fillMaxWidth()
154
- .border(
155
- 1.dp,
156
- getBorderColor(isFocused, error, disabled),
157
- RoundedCornerShape(size.values.borderRadius)
158
- ),
159
- contentAlignment = Alignment.CenterStart
160
- ) {
161
- Row(
162
- modifier = Modifier.padding(horizontal = Spacing.M),
163
- verticalAlignment = Alignment.CenterVertically
164
- ) {
165
- //leading icon
166
- if (leadingIcon.isNotEmpty()) {
167
- Icon(
168
- source = leadingIcon,
169
- modifier = Modifier.padding(end = Spacing.XS),
170
- size = if (size.name == InputSize.SMALL.name) 24.dp else 32.dp,
171
- color = leadingIconColor
172
- )
173
- }
174
- Box(Modifier.weight(9f).padding(start = 0.dp)) {
175
- if (text.value.isEmpty()) {
176
- Text(
177
- text = placeholder,
178
- style = TextStyle(
179
- fontSize = 20.sp,
180
- lineHeight = 24.sp,
181
- fontWeight = fontWeight.value
182
- ),
183
- color = placeholderColor
184
- )
185
- } else {
186
- innerTextField()
187
- }
188
- }
189
- if (isFocused && text.value.isNotEmpty()) {
190
- Row {
191
- Spacer(Modifier.width(Spacing.XS))
192
- Icon(
193
- source = "24_navigation_close_circle_full",
194
- size = 16.dp,
195
- color = AppTheme.current.colors.text.hint,
196
- modifier = Modifier.clickable(
197
- onClick = {
198
- text.value = ""
199
- onChangeText.invoke("")
200
- },
201
- interactionSource = remember { MutableInteractionSource() },
202
- indication = null
203
- )
204
- )
205
- }
206
- }
207
- RenderRightIcon(loading, icon, iconTintColor, onPressIcon)
208
- }
209
- }
210
- },
211
- )
212
- ErrorView(error, errorSpacing, "")
213
- }
214
- }
@@ -1,240 +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
- var isBlurred = false
105
-
106
- val handleChangeText: (String) -> Unit = { text ->
107
- if (text.length <= maxLength &&
108
- (dataType != "number" || !text.any { !it.isDigit() }) &&
109
- (text.length < value.length || value.length < text.length)
110
- ) {
111
- onChangeText(text)
112
- }
113
- }
114
-
115
- fun onClearText(){
116
- handleChangeText("")
117
- }
118
-
119
- val fontSize = scaleSize(20.sp)
120
-
121
- Column(modifier = modifier.conditional(IsShowBaseLineDebug) {
122
- border(1.dp, Colors.blue_03)
123
- }) {
124
- BasicTextField(
125
- value = value,
126
- textStyle = TextStyle(fontSize = fontSize),
127
- onValueChange = handleChangeText,
128
- singleLine = true,
129
- keyboardOptions = KeyboardOptions.Default.copy(keyboardType = if (dataType == "number") KeyboardType.Number else KeyboardType.Ascii),
130
- modifier = modifier.height(56.dp).onFocusChanged {
131
- isFocused = it.isFocused
132
- if (it.isFocused) {
133
- onFocus()
134
- }
135
- if (!it.isFocused && isBlurred) onBlur()
136
- if (it.isFocused && !isBlurred) isBlurred = true
137
- },
138
- decorationBox = { innerTextField ->
139
- Box {
140
- Box(
141
- modifier = Modifier.fillMaxWidth().height(56.dp).alpha(0f)
142
- ) { innerTextField() }
143
- if (floatingValue.isNotEmpty()) {
144
- Box(
145
- modifier = Modifier.wrapContentSize()
146
- .offset(y = ((-56).dp / 2))
147
- .align(Alignment.Center)
148
- .background(AppTheme.current.colors.background.surface)
149
- .zIndex(10f),
150
- ) {
151
- Row(
152
- modifier = Modifier
153
- .padding(horizontal = Spacing.S),
154
- verticalAlignment = Alignment.Bottom
155
- ) {
156
- Text(
157
- floatingValue,
158
- style = Typography.labelSMedium,
159
- color = AppTheme.current.colors.text.hint
160
- )
161
- }
162
- }
163
- }
164
- Box(
165
- modifier = Modifier
166
- .fillMaxWidth()
167
- .height(56.dp)
168
- .border(
169
- 1.dp,
170
- getBorderColor(isFocused, errorMessage, false),
171
- RoundedCornerShape(
172
- Radius.S
173
- )
174
- ), contentAlignment = Alignment.Center
175
- ) {
176
- Row(
177
- modifier = Modifier.padding(vertical = 8.dp),
178
- horizontalArrangement = Arrangement.SpaceBetween,
179
- verticalAlignment = Alignment.CenterVertically
180
- ) {
181
- if (length != null) {
182
- for (i in 0 until length) {
183
- if (isFocused && value.length == i) {
184
- OTPCaret()
185
- } else {
186
- val textColor =
187
- if (value.getOrNull(i) != null) AppTheme.current.colors.text.default else AppTheme.current.colors.text.hint
188
- val typo =
189
- if (value.getOrNull(i) != null) Typography.headerDefaultBold else Typography.descriptionDefaultRegular
190
- Text(
191
- text = value.getOrNull(i)?.toString() ?: "-",
192
- color = textColor,
193
- style = typo
194
- )
195
- }
196
- if (i != length - 1) Spacer(Modifier.width(Spacing.L))
197
- }
198
- } else {
199
- if (value.isEmpty() && !isFocused && placeholder.isNotEmpty()) {
200
- return@BasicTextField Text(
201
- text = placeholder,
202
- color = AppTheme.current.colors.text.hint
203
- )
204
- } else {
205
- for (i in value.indices) {
206
- Text(
207
- style = Typography.headerDefaultBold,
208
- text = value[i].toString()
209
- )
210
- if (i != value.length - 1 || (isFocused && value.length != MAX_LENGTH)) {
211
- Spacer(Modifier.width(Spacing.L))
212
- }
213
- }
214
- if (isFocused && value.length != MAX_LENGTH) OTPCaret()
215
- }
216
- }
217
- }
218
- }
219
- Box(
220
- modifier = Modifier.align(Alignment.Center).zIndex(10f)
221
- ) {
222
- Row(
223
- horizontalArrangement = Arrangement.End,
224
- modifier = Modifier.fillMaxWidth()
225
- ) {
226
- Icon(
227
- "24_navigation_close_circle_full",
228
- size = 12.dp,
229
- modifier = Modifier.padding(end = 12.dp).clickable {
230
- onClearText()
231
- }
232
- )
233
- }
234
- }
235
- }
236
- }
237
- )
238
- ErrorView(errorMessage, errorSpacing, "")
239
- }
240
- }
@@ -1,216 +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.*
8
- import androidx.compose.foundation.shape.RoundedCornerShape
9
- import androidx.compose.foundation.text.BasicTextField
10
- import androidx.compose.foundation.text.KeyboardOptions
11
- import androidx.compose.runtime.*
12
- import androidx.compose.ui.Alignment
13
- import androidx.compose.ui.Modifier
14
- import androidx.compose.ui.focus.onFocusChanged
15
- import androidx.compose.ui.graphics.Color
16
- import androidx.compose.ui.graphics.SolidColor
17
- import androidx.compose.ui.layout.ContentScale
18
- import androidx.compose.ui.text.TextStyle
19
- import androidx.compose.ui.text.input.KeyboardType
20
- import androidx.compose.ui.unit.Dp
21
- import androidx.compose.ui.unit.dp
22
- import vn.momo.kits.application.IsShowBaseLineDebug
23
- import vn.momo.kits.const.*
24
- import vn.momo.kits.modifier.conditional
25
- import vn.momo.kits.modifier.setAutomationId
26
-
27
- data class InputPhoneNumberSizeDetail(
28
- val borderWidth: Dp,
29
- val borderRadius: Dp,
30
- val height: Dp,
31
- val textStyle: TextStyle,
32
- val dividerHeight: Dp,
33
- )
34
-
35
- enum class InputPhoneNumberSize(val values: InputPhoneNumberSizeDetail) {
36
- SMALL(
37
- InputPhoneNumberSizeDetail(
38
- borderWidth = 1.dp,
39
- borderRadius = Radius.S,
40
- height = 48.dp,
41
- textStyle = Typography.headerSSemibold,
42
- dividerHeight = 24.dp
43
- )
44
- ),
45
- LARGE(
46
- InputPhoneNumberSizeDetail(
47
- borderWidth = 1.dp,
48
- borderRadius = Radius.S,
49
- height = 56.dp,
50
- textStyle = Typography.headerMBold,
51
- dividerHeight = 32.dp
52
- )
53
- )
54
- }
55
-
56
- @Composable
57
- private fun getBorderColor(isFocused: Boolean, error: String): Color {
58
- val theme = AppTheme.current
59
- return remember(isFocused, error, theme) {
60
- when {
61
- error.isNotEmpty() -> theme.colors.error.primary
62
- isFocused -> theme.colors.primary
63
- else -> theme.colors.border.default
64
- }
65
- }
66
- }
67
-
68
- @Composable
69
- fun InputPhoneNumber(
70
- text: MutableState<String> = remember { mutableStateOf("") },
71
- placeholder: String = "0123456789",
72
- size: InputPhoneNumberSize = InputPhoneNumberSize.SMALL,
73
- onChangeText: (String) -> Unit = {},
74
- hintText: String = "",
75
- error: String = "",
76
- errorSpacing: Boolean = false,
77
- icon: String = "",
78
- iconColor: Color = AppTheme.current.colors.text.default,
79
- onRightIconPressed: () -> Unit = {},
80
- onFocus: () -> Unit = {},
81
- onBlur: () -> Unit = {},
82
- loading: Boolean = false,
83
- modifier: Modifier = Modifier,
84
- inputModifier: Modifier = Modifier,
85
- ) {
86
- // Consolidated state management
87
- var inputState by remember { mutableStateOf(InputState()) }
88
-
89
- // Memoized color calculations
90
- val theme = AppTheme.current
91
- val colors = remember( theme) {
92
- Triple(
93
- theme.colors.text.default, // textColor
94
- theme.colors.text.hint, // placeholderColor
95
- iconColor // iconTintColor
96
- )
97
- }
98
-
99
- val (textColor, placeholderColor, iconTintColor) = colors
100
- val textStyle = scaleSize(size.values.textStyle.copy(color = textColor))
101
-
102
-
103
- Column(modifier = modifier
104
- .conditional(IsShowBaseLineDebug) {
105
- border(1.dp, Colors.blue_03)
106
- }) {
107
- BasicTextField(
108
- singleLine = true,
109
- value = text.value,
110
- textStyle = textStyle,
111
- keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
112
- cursorBrush = SolidColor(AppTheme.current.colors.primary),
113
- modifier = inputModifier
114
- .height(scaleSize(size.values.height.value).dp)
115
- .onFocusChanged { focusState ->
116
- val wasFocused = inputState.isFocused
117
- inputState = inputState.copy(
118
- isFocused = focusState.isFocused,
119
- hasBeenBlurred = inputState.hasBeenBlurred || wasFocused
120
- )
121
-
122
- if (focusState.isFocused) {
123
- onFocus()
124
- } else if (inputState.hasBeenBlurred) {
125
- onBlur()
126
- }
127
- },
128
- onValueChange = onChangeText,
129
- decorationBox = { innerTextField ->
130
- // Input container
131
- Box(
132
- modifier = Modifier
133
- .fillMaxWidth()
134
- .background(
135
- color = AppTheme.current.colors.background.surface,
136
- shape = RoundedCornerShape(size.values.borderRadius)
137
- )
138
- .border(
139
- if(inputState.isFocused) 1.5.dp else 1.dp,
140
- getBorderColor(inputState.isFocused, error),
141
- RoundedCornerShape(size.values.borderRadius)
142
- ),
143
- contentAlignment = Alignment.CenterStart
144
- ) {
145
- Row(
146
- modifier = Modifier.padding(horizontal = Spacing.M),
147
- verticalAlignment = Alignment.CenterVertically
148
- ) {
149
- // Leading icon
150
- Image(
151
- source = "https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png",
152
- modifier = Modifier.size(24.dp).padding(end = Spacing.XS),
153
- options = Options(
154
- contentScale = ContentScale.Fit,
155
- alignment = Alignment.Center
156
- )
157
- )
158
- Text(
159
- "+84",
160
- color = textColor,
161
- style = size.values.textStyle.copy(color = textColor),
162
- )
163
-
164
- // Divider
165
- Box(modifier = Modifier.padding(horizontal = Spacing.M)) {
166
- Box(
167
- modifier = Modifier.width(1.dp)
168
- .height(size.values.dividerHeight)
169
- .background(Colors.black_04)
170
- )
171
- }
172
-
173
-
174
- Box(Modifier.weight(1f)) {
175
- if (text.value.isEmpty()) {
176
- Text(
177
- text = placeholder,
178
- style = size.values.textStyle.copy(color = placeholderColor),
179
- color = placeholderColor,
180
- modifier = Modifier.align(Alignment.CenterStart)
181
- )
182
- }
183
- innerTextField()
184
- }
185
-
186
- // Clear button
187
- if (inputState.isFocused && text.value.isNotEmpty()) {
188
- Row {
189
- Icon(
190
- source = "24_navigation_close_circle_full",
191
- size = 16.dp,
192
- color = theme.colors.text.hint,
193
- modifier = Modifier.clickable(
194
- onClick = {
195
- text.value = ""
196
- onChangeText.invoke("")
197
- },
198
- interactionSource = remember { MutableInteractionSource() },
199
- indication = null
200
- )
201
- .padding(horizontal = Spacing.S)
202
- .setAutomationId("ic_clear")
203
- )
204
- }
205
- }
206
-
207
- // Right icon (password toggle or custom icon)
208
- RenderRightIcon(loading, icon, iconTintColor, onRightIconPressed)
209
- }
210
- }
211
- },
212
- )
213
- // Error/hint display
214
- ErrorView(error, errorSpacing, hintText)
215
- }
216
- }