@momo-kits/native-kits 0.152.4-beta.2 → 0.152.4-beta.3
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 +7 -0
- 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 +306 -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 +236 -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 +77 -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 +131 -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 +384 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +160 -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 +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +228 -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/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 +84 -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 +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +258 -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 +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScaleSizeScope.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +459 -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 +216 -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/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/Application/ApplicationEnvironment.swift +50 -0
- package/ios/Application/Components.swift +263 -0
- package/ios/Application/ComposeApi.swift +22 -0
- package/ios/Application/FloatingButton.swift +172 -0
- package/ios/Application/HeaderRight.swift +271 -0
- package/ios/Application/Screen.swift +249 -0
- package/ios/Badge/BadgeDot.swift +31 -0
- package/ios/Button/Button.swift +211 -0
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
- package/ios/Checkbox/Checkbox.swift +81 -0
- package/ios/Chip/Chip.swift +96 -0
- package/ios/Colors+Radius+Spacing/Colors.swift +172 -0
- package/ios/Colors+Radius+Spacing/Radius.swift +22 -0
- package/ios/Colors+Radius+Spacing/Spacing.swift +12 -0
- package/ios/Extensions/Color++.swift +25 -0
- package/ios/Icon/Icon.swift +51 -0
- package/ios/Image/Image.swift +70 -0
- package/ios/Input/Input.swift +207 -0
- package/ios/Input/InputPhoneNumber.swift +176 -0
- package/ios/Input/InputSearch.swift +238 -0
- package/ios/Input/InputTextArea.swift +242 -0
- package/ios/Lottie/LottieView.swift +86 -0
- package/ios/OTPKeyboard/KeyboardButton.swift +41 -0
- package/ios/OTPKeyboard/OTPKeyboard.swift +145 -0
- package/ios/Popup/PopupDisplay.swift +284 -0
- package/ios/Popup/PopupInput.swift +96 -0
- package/ios/Popup/PopupPromotion.swift +73 -0
- package/ios/PopupView/FullscreenPopup.swift +251 -0
- package/ios/PopupView/Modifiers.swift +158 -0
- package/ios/PopupView/PopupView.swift +289 -0
- package/ios/PopupView/Utils++.swift +281 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +110 -0
- package/ios/Swipeable/SwipeCell.swift +278 -0
- package/ios/Swipeable/SwipeCellModel.swift +86 -0
- package/ios/Switch/Switch.swift +44 -0
- package/ios/Template/Logo/Logo.swift +75 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +120 -0
- package/ios/Theme.md +18 -0
- package/ios/Typography/Text.swift +140 -0
- package/ios/Typography/Typography.swift +95 -0
- package/ios/native-kits.podspec +18 -0
- package/package.json +6 -7
- package/settings.gradle.kts +25 -0
- package/shared/build.gradle.kts +0 -74
|
@@ -0,0 +1,236 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
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
|
+
}
|