@momo-kits/native-kits 0.155.1-tracking.13 → 0.155.1-tracking.14-debug

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 (116) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +180 -0
  3. package/compose/compose.podspec +54 -0
  4. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +113 -0
  5. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  6. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  7. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +95 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +715 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +35 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +343 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +353 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +98 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +138 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +78 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +151 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +190 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +119 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +407 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +175 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +244 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +233 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +257 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +240 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +59 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +44 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +95 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +43 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +351 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +106 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +72 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +99 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +99 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +95 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +132 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +217 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +180 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +208 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +189 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +15 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +271 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +152 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +95 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +162 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +347 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +551 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +169 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +233 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +190 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +258 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +135 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +218 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
  106. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +152 -0
  107. package/gradle/libs.versions.toml +57 -0
  108. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  109. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  110. package/gradle.properties +26 -0
  111. package/gradlew +252 -0
  112. package/gradlew.bat +94 -0
  113. package/local.properties +8 -0
  114. package/package.json +1 -1
  115. package/publish_release.sh +105 -0
  116. package/settings.gradle.kts +52 -0
@@ -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.fillMaxWidth
11
+ import androidx.compose.foundation.layout.height
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.shape.RoundedCornerShape
16
+ import androidx.compose.foundation.text.BasicTextField
17
+ import androidx.compose.foundation.text.KeyboardOptions
18
+ import androidx.compose.runtime.Composable
19
+ import androidx.compose.runtime.MutableState
20
+ import androidx.compose.runtime.getValue
21
+ import androidx.compose.runtime.mutableStateOf
22
+ import androidx.compose.runtime.remember
23
+ import androidx.compose.runtime.setValue
24
+ import androidx.compose.ui.Alignment
25
+ import androidx.compose.ui.Modifier
26
+ import androidx.compose.ui.focus.onFocusChanged
27
+ import androidx.compose.ui.graphics.Color
28
+ import androidx.compose.ui.graphics.SolidColor
29
+ import androidx.compose.ui.layout.ContentScale
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 vn.momo.kits.const.AppTheme
35
+ import vn.momo.kits.const.Colors
36
+ import vn.momo.kits.const.Radius
37
+ import vn.momo.kits.const.Spacing
38
+ import vn.momo.kits.application.ApplicationContext
39
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
40
+ import vn.momo.kits.const.Typography
41
+ import vn.momo.kits.const.scaleSize
42
+ import vn.momo.kits.modifier.conditional
43
+ import vn.momo.kits.modifier.setAutomationId
44
+
45
+ data class InputPhoneNumberSizeDetail(
46
+ val borderWidth: Dp,
47
+ val borderRadius: Dp,
48
+ val height: Dp,
49
+ val textStyle: TextStyle,
50
+ val dividerHeight: Dp,
51
+ )
52
+
53
+ enum class InputPhoneNumberSize(val values: InputPhoneNumberSizeDetail) {
54
+ SMALL(
55
+ InputPhoneNumberSizeDetail(
56
+ borderWidth = 1.dp,
57
+ borderRadius = Radius.S,
58
+ height = 48.dp,
59
+ textStyle = Typography.headerSSemibold,
60
+ dividerHeight = 24.dp
61
+ )
62
+ ),
63
+ LARGE(
64
+ InputPhoneNumberSizeDetail(
65
+ borderWidth = 1.dp,
66
+ borderRadius = Radius.S,
67
+ height = 56.dp,
68
+ textStyle = Typography.headerMBold,
69
+ dividerHeight = 32.dp
70
+ )
71
+ )
72
+ }
73
+
74
+ @Composable
75
+ fun getBorderColor(isFocused: Boolean, error: String): Color {
76
+ val theme = AppTheme.current
77
+ return remember(isFocused, error, theme) {
78
+ when {
79
+ error.isNotEmpty() -> theme.colors.error.primary
80
+ isFocused -> theme.colors.primary
81
+ else -> theme.colors.border.default
82
+ }
83
+ }
84
+ }
85
+
86
+ @Composable
87
+ fun InputPhoneNumber(
88
+ text: MutableState<String> = remember { mutableStateOf("") },
89
+ placeholder: String = "0123456789",
90
+ size: InputPhoneNumberSize = InputPhoneNumberSize.SMALL,
91
+ onChangeText: (String) -> Unit = {},
92
+ hintText: String = "",
93
+ error: String = "",
94
+ errorSpacing: Boolean = false,
95
+ icon: String = "",
96
+ iconColor: Color = AppTheme.current.colors.text.default,
97
+ onRightIconPressed: () -> Unit = {},
98
+ onFocus: () -> Unit = {},
99
+ onBlur: () -> Unit = {},
100
+ loading: Boolean = false,
101
+ modifier: Modifier = Modifier,
102
+ ) {
103
+ // Consolidated state management
104
+ var inputState by remember { mutableStateOf(InputState()) }
105
+
106
+ // Memoized color calculations
107
+ val theme = AppTheme.current
108
+ val colors = remember( theme) {
109
+ Triple(
110
+ theme.colors.text.default, // textColor
111
+ theme.colors.text.hint, // placeholderColor
112
+ iconColor // iconTintColor
113
+ )
114
+ }
115
+
116
+ val (textColor, placeholderColor, iconTintColor) = colors
117
+
118
+ val testId = "input_phone_number"
119
+ val application = ApplicationContext.current
120
+
121
+ val textStyle = scaleSize(size.values.textStyle.copy(color = textColor))
122
+
123
+ Column(modifier = modifier
124
+ .conditional(application.isShowBaselineDebug()) {
125
+ border(1.dp, Colors.blue_03)
126
+ }
127
+ .setAutomationId(testId)) {
128
+ BasicTextField(
129
+ singleLine = true,
130
+ value = text.value,
131
+ textStyle = textStyle,
132
+ keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
133
+ cursorBrush = SolidColor(AppTheme.current.colors.primary),
134
+ modifier = Modifier
135
+ .height(scaleSize(size.values.height.value, 1.1f).dp)
136
+ .onFocusChanged { focusState ->
137
+ val wasFocused = inputState.isFocused
138
+ inputState = inputState.copy(
139
+ isFocused = focusState.isFocused,
140
+ hasBeenBlurred = inputState.hasBeenBlurred || wasFocused
141
+ )
142
+
143
+ if (focusState.isFocused) {
144
+ onFocus()
145
+ } else if (inputState.hasBeenBlurred) {
146
+ onBlur()
147
+ }
148
+ },
149
+ onValueChange = onChangeText,
150
+ decorationBox = { innerTextField ->
151
+ // Input container
152
+ Box(
153
+ modifier = Modifier
154
+ .fillMaxWidth()
155
+ .background(
156
+ color = AppTheme.current.colors.background.surface,
157
+ shape = RoundedCornerShape(size.values.borderRadius)
158
+ )
159
+ .border(
160
+ if(inputState.isFocused) 1.5.dp else 1.dp,
161
+ getBorderColor(inputState.isFocused, error),
162
+ RoundedCornerShape(size.values.borderRadius)
163
+ ),
164
+ contentAlignment = Alignment.CenterStart
165
+ ) {
166
+ Row(
167
+ modifier = Modifier.padding(horizontal = Spacing.M),
168
+ verticalAlignment = Alignment.CenterVertically
169
+ ) {
170
+ // Leading icon
171
+ Image(
172
+ source = "https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png",
173
+ modifier = Modifier.size(24.dp).padding(end = Spacing.XS),
174
+ options = Options(
175
+ contentScale = ContentScale.Fit,
176
+ alignment = Alignment.Center
177
+ )
178
+ )
179
+ Text(
180
+ "+84",
181
+ color = textColor,
182
+ style = size.values.textStyle.copy(color = textColor),
183
+ )
184
+
185
+ // Divider
186
+ Box(modifier = Modifier.padding(horizontal = Spacing.M)) {
187
+ Box(
188
+ modifier = Modifier.width(1.dp)
189
+ .height(size.values.dividerHeight)
190
+ .background(Colors.black_04)
191
+ )
192
+ }
193
+
194
+
195
+ Box(Modifier.weight(1f)) {
196
+ if (text.value.isEmpty()) {
197
+ Text(
198
+ text = placeholder,
199
+ style = size.values.textStyle.copy(color = placeholderColor),
200
+ color = placeholderColor,
201
+ modifier = Modifier.align(Alignment.CenterStart)
202
+ )
203
+ }
204
+ innerTextField()
205
+ }
206
+
207
+ // Clear button
208
+ if (inputState.isFocused && text.value.isNotEmpty()) {
209
+ Row {
210
+ Icon(
211
+ source = "24_navigation_close_circle_full",
212
+ size = 16.dp,
213
+ color = theme.colors.text.hint,
214
+ modifier = Modifier.clickable(
215
+ onClick = { text.value = "" },
216
+ interactionSource = remember { MutableInteractionSource() },
217
+ indication = null
218
+ )
219
+ .padding(horizontal = Spacing.S)
220
+ )
221
+ }
222
+ }
223
+
224
+ // Right icon (password toggle or custom icon)
225
+ RenderRightIcon(loading, icon, iconTintColor, onRightIconPressed)
226
+ }
227
+ }
228
+ },
229
+ )
230
+ // Error/hint display
231
+ ErrorView(error, errorSpacing, hintText)
232
+ }
233
+ }
@@ -0,0 +1,257 @@
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.Arrangement
8
+ import androidx.compose.foundation.layout.Box
9
+ import androidx.compose.foundation.layout.Row
10
+ import androidx.compose.foundation.layout.Spacer
11
+ import androidx.compose.foundation.layout.fillMaxHeight
12
+ import androidx.compose.foundation.layout.fillMaxWidth
13
+ import androidx.compose.foundation.layout.height
14
+ import androidx.compose.foundation.layout.padding
15
+ import androidx.compose.foundation.layout.size
16
+ import androidx.compose.foundation.layout.width
17
+ import androidx.compose.foundation.shape.RoundedCornerShape
18
+ import androidx.compose.foundation.text.BasicTextField
19
+ import androidx.compose.foundation.text.KeyboardActions
20
+ import androidx.compose.foundation.text.KeyboardOptions
21
+ import androidx.compose.material3.CircularProgressIndicator
22
+ import androidx.compose.runtime.Composable
23
+ import androidx.compose.runtime.MutableState
24
+ import androidx.compose.runtime.getValue
25
+ import androidx.compose.runtime.mutableStateOf
26
+ import androidx.compose.runtime.remember
27
+ import androidx.compose.runtime.setValue
28
+ import androidx.compose.ui.Alignment
29
+ import androidx.compose.ui.Modifier
30
+ import androidx.compose.ui.focus.onFocusChanged
31
+ import androidx.compose.ui.graphics.Color
32
+ import androidx.compose.ui.text.TextStyle
33
+ import androidx.compose.ui.text.input.KeyboardType
34
+ import androidx.compose.ui.text.style.TextOverflow
35
+ import androidx.compose.ui.unit.Dp
36
+ import androidx.compose.ui.unit.dp
37
+ import androidx.compose.ui.unit.sp
38
+ import vn.momo.kits.const.AppTheme
39
+ import vn.momo.kits.const.Colors
40
+ import vn.momo.kits.const.Radius
41
+ import vn.momo.kits.const.Spacing
42
+ import vn.momo.kits.application.ApplicationContext
43
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
44
+ import vn.momo.kits.const.Typography
45
+ import vn.momo.kits.const.scaleSize
46
+ import vn.momo.kits.modifier.conditional
47
+ import vn.momo.kits.utils.ifTrue
48
+
49
+ @Composable
50
+ fun RenderRightIconSearch(
51
+ loading: Boolean,
52
+ icon: String,
53
+ color: Color,
54
+ onClick: () -> Unit,
55
+ iconModifier: Modifier = Modifier
56
+ ) {
57
+ if (loading) {
58
+ Box(Modifier.padding(horizontal = Spacing.S)) {
59
+ CircularProgressIndicator(
60
+ modifier = Modifier.size(16.dp),
61
+ color = color,
62
+ trackColor = Color.Transparent,
63
+ strokeWidth = 2.dp
64
+ )
65
+ }
66
+ }
67
+ if (icon.isNotEmpty()) {
68
+ Spacer(
69
+ Modifier.padding(start = Spacing.S, top = Spacing.S, bottom = Spacing.S).width(1.dp).fillMaxHeight()
70
+ .background(AppTheme.current.colors.primary)
71
+ )
72
+ Icon(
73
+ source = icon,
74
+ color = color,
75
+ size = 24.dp,
76
+ modifier = iconModifier.padding(start = Spacing.S, end = 0.dp).clickable(
77
+ onClick = onClick,
78
+ interactionSource = remember { MutableInteractionSource() },
79
+ indication = null
80
+ )
81
+ )
82
+ }
83
+ }
84
+
85
+ data class InputSearchProps(
86
+ val text: MutableState<String>,
87
+ val buttonText: String = "",
88
+ val showButtonText: Boolean = false,
89
+ val placeholder: String = "",
90
+ val onChangeText: (String) -> Unit = {},
91
+ val onPressButtonText: () -> Unit = {},
92
+ val disabled: Boolean = false,
93
+ val icon: String = "",
94
+ val iconColor: Color = Color(0xff),
95
+ val onRightIconPressed: () -> Unit = {},
96
+ val onFocus: () -> Unit = {},
97
+ val onBlur: () -> Unit = {},
98
+ val loading: Boolean = false,
99
+ val fontWeight: InputFontWeight = InputFontWeight.REGULAR,
100
+ val keyboardType: KeyboardType = KeyboardType.Text,
101
+ val backgroundColor: Color = Colors.black_01,
102
+ val clearCondition: (() -> Boolean)? = null,
103
+ val keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
104
+ val keyboardActions: KeyboardActions = KeyboardActions.Default,
105
+ val modifier: Modifier = Modifier,
106
+ val iconModifier: Modifier = Modifier,
107
+ val onClearPress: () -> Unit = {},
108
+ val leftPosition: Dp? = null,
109
+ )
110
+
111
+ @Composable
112
+ fun InputSearch(
113
+ inputSearchProps: InputSearchProps = InputSearchProps(
114
+ text = remember { mutableStateOf("") },
115
+ iconColor = AppTheme.current.colors.text.default
116
+ ),
117
+ ) {
118
+ var isFocused by remember { mutableStateOf(false) }
119
+ var isBlurred = false
120
+ val disabledColor = AppTheme.current.colors.text.disable
121
+ var textColor = AppTheme.current.colors.text.default
122
+ var placeholderColor = AppTheme.current.colors.text.hint
123
+ var iconTintColor = inputSearchProps.iconColor
124
+
125
+ if (inputSearchProps.disabled) {
126
+ textColor = disabledColor
127
+ placeholderColor = disabledColor
128
+ iconTintColor = disabledColor
129
+ }
130
+ val fontSize = 14.sp
131
+ val scaleFontSize = scaleSize(fontSize)
132
+
133
+ val textStyle = remember(textColor, inputSearchProps.fontWeight.value) {
134
+ TextStyle(
135
+ color = textColor,
136
+ fontSize = scaleFontSize,
137
+ fontWeight = inputSearchProps.fontWeight.value
138
+ )
139
+ }
140
+
141
+ val placeHolderStyle = remember(textColor, inputSearchProps.fontWeight.value) {
142
+ TextStyle(
143
+ color = textColor,
144
+ fontSize = fontSize,
145
+ fontWeight = inputSearchProps.fontWeight.value
146
+ )
147
+ }
148
+
149
+ val application = ApplicationContext.current
150
+
151
+ Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier
152
+ .fillMaxWidth()
153
+ .height(36.dp)
154
+ .conditional(application.isShowBaselineDebug()) {
155
+ border(1.dp, Colors.blue_03)
156
+ }
157
+ ) {
158
+ BasicTextField(
159
+ enabled = !inputSearchProps.disabled,
160
+ singleLine = true,
161
+ value = inputSearchProps.text.value,
162
+ textStyle = textStyle,
163
+ keyboardOptions = inputSearchProps.keyboardOptions.copy(keyboardType = inputSearchProps.keyboardType),
164
+ keyboardActions = inputSearchProps.keyboardActions,
165
+ modifier = inputSearchProps.modifier.weight(1f).fillMaxHeight().onFocusChanged {
166
+ isFocused = it.isFocused
167
+ if (it.isFocused) {
168
+ inputSearchProps.onFocus()
169
+ }
170
+ if (!it.isFocused && isBlurred) inputSearchProps.onBlur()
171
+ if (it.isFocused && !isBlurred) isBlurred = true
172
+ },
173
+ onValueChange = inputSearchProps.onChangeText,
174
+ decorationBox = { innerTextField ->
175
+ Row(verticalAlignment = Alignment.CenterVertically) {
176
+ Row(
177
+ modifier = Modifier.weight(
178
+ inputSearchProps.showButtonText.ifTrue(
179
+ 8f,
180
+ 1f
181
+ )
182
+ ).fillMaxHeight()
183
+ .background(
184
+ inputSearchProps.backgroundColor,
185
+ RoundedCornerShape(Radius.XL)
186
+ ),
187
+ horizontalArrangement = Arrangement.Start,
188
+ verticalAlignment = Alignment.CenterVertically
189
+ ) {
190
+ Row(
191
+ modifier = Modifier.padding(
192
+ horizontal = Spacing.M
193
+ ),
194
+ verticalAlignment = Alignment.CenterVertically
195
+ ) {
196
+ Icon(
197
+ source = "navigation_search",
198
+ modifier = Modifier.padding(end = Spacing.XS),
199
+ size = 24.dp,
200
+ color = AppTheme.current.colors.text.hint
201
+ )
202
+ Box(Modifier.weight(1f)) {
203
+ if (inputSearchProps.text.value.isEmpty()) {
204
+ Text(
205
+ text = inputSearchProps.placeholder,
206
+ style = placeHolderStyle,
207
+ maxLines = 1,
208
+ color = placeholderColor,
209
+ overflow = TextOverflow.Ellipsis
210
+ )
211
+ }
212
+ innerTextField()
213
+ }
214
+ if (inputSearchProps.clearCondition?.invoke() == true || (isFocused && inputSearchProps.text.value.isNotEmpty())) {
215
+ Row {
216
+ Spacer(Modifier.width(Spacing.XS))
217
+ Icon(
218
+ source = "24_navigation_close_circle_full",
219
+ size = 16.dp,
220
+ color = AppTheme.current.colors.text.hint,
221
+ modifier = Modifier.clickable(
222
+ onClick = {
223
+ inputSearchProps.text.value = ""
224
+ inputSearchProps.onClearPress.invoke()
225
+ },
226
+ interactionSource = remember { MutableInteractionSource() },
227
+ indication = null
228
+ )
229
+ )
230
+ }
231
+ }
232
+ RenderRightIconSearch(
233
+ inputSearchProps.loading,
234
+ inputSearchProps.icon,
235
+ iconTintColor,
236
+ inputSearchProps.onRightIconPressed,
237
+ iconModifier = inputSearchProps.iconModifier
238
+ )
239
+ }
240
+ }
241
+ }
242
+ },
243
+ )
244
+ if (inputSearchProps.showButtonText) {
245
+ Text(
246
+ text = inputSearchProps.buttonText,
247
+ style = Typography.actionDefaultBold,
248
+ color = AppTheme.current.colors.text.default,
249
+ modifier = Modifier.padding(start = Spacing.L).clickable(
250
+ interactionSource = remember { MutableInteractionSource() },
251
+ indication = null,
252
+ onClick = inputSearchProps.onPressButtonText
253
+ )
254
+ )
255
+ }
256
+ }
257
+ }