@momo-kits/native-kits 0.152.4-beta.3 → 0.152.5

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 (155) hide show
  1. package/package.json +7 -6
  2. package/shared/build.gradle.kts +74 -0
  3. package/CODE_OF_CONDUCT.md +0 -133
  4. package/CONTRIBUTING.md +0 -114
  5. package/LICENSE +0 -20
  6. package/README.md +0 -7
  7. package/build.gradle.kts +0 -32
  8. package/compose/MoMoComposeKits.podspec +0 -54
  9. package/compose/build.gradle.kts +0 -149
  10. package/compose/src/androidMain/AndroidManifest.xml +0 -2
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -105
  12. package/compose/src/commonMain/composeResources/files/lottie_circle_loader.json +0 -1
  13. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  14. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  22. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  23. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  24. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  25. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  26. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -306
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -715
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -214
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -236
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -77
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -27
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -334
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -345
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -90
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -131
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -69
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -143
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -179
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -111
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -384
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -160
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -234
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -223
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -232
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -236
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -228
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -50
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -34
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -85
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -33
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -338
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -95
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -64
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -89
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -84
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -208
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -172
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -199
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -237
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -13
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -191
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -258
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -59
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -49
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -232
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -111
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -94
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -159
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -232
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScaleSizeScope.kt +0 -17
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -459
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -169
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -216
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -180
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -251
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -31
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -385
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -38
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -62
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -88
  110. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -144
  111. package/gradle.properties +0 -19
  112. package/gradlew +0 -240
  113. package/gradlew.bat +0 -91
  114. package/ios/Application/ApplicationEnvironment.swift +0 -50
  115. package/ios/Application/Components.swift +0 -263
  116. package/ios/Application/ComposeApi.swift +0 -22
  117. package/ios/Application/FloatingButton.swift +0 -172
  118. package/ios/Application/HeaderRight.swift +0 -271
  119. package/ios/Application/Screen.swift +0 -249
  120. package/ios/Badge/BadgeDot.swift +0 -31
  121. package/ios/Button/Button.swift +0 -211
  122. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +0 -126
  123. package/ios/Checkbox/Checkbox.swift +0 -81
  124. package/ios/Chip/Chip.swift +0 -96
  125. package/ios/Colors+Radius+Spacing/Colors.swift +0 -172
  126. package/ios/Colors+Radius+Spacing/Radius.swift +0 -22
  127. package/ios/Colors+Radius+Spacing/Spacing.swift +0 -12
  128. package/ios/Extensions/Color++.swift +0 -25
  129. package/ios/Icon/Icon.swift +0 -51
  130. package/ios/Image/Image.swift +0 -70
  131. package/ios/Input/Input.swift +0 -207
  132. package/ios/Input/InputPhoneNumber.swift +0 -176
  133. package/ios/Input/InputSearch.swift +0 -238
  134. package/ios/Input/InputTextArea.swift +0 -242
  135. package/ios/Lottie/LottieView.swift +0 -86
  136. package/ios/OTPKeyboard/KeyboardButton.swift +0 -41
  137. package/ios/OTPKeyboard/OTPKeyboard.swift +0 -145
  138. package/ios/Popup/PopupDisplay.swift +0 -284
  139. package/ios/Popup/PopupInput.swift +0 -96
  140. package/ios/Popup/PopupPromotion.swift +0 -73
  141. package/ios/PopupView/FullscreenPopup.swift +0 -251
  142. package/ios/PopupView/Modifiers.swift +0 -158
  143. package/ios/PopupView/PopupView.swift +0 -289
  144. package/ios/PopupView/Utils++.swift +0 -281
  145. package/ios/ScrollIndicator/ScrollIndicator.swift +0 -110
  146. package/ios/Swipeable/SwipeCell.swift +0 -278
  147. package/ios/Swipeable/SwipeCellModel.swift +0 -86
  148. package/ios/Switch/Switch.swift +0 -44
  149. package/ios/Template/Logo/Logo.swift +0 -75
  150. package/ios/Template/TrustBanner/TrustBanner.swift +0 -120
  151. package/ios/Theme.md +0 -18
  152. package/ios/Typography/Text.swift +0 -140
  153. package/ios/Typography/Typography.swift +0 -95
  154. package/ios/native-kits.podspec +0 -18
  155. package/settings.gradle.kts +0 -25
@@ -1,236 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.clickable
5
- import androidx.compose.foundation.interaction.MutableInteractionSource
6
- import androidx.compose.foundation.layout.Arrangement
7
- import androidx.compose.foundation.layout.Box
8
- import androidx.compose.foundation.layout.Row
9
- import androidx.compose.foundation.layout.Spacer
10
- import androidx.compose.foundation.layout.fillMaxHeight
11
- import androidx.compose.foundation.layout.fillMaxWidth
12
- import androidx.compose.foundation.layout.height
13
- import androidx.compose.foundation.layout.padding
14
- import androidx.compose.foundation.layout.size
15
- import androidx.compose.foundation.layout.width
16
- import androidx.compose.foundation.shape.RoundedCornerShape
17
- import androidx.compose.foundation.text.BasicTextField
18
- import androidx.compose.foundation.text.KeyboardActions
19
- import androidx.compose.foundation.text.KeyboardOptions
20
- import androidx.compose.material3.CircularProgressIndicator
21
- import androidx.compose.runtime.Composable
22
- import androidx.compose.runtime.MutableState
23
- import androidx.compose.runtime.getValue
24
- import androidx.compose.runtime.mutableStateOf
25
- import androidx.compose.runtime.remember
26
- import androidx.compose.runtime.setValue
27
- import androidx.compose.ui.Alignment
28
- import androidx.compose.ui.Modifier
29
- import androidx.compose.ui.focus.onFocusChanged
30
- import androidx.compose.ui.graphics.Color
31
- import androidx.compose.ui.text.TextStyle
32
- import androidx.compose.ui.text.input.KeyboardType
33
- import androidx.compose.ui.text.style.TextOverflow
34
- import androidx.compose.ui.unit.Dp
35
- import androidx.compose.ui.unit.dp
36
- import androidx.compose.ui.unit.sp
37
- import vn.momo.kits.const.AppTheme
38
- import vn.momo.kits.const.Colors
39
- import vn.momo.kits.const.Radius
40
- import vn.momo.kits.const.Spacing
41
- import vn.momo.kits.const.Typography
42
- import vn.momo.kits.utils.ifTrue
43
-
44
- @Composable
45
- fun RenderRightIconSearch(
46
- loading: Boolean,
47
- icon: String,
48
- color: Color,
49
- onClick: () -> Unit,
50
- iconModifier: Modifier = Modifier
51
- ) {
52
- if (loading) {
53
- Box(Modifier.padding(horizontal = Spacing.S)) {
54
- CircularProgressIndicator(
55
- modifier = Modifier.size(16.dp),
56
- color = color,
57
- trackColor = Color.Transparent,
58
- strokeWidth = 2.dp
59
- )
60
- }
61
- }
62
- if (icon.isNotEmpty()) {
63
- Spacer(
64
- Modifier.padding(start = Spacing.S).width(1.dp).fillMaxHeight()
65
- .background(AppTheme.current.colors.primary)
66
- )
67
- Icon(
68
- source = icon,
69
- color = color,
70
- size = 24.dp,
71
- modifier = iconModifier.padding(start = Spacing.S, end = 0.dp).clickable(
72
- onClick = onClick,
73
- interactionSource = remember { MutableInteractionSource() },
74
- indication = null
75
- )
76
- )
77
- }
78
- }
79
-
80
- data class InputSearchProps(
81
- val text: MutableState<String>,
82
- val buttonText: String = "",
83
- val showButtonText: Boolean = false,
84
- val placeholder: String = "",
85
- val onChangeText: (String) -> Unit = {},
86
- val onPressButtonText: () -> Unit = {},
87
- val disabled: Boolean = false,
88
- val icon: String = "",
89
- val iconColor: Color = Color(0xff),
90
- val onRightIconPressed: () -> Unit = {},
91
- val onFocus: () -> Unit = {},
92
- val onBlur: () -> Unit = {},
93
- val loading: Boolean = false,
94
- val fontWeight: InputFontWeight = InputFontWeight.REGULAR,
95
- val keyboardType: KeyboardType = KeyboardType.Text,
96
- val backgroundColor: Color = Colors.black_01,
97
- val clearCondition: (() -> Boolean)? = null,
98
- val keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
99
- val keyboardActions: KeyboardActions = KeyboardActions.Default,
100
- val modifier: Modifier = Modifier,
101
- val iconModifier: Modifier = Modifier,
102
- val onClearPress: () -> Unit = {},
103
- val leftPosition: Dp? = null,
104
- )
105
-
106
- @Composable
107
- fun InputSearch(
108
- inputSearchProps: InputSearchProps = InputSearchProps(
109
- text = remember { mutableStateOf("") },
110
- iconColor = AppTheme.current.colors.text.default
111
- ),
112
- ) {
113
- var isFocused by remember { mutableStateOf(false) }
114
- var isBlurred = false
115
- val disabledColor = AppTheme.current.colors.text.disable
116
- var textColor = AppTheme.current.colors.text.default
117
- var placeholderColor = AppTheme.current.colors.text.hint
118
- var iconTintColor = inputSearchProps.iconColor
119
-
120
- if (inputSearchProps.disabled) {
121
- textColor = disabledColor
122
- placeholderColor = disabledColor
123
- iconTintColor = disabledColor
124
- }
125
-
126
- Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
127
- BasicTextField(
128
- enabled = !inputSearchProps.disabled,
129
- singleLine = true,
130
- value = inputSearchProps.text.value,
131
- textStyle = TextStyle(
132
- color = textColor,
133
- fontSize = 14.sp,
134
- lineHeight = 20.sp,
135
- fontWeight = inputSearchProps.fontWeight.value
136
- ),
137
- keyboardOptions = inputSearchProps.keyboardOptions.copy(keyboardType = inputSearchProps.keyboardType),
138
- keyboardActions = inputSearchProps.keyboardActions,
139
- modifier = inputSearchProps.modifier.weight(1f).height(36.dp).onFocusChanged {
140
- isFocused = it.isFocused
141
- if (it.isFocused) {
142
- inputSearchProps.onFocus()
143
- }
144
- if (!it.isFocused && isBlurred) inputSearchProps.onBlur()
145
- if (it.isFocused && !isBlurred) isBlurred = true
146
- },
147
- onValueChange = inputSearchProps.onChangeText,
148
- decorationBox = { innerTextField ->
149
- Row(verticalAlignment = Alignment.CenterVertically) {
150
- Row(
151
- modifier = Modifier.weight(
152
- inputSearchProps.showButtonText.ifTrue(
153
- 8f,
154
- 1f
155
- )
156
- )
157
- .background(
158
- inputSearchProps.backgroundColor,
159
- RoundedCornerShape(Radius.XL)
160
- ),
161
- horizontalArrangement = Arrangement.Start,
162
- verticalAlignment = Alignment.CenterVertically
163
- ) {
164
- Row(
165
- modifier = Modifier.padding(
166
- horizontal = Spacing.M,
167
- vertical = Spacing.S
168
- ),
169
- verticalAlignment = Alignment.CenterVertically
170
- ) {
171
- Icon(
172
- source = "navigation_search",
173
- modifier = Modifier.padding(end = Spacing.XS),
174
- size = 24.dp,
175
- color = AppTheme.current.colors.text.hint
176
- )
177
- Box(Modifier.weight(1f)) {
178
- if (inputSearchProps.text.value.isEmpty()) {
179
- Text(
180
- text = inputSearchProps.placeholder,
181
- style = TextStyle(
182
- fontSize = 14.sp,
183
- lineHeight = 20.sp,
184
- fontWeight = inputSearchProps.fontWeight.value
185
- ),
186
- maxLines = 1,
187
- color = placeholderColor,
188
- overflow = TextOverflow.Ellipsis
189
- )
190
- }
191
- innerTextField()
192
- }
193
- if (inputSearchProps.clearCondition?.invoke() == true || (isFocused && inputSearchProps.text.value.isNotEmpty())) {
194
- Row {
195
- Spacer(Modifier.width(Spacing.XS))
196
- Icon(
197
- source = "24_navigation_close_circle_full",
198
- size = 16.dp,
199
- color = AppTheme.current.colors.text.hint,
200
- modifier = Modifier.clickable(
201
- onClick = {
202
- inputSearchProps.text.value = ""
203
- inputSearchProps.onClearPress.invoke()
204
- },
205
- interactionSource = remember { MutableInteractionSource() },
206
- indication = null
207
- )
208
- )
209
- }
210
- }
211
- RenderRightIconSearch(
212
- inputSearchProps.loading,
213
- inputSearchProps.icon,
214
- iconTintColor,
215
- inputSearchProps.onRightIconPressed,
216
- iconModifier = inputSearchProps.iconModifier
217
- )
218
- }
219
- }
220
- }
221
- },
222
- )
223
- if (inputSearchProps.showButtonText) {
224
- Text(
225
- text = inputSearchProps.buttonText,
226
- style = Typography.actionDefaultBold,
227
- color = AppTheme.current.colors.text.default,
228
- modifier = Modifier.padding(start = Spacing.L).clickable(
229
- interactionSource = remember { MutableInteractionSource() },
230
- indication = null,
231
- onClick = inputSearchProps.onPressButtonText
232
- )
233
- )
234
- }
235
- }
236
- }
@@ -1,228 +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.text.TextStyle
31
- import androidx.compose.ui.text.input.KeyboardType
32
- import androidx.compose.ui.unit.Dp
33
- import androidx.compose.ui.unit.dp
34
- import androidx.compose.ui.unit.sp
35
- import androidx.compose.ui.zIndex
36
- import vn.momo.kits.const.AppTheme
37
- import vn.momo.kits.const.Spacing
38
- import vn.momo.kits.const.Typography
39
-
40
- const val MAX_LENGTH = 300
41
- val DEFAULT_HEIGHT = 104.dp
42
-
43
- @Composable
44
- fun InputTextArea(
45
- text: MutableState<String> = remember { mutableStateOf("") },
46
- maxLength: Int = MAX_LENGTH,
47
- height: Dp = DEFAULT_HEIGHT,
48
- floatingValue: String = "",
49
- floatingValueColor: Color = AppTheme.current.colors.text.hint,
50
- floatingIcon: String = "",
51
- floatingIconColor: Color = AppTheme.current.colors.text.default,
52
- placeholder: String = "",
53
- size: InputSize = InputSize.SMALL,
54
- onChangeText: (String) -> Unit = {},
55
- error: String = "",
56
- errorSpacing: Boolean = false,
57
- disabled: Boolean = false,
58
- icon: String = "",
59
- iconColor: Color = AppTheme.current.colors.text.default,
60
- onRightIconPressed: () -> Unit = {},
61
- onFocus: () -> Unit = {},
62
- onBlur: () -> Unit = {},
63
- loading: Boolean = false,
64
- required: Boolean = false,
65
- fontWeight: InputFontWeight = InputFontWeight.REGULAR,
66
- keyboardType: KeyboardType = KeyboardType.Text,
67
- ) {
68
- var isFocused by remember { mutableStateOf(false) }
69
- var isBlurred = false
70
- val disabledColor = AppTheme.current.colors.text.disable
71
- var textColor = AppTheme.current.colors.text.default
72
- var placeholderColor = AppTheme.current.colors.text.hint
73
- var iconTintColor = iconColor
74
- val floatingTitleColor = when {
75
- disabled -> AppTheme.current.colors.text.disable
76
- else -> floatingValueColor
77
- }
78
- val floatingIconTintColor = when {
79
- disabled -> AppTheme.current.colors.text.disable
80
- else -> floatingIconColor
81
- }
82
-
83
- if (disabled) {
84
- textColor = disabledColor
85
- placeholderColor = disabledColor
86
- iconTintColor = disabledColor
87
- }
88
-
89
-
90
-
91
- Column {
92
- BasicTextField(
93
- enabled = !disabled,
94
- singleLine = false,
95
- value = text.value,
96
- textStyle = TextStyle(
97
- color = textColor,
98
- fontSize = 16.sp,
99
- lineHeight = 24.sp,
100
- fontWeight = fontWeight.value
101
- ),
102
- keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
103
- modifier = Modifier.height(height).onFocusChanged {
104
- isFocused = it.isFocused
105
- if (it.isFocused) {
106
- onFocus()
107
- }
108
- if (!it.isFocused && isBlurred) onBlur()
109
- if (it.isFocused && !isBlurred) isBlurred = true
110
- },
111
- onValueChange = {
112
- if (it.length <= maxLength) {
113
- onChangeText(it)
114
- }
115
- },
116
- decorationBox = { innerTextField ->
117
- // Floating Icon
118
- if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
119
- Box(
120
- modifier = Modifier.wrapContentSize()
121
- .offset(y = (-height / 2), x = (Spacing.S))
122
- .background(AppTheme.current.colors.background.surface)
123
- .zIndex(10f),
124
- ) {
125
- Row(
126
- modifier = Modifier
127
- .padding(horizontal = Spacing.S),
128
- verticalAlignment = Alignment.Bottom
129
- ) {
130
- Text(
131
- floatingValue,
132
- style = Typography.labelSMedium,
133
- color = floatingTitleColor
134
- )
135
- if (required) {
136
- Text(
137
- "*",
138
- style = Typography.labelSMedium,
139
- color = AppTheme.current.colors.error.primary,
140
- )
141
- }
142
- if (floatingIcon.isNotEmpty()) {
143
- Icon(
144
- source = floatingIcon,
145
- modifier = Modifier.padding(start = Spacing.XS),
146
- size = 16.dp,
147
- color = floatingIconTintColor
148
- )
149
- }
150
- }
151
- }
152
- }
153
- //input box wrapper
154
- Box(
155
- modifier = Modifier.fillMaxWidth()
156
- .background(
157
- AppTheme.current.colors.background.surface,
158
- RoundedCornerShape(size.values.borderRadius)
159
- )
160
- .border(
161
- 1.dp,
162
- getBorderColor(isFocused, error, disabled),
163
- RoundedCornerShape(size.values.borderRadius)
164
- ),
165
- contentAlignment = Alignment.TopStart
166
- ) {
167
- Column {
168
- Row(
169
- modifier = Modifier.weight(9f).padding(
170
- horizontal = Spacing.M,
171
- vertical = Spacing.M
172
- ),
173
- verticalAlignment = Alignment.Top
174
- ) {
175
- Box(Modifier.weight(1f)) {
176
- if (text.value.isEmpty()) {
177
- Text(
178
- text = placeholder,
179
- style = TextStyle(
180
- fontSize = 16.sp,
181
- lineHeight = 24.sp,
182
- fontWeight = fontWeight.value
183
- ),
184
- color = placeholderColor
185
- )
186
- }
187
- innerTextField()
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 = { text.value = "" },
198
- interactionSource = remember { MutableInteractionSource() },
199
- indication = null
200
- )
201
- )
202
- }
203
- }
204
- RenderRightIcon(loading, icon, iconTintColor, onRightIconPressed)
205
- }
206
-
207
- Box(
208
- modifier = Modifier
209
- .weight(1.5f)
210
- .fillMaxWidth()
211
- .padding(end = Spacing.M),
212
- contentAlignment = Alignment.CenterEnd
213
- ) {
214
- Text(
215
- "${text.value.length}/$maxLength",
216
- style = Typography.descriptionXsRegular,
217
- color = AppTheme.current.colors.text.hint
218
- )
219
- }
220
- Spacer(Modifier.height(Spacing.M))
221
- }
222
- }
223
- },
224
- )
225
- // show error
226
- ErrorView(error, errorSpacing, "")
227
- }
228
- }