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