@momo-kits/native-kits 0.0.1-beta.4 → 0.89.1-2

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 (195) hide show
  1. package/README.md +1 -0
  2. package/android/.gradle/8.0/checksums/checksums.lock +0 -0
  3. package/android/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/8.0/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/8.0/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/8.0/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/8.0/gc.properties +0 -0
  8. package/android/.gradle/config.properties +2 -0
  9. package/android/.gradle/vcs-1/gc.properties +0 -0
  10. package/android/.idea/gradle.xml +12 -0
  11. package/android/.idea/migrations.xml +10 -0
  12. package/android/.idea/misc.xml +10 -0
  13. package/android/.idea/vcs.xml +6 -0
  14. package/android/.idea/workspace.xml +50 -0
  15. package/android/build.gradle +35 -69
  16. package/android/local.properties +8 -0
  17. package/android/proguard-rules.pro +21 -0
  18. package/android/src/main/AndroidManifest.xml +2 -2
  19. package/android/src/main/java/com/momoplatform/nativekits/foundations/Button.kt +16 -0
  20. package/android/src/main/java/com/momoplatform/nativekits/libs/Logo.kt +63 -0
  21. package/android/src/main/java/com/momoplatform/nativekits/libs/TrustBanner.kt +246 -0
  22. package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
  23. package/android/src/main/res/drawable-v24/ic_launcher_foreground.xml +30 -0
  24. package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
  25. package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
  26. package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
  27. package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
  28. package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
  29. package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
  30. package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
  31. package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
  32. package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
  33. package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
  34. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
  35. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
  36. package/android/src/main/res/values/colors.xml +10 -0
  37. package/android/src/main/res/values/strings.xml +3 -0
  38. package/android/src/main/res/values/themes.xml +3 -0
  39. package/android/src/main/res/values-night/themes.xml +3 -0
  40. package/android/src/main/res/xml/backup_rules.xml +13 -0
  41. package/android/src/main/res/xml/data_extraction_rules.xml +19 -0
  42. package/build.gradle.kts +18 -0
  43. package/compose/build.gradle.kts +82 -0
  44. package/compose/src/androidMain/AndroidManifest.xml +2 -0
  45. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
  46. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +8 -0
  47. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Utils.android.kt +14 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Components.kt +194 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +197 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +133 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +62 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +27 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +288 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +80 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +42 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +126 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +51 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +299 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +246 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +223 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +244 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +281 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PromotionPopup.kt +72 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +65 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +64 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +63 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +73 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +42 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +150 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +173 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +242 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +2 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1321 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +5 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +97 -0
  83. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
  84. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +9 -0
  85. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Utils.ios.kt +18 -0
  86. package/gradle.properties +19 -0
  87. package/gradlew +240 -0
  88. package/gradlew.bat +91 -0
  89. package/ios/Button/Button.swift +9 -2
  90. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
  91. package/ios/Checkbox/Checkbox.swift +38 -0
  92. package/ios/{Colors+Spacing → Colors+Radius+Spacing}/Colors.swift +21 -19
  93. package/ios/Colors+Radius+Spacing/Radius.swift +22 -0
  94. package/ios/Image/Image.swift +60 -0
  95. package/ios/Input/Input.swift +88 -37
  96. package/ios/OTPKeyboard/KeyboardButton.swift +12 -4
  97. package/ios/OTPKeyboard/OTPKeyboard.swift +1 -1
  98. package/ios/Popup/PopupDisplay.swift +169 -0
  99. package/ios/Popup/PopupInput.swift +96 -0
  100. package/ios/Popup/PopupPromotion.swift +52 -0
  101. package/ios/PopupView/FullscreenPopup.swift +251 -0
  102. package/ios/{Popup → PopupView}/Modifiers.swift +6 -20
  103. package/ios/{Popup → PopupView}/PopupView.swift +38 -146
  104. package/ios/PopupView/Utils++.swift +281 -0
  105. package/ios/ScrollIndicator/ScrollIndicator.swift +79 -0
  106. package/ios/Switch/Switch.swift +44 -0
  107. package/ios/Template/Logo/Logo.swift +75 -0
  108. package/ios/Template/TrustBanner/TrustBanner.swift +189 -0
  109. package/ios/native-kits.podspec +2 -0
  110. package/local.properties +8 -0
  111. package/package.json +6 -6
  112. package/publish.sh +1 -10
  113. package/settings.gradle.kts +41 -0
  114. package/android/gradle.properties +0 -5
  115. package/android/src/main/java/com/momoplatform/nativekits/NativeKitsPackage.kt +0 -17
  116. package/android/src/main/java/com/momoplatform/nativekits/NativeKitsViewManager.kt +0 -20
  117. package/example/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -63
  118. package/example/ios/Example/Assets.xcassets/Background.colorset/Contents.json +0 -38
  119. package/example/ios/Example/Assets.xcassets/Border.colorset/Contents.json +0 -38
  120. package/example/ios/Example/Assets.xcassets/Card.colorset/Contents.json +0 -38
  121. package/example/ios/Example/Assets.xcassets/Contents.json +0 -6
  122. package/example/ios/Example/Assets.xcassets/Error.colorset/Contents.json +0 -38
  123. package/example/ios/Example/Assets.xcassets/Primary.colorset/Contents.json +0 -38
  124. package/example/ios/Example/Assets.xcassets/PrimaryDark.colorset/Contents.json +0 -38
  125. package/example/ios/Example/Assets.xcassets/PrimaryLight.colorset/Contents.json +0 -38
  126. package/example/ios/Example/Assets.xcassets/Secondary.colorset/Contents.json +0 -38
  127. package/example/ios/Example/Assets.xcassets/Success.colorset/Contents.json +0 -38
  128. package/example/ios/Example/Assets.xcassets/Text.colorset/Contents.json +0 -38
  129. package/example/ios/Example/Assets.xcassets/TextSecondary.colorset/Contents.json +0 -38
  130. package/example/ios/Example/Assets.xcassets/Warning.colorset/Contents.json +0 -38
  131. package/example/ios/Example/ComponentDetail.swift +0 -35
  132. package/example/ios/Example/ComponentItem.swift +0 -24
  133. package/example/ios/Example/ComponentModel.swift +0 -33
  134. package/example/ios/Example/ContentView.swift +0 -53
  135. package/example/ios/Example/Example.entitlements +0 -10
  136. package/example/ios/Example/Foundation/ButtonDemo.swift +0 -80
  137. package/example/ios/Example/Foundation/Popup/ActionSheets.swift +0 -136
  138. package/example/ios/Example/Foundation/Popup/Floats.swift +0 -127
  139. package/example/ios/Example/Foundation/Popup/Popups.swift +0 -101
  140. package/example/ios/Example/Foundation/PopupDemo.swift +0 -366
  141. package/example/ios/Example/Foundation/TextInputDemo.swift +0 -31
  142. package/example/ios/Example/Foundation/TypographyDemo.swift +0 -53
  143. package/example/ios/Example/Foundation.swift +0 -26
  144. package/example/ios/Example/Info.plist +0 -18
  145. package/example/ios/Example/Library/SwipeableDemo.swift +0 -105
  146. package/example/ios/Example/Library.swift +0 -26
  147. package/example/ios/Example/Main.swift +0 -11
  148. package/example/ios/Example/Overview.swift +0 -20
  149. package/example/ios/Example/Preview Content/Preview Assets.xcassets/Contents.json +0 -6
  150. package/example/ios/Example/Resource/SFProText-Black.ttf +0 -0
  151. package/example/ios/Example/Resource/SFProText-Bold.ttf +0 -0
  152. package/example/ios/Example/Resource/SFProText-Heavy.ttf +0 -0
  153. package/example/ios/Example/Resource/SFProText-Light.ttf +0 -0
  154. package/example/ios/Example/Resource/SFProText-Medium.ttf +0 -0
  155. package/example/ios/Example/Resource/SFProText-Regular.ttf +0 -0
  156. package/example/ios/Example/Resource/SFProText-Semibold.ttf +0 -0
  157. package/example/ios/Example/Resource/SFProText-Thin.ttf +0 -0
  158. package/example/ios/Example/Resource/SFProText-Ultralight.ttf +0 -0
  159. package/example/ios/Example/Resource/foundation.json +0 -33
  160. package/example/ios/Example/Resource/library.json +0 -8
  161. package/example/ios/Example/Utils.swift +0 -30
  162. package/example/ios/Example/ViewModifier/DarkViewModifier.swift +0 -22
  163. package/example/ios/Example.xcodeproj/project.pbxproj +0 -570
  164. package/example/ios/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  165. package/example/ios/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  166. package/example/ios/Example.xcodeproj/project.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  167. package/example/ios/Example.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  168. package/example/ios/Example.xcworkspace/contents.xcworkspacedata +0 -10
  169. package/example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  170. package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  171. package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
  172. package/example/ios/Podfile +0 -6
  173. package/example/ios/Podfile.lock +0 -16
  174. package/example/ios/Pods/Local Podspecs/MoMoUIKits.podspec.json +0 -29
  175. package/example/ios/Pods/Manifest.lock +0 -16
  176. package/example/ios/Pods/Pods.xcodeproj/project.pbxproj +0 -661
  177. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
  178. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
  179. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -25
  180. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-dummy.m +0 -5
  181. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-prefix.pch +0 -12
  182. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-umbrella.h +0 -16
  183. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.debug.xcconfig +0 -12
  184. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.modulemap +0 -6
  185. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.release.xcconfig +0 -12
  186. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.markdown +0 -3
  187. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.plist +0 -29
  188. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-dummy.m +0 -5
  189. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-umbrella.h +0 -16
  190. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig +0 -14
  191. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.modulemap +0 -6
  192. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig +0 -14
  193. package/ios/Colors+Spacing/Radius.swift +0 -11
  194. package/ios/Popup/Utils++.swift +0 -163
  195. /package/ios/{Colors+Spacing → Colors+Radius+Spacing}/Spacing.swift +0 -0
@@ -0,0 +1,246 @@
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.AnnotatedString
31
+ import androidx.compose.ui.text.TextStyle
32
+ import androidx.compose.ui.text.input.KeyboardType
33
+ import androidx.compose.ui.text.input.OffsetMapping
34
+ import androidx.compose.ui.text.input.TransformedText
35
+ import androidx.compose.ui.text.input.VisualTransformation
36
+ import androidx.compose.ui.unit.dp
37
+ import androidx.compose.ui.unit.sp
38
+ import androidx.compose.ui.zIndex
39
+ import vn.momo.kits.const.AppTheme
40
+ import vn.momo.kits.const.Spacing
41
+ import vn.momo.kits.const.Typography
42
+ import vn.momo.kits.utils.formatNumberToMoney
43
+
44
+ class CustomConverter : VisualTransformation {
45
+ override fun filter(text: AnnotatedString): TransformedText {
46
+ if (text.text.isEmpty() || text.text == "0") {
47
+ return TransformedText(AnnotatedString("0"), OffsetMapping.Identity)
48
+ }
49
+ val formattedText = formatNumberToMoney(text.text.toLong())
50
+
51
+ return TransformedText(
52
+ AnnotatedString(formattedText),
53
+ object : OffsetMapping {
54
+ override fun originalToTransformed(offset: Int): Int = formattedText.length
55
+ override fun transformedToOriginal(offset: Int): Int = text.length
56
+ }
57
+ )
58
+ }
59
+ }
60
+
61
+ @Composable
62
+ fun InputMoney(
63
+ text: MutableState<String> = remember { mutableStateOf("0") },
64
+ floatingValue: String = "",
65
+ floatingValueColor: Color = AppTheme.current.colors.text.hint,
66
+ floatingIcon: String = "",
67
+ floatingIconColor: Color = AppTheme.current.colors.text.default,
68
+ placeholder: String = "0đ",
69
+ size: InputSize = InputSize.SMALL,
70
+ onChangeText: (String) -> Unit = {},
71
+ error: String = "",
72
+ disabled: Boolean = false,
73
+ icon: String = "",
74
+ iconColor: Color = AppTheme.current.colors.text.default,
75
+ onPressIcon: () -> Unit = {},
76
+ leadingIcon: String = "",
77
+ leadingIconColor: Color = AppTheme.current.colors.text.hint,
78
+ onFocus: () -> Unit = {},
79
+ onBlur: () -> Unit = {},
80
+ loading: Boolean = false,
81
+ required: Boolean = false,
82
+ fontWeight: InputFontWeight = InputFontWeight.BOLD,
83
+ keyboardType: KeyboardType = KeyboardType.Number,
84
+ ) {
85
+ var isFocused by remember { mutableStateOf(false) }
86
+ var isBlurred = false
87
+ val disabledColor = AppTheme.current.colors.text.disable
88
+ var textColor = AppTheme.current.colors.text.default
89
+ var placeholderColor = AppTheme.current.colors.text.hint
90
+ var iconTintColor = iconColor
91
+ val floatingTitleColor = when {
92
+ disabled -> AppTheme.current.colors.text.disable
93
+ else -> floatingValueColor
94
+ }
95
+ val floatingIconTintColor = when {
96
+ disabled -> AppTheme.current.colors.text.disable
97
+ else -> floatingIconColor
98
+ }
99
+
100
+ if (disabled) {
101
+ textColor = disabledColor
102
+ placeholderColor = disabledColor
103
+ iconTintColor = disabledColor
104
+ }
105
+
106
+
107
+ Column {
108
+ BasicTextField(
109
+ enabled = !disabled,
110
+ singleLine = true,
111
+ value = text.value,
112
+ textStyle = TextStyle(
113
+ color = textColor,
114
+ fontSize = 20.sp,
115
+ lineHeight = 24.sp,
116
+ fontWeight = fontWeight.value
117
+ ),
118
+ visualTransformation = CustomConverter(),
119
+ keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
120
+ modifier = Modifier.height(size.values.height).onFocusChanged {
121
+ isFocused = it.isFocused
122
+ if (it.isFocused) {
123
+ onFocus()
124
+ }
125
+ if (!it.isFocused && isBlurred) onBlur()
126
+ if (it.isFocused && !isBlurred) isBlurred = true
127
+ },
128
+ onValueChange = {
129
+ val numericValue = it.filter { char -> char.isDigit() }
130
+ onChangeText(numericValue)
131
+ },
132
+ decorationBox = { innerTextField ->
133
+ // Floating Icon
134
+ if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
135
+ Box(
136
+ modifier = Modifier.wrapContentSize()
137
+ .offset(y = (-size.values.height / 2), x = (Spacing.S))
138
+ .background(AppTheme.current.colors.background.surface)
139
+ .zIndex(10f),
140
+ ) {
141
+ Row(
142
+ modifier = Modifier.padding(horizontal = Spacing.S),
143
+ ) {
144
+ Text(
145
+ floatingValue,
146
+ style = Typography.labelS,
147
+ color = floatingTitleColor
148
+ )
149
+ if (required) {
150
+ Text(
151
+ "*",
152
+ style = Typography.labelS,
153
+ color = AppTheme.current.colors.error.primary,
154
+ )
155
+ }
156
+ if (floatingIcon.isNotEmpty()) {
157
+ Icon(
158
+ source = floatingIcon,
159
+ modifier = Modifier.padding(start = Spacing.XS),
160
+ size = 16.dp,
161
+ color = floatingIconTintColor
162
+ )
163
+ }
164
+ }
165
+ }
166
+ }
167
+ //input box wrapper
168
+ Box(
169
+ modifier = Modifier.fillMaxWidth()
170
+ .border(
171
+ 1.dp,
172
+ getBorderColor(isFocused, error, disabled),
173
+ RoundedCornerShape(size.values.borderRadius)
174
+ ),
175
+ contentAlignment = Alignment.CenterStart
176
+ ) {
177
+ Row(
178
+ modifier = Modifier.padding(horizontal = Spacing.M),
179
+ verticalAlignment = Alignment.CenterVertically
180
+ ) {
181
+ //leading icon
182
+ if (leadingIcon.isNotEmpty()) {
183
+ Icon(
184
+ source = leadingIcon,
185
+ modifier = Modifier.padding(end = Spacing.XS),
186
+ size = if (size.name == InputSize.SMALL.name) 24.dp else 32.dp,
187
+ color = leadingIconColor
188
+ )
189
+ }
190
+ Box(Modifier.weight(9f).padding(start = 0.dp)) {
191
+ if (text.value.isEmpty()) {
192
+ Text(
193
+ text = placeholder,
194
+ style = TextStyle(
195
+ fontSize = 20.sp,
196
+ lineHeight = 24.sp,
197
+ fontWeight = fontWeight.value
198
+ ),
199
+ color = placeholderColor
200
+ )
201
+ } else {
202
+ innerTextField()
203
+ }
204
+ }
205
+ if (isFocused && text.value.isNotEmpty()) {
206
+ Row {
207
+ Spacer(Modifier.width(Spacing.XS))
208
+ Icon(
209
+ source = "24_navigation_close_circle_full",
210
+ size = 16.dp,
211
+ color = AppTheme.current.colors.text.hint,
212
+ modifier = Modifier.clickable(
213
+ onClick = { text.value = "" },
214
+ interactionSource = remember { MutableInteractionSource() },
215
+ indication = null
216
+ )
217
+ )
218
+ }
219
+ }
220
+ RenderRightIcon(loading, icon, iconTintColor, onPressIcon)
221
+ }
222
+ }
223
+ },
224
+ )
225
+ // show error
226
+ if (error.isNotEmpty()) {
227
+ Row(
228
+ Modifier.padding(top = Spacing.XS),
229
+ verticalAlignment = Alignment.CenterVertically
230
+ ) {
231
+ Icon(
232
+ size = 16.dp,
233
+ color = AppTheme.current.colors.error.primary,
234
+ source = "ic_error"
235
+ )
236
+
237
+ Text(
238
+ error,
239
+ style = Typography.descriptionS,
240
+ modifier = Modifier.padding(start = Spacing.XS),
241
+ color = AppTheme.current.colors.error.primary,
242
+ )
243
+ }
244
+ }
245
+ }
246
+ }
@@ -0,0 +1,223 @@
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.Column
10
+ import androidx.compose.foundation.layout.Row
11
+ import androidx.compose.foundation.layout.Spacer
12
+ import androidx.compose.foundation.layout.fillMaxHeight
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.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.unit.dp
34
+ import androidx.compose.ui.unit.sp
35
+ import vn.momo.kits.const.AppTheme
36
+ import vn.momo.kits.const.Radius
37
+ import vn.momo.kits.const.Spacing
38
+ import vn.momo.kits.const.Typography
39
+ import vn.momo.kits.utils.ifTrue
40
+
41
+ @Composable
42
+ fun RenderRightIconSearch(loading: Boolean, icon: String, color: Color, onClick: () -> Unit) {
43
+ if (loading) {
44
+ Box(Modifier.padding(horizontal = Spacing.S)) {
45
+ CircularProgressIndicator(
46
+ modifier = Modifier.size(16.dp),
47
+ color = color,
48
+ trackColor = Color.Transparent,
49
+ strokeWidth = 2.dp
50
+ )
51
+ }
52
+ }
53
+ if (icon.isNotEmpty()) {
54
+ Spacer(
55
+ Modifier.padding(start = Spacing.S).width(1.dp).fillMaxHeight()
56
+ .background(AppTheme.current.colors.primary)
57
+ )
58
+ Icon(
59
+ source = icon,
60
+ color = color,
61
+ size = 24.dp,
62
+ modifier = Modifier.padding(start = Spacing.S, end = 0.dp).clickable(
63
+ onClick = onClick,
64
+ interactionSource = remember { MutableInteractionSource() },
65
+ indication = null
66
+ )
67
+ )
68
+ }
69
+ }
70
+
71
+ @Composable
72
+ fun InputSearch(
73
+ text: MutableState<String> = remember { mutableStateOf("") },
74
+ buttonText: String = "",
75
+ showButtonText: Boolean = false,
76
+ showBorder: Boolean = true,
77
+ placeholder: String = "",
78
+ onChangeText: (String) -> Unit = {},
79
+ onPressButtonText: () -> Unit = {},
80
+ error: String = "",
81
+ disabled: Boolean = false,
82
+ icon: String = "",
83
+ iconColor: Color = AppTheme.current.colors.text.default,
84
+ onRightIconPressed: () -> Unit = {},
85
+ onFocus: () -> Unit = {},
86
+ onBlur: () -> Unit = {},
87
+ loading: Boolean = false,
88
+ fontWeight: InputFontWeight = InputFontWeight.REGULAR,
89
+ keyboardType: KeyboardType = KeyboardType.Text,
90
+ ) {
91
+ var isFocused by remember { mutableStateOf(false) }
92
+ var isBlurred = false
93
+ val disabledColor = AppTheme.current.colors.text.disable
94
+ var textColor = AppTheme.current.colors.text.default
95
+ var placeholderColor = AppTheme.current.colors.text.hint
96
+ var iconTintColor = iconColor
97
+
98
+ if (disabled) {
99
+ textColor = disabledColor
100
+ placeholderColor = disabledColor
101
+ iconTintColor = disabledColor
102
+ }
103
+
104
+ Column {
105
+ BasicTextField(
106
+ enabled = !disabled,
107
+ singleLine = true,
108
+ value = text.value,
109
+ textStyle = TextStyle(
110
+ color = textColor,
111
+ fontSize = 15.sp,
112
+ lineHeight = 24.sp,
113
+ fontWeight = fontWeight.value
114
+ ),
115
+ keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
116
+ modifier = Modifier.height(36.dp).onFocusChanged {
117
+ isFocused = it.isFocused
118
+ if (it.isFocused) {
119
+ onFocus()
120
+ }
121
+ if (!it.isFocused && isBlurred) onBlur()
122
+ if (it.isFocused && !isBlurred) isBlurred = true
123
+ },
124
+ onValueChange = onChangeText,
125
+ decorationBox = { innerTextField ->
126
+ //input box wrapper
127
+ Row(verticalAlignment = Alignment.CenterVertically) {
128
+ Row(
129
+ modifier = Modifier.weight(showButtonText.ifTrue(8f, 1f))
130
+ .background(
131
+ AppTheme.current.colors.background.surface,
132
+ RoundedCornerShape(Radius.XL)
133
+ )
134
+ .border(
135
+ showBorder.ifTrue(1.dp, 0.dp),
136
+ getBorderColor(isFocused, error, disabled),
137
+ RoundedCornerShape(Radius.XL)
138
+ ),
139
+ horizontalArrangement = Arrangement.Start,
140
+ verticalAlignment = Alignment.CenterVertically
141
+ ) {
142
+ Row(
143
+ modifier = Modifier.padding(
144
+ horizontal = Spacing.M,
145
+ vertical = Spacing.S
146
+ ),
147
+ verticalAlignment = Alignment.CenterVertically
148
+ ) {
149
+ //leading icon
150
+ Icon(
151
+ source = "navigation_search",
152
+ modifier = Modifier.padding(end = Spacing.XS),
153
+ size = 24.dp,
154
+ color = AppTheme.current.colors.text.hint
155
+ )
156
+ Box(Modifier.weight(1f)) {
157
+ if (text.value.isEmpty()) {
158
+ Text(
159
+ text = placeholder,
160
+ style = TextStyle(
161
+ fontSize = 16.sp,
162
+ lineHeight = 24.sp,
163
+ fontWeight = fontWeight.value
164
+ ),
165
+ color = placeholderColor
166
+ )
167
+ }
168
+ innerTextField()
169
+ }
170
+ if (isFocused && text.value.isNotEmpty()) {
171
+ Row {
172
+ Spacer(Modifier.width(Spacing.XS))
173
+ Icon(
174
+ source = "24_navigation_close_circle_full",
175
+ size = 16.dp,
176
+ color = AppTheme.current.colors.text.hint,
177
+ modifier = Modifier.clickable(
178
+ onClick = { text.value = "" },
179
+ interactionSource = remember { MutableInteractionSource() },
180
+ indication = null
181
+ )
182
+ )
183
+ }
184
+ }
185
+ RenderRightIconSearch(loading, icon, iconTintColor, onRightIconPressed)
186
+ }
187
+ }
188
+ if (showButtonText) {
189
+ Text(
190
+ text = buttonText,
191
+ style = Typography.actionDefault,
192
+ color = AppTheme.current.colors.text.default,
193
+ modifier = Modifier.padding(start = Spacing.L).clickable(
194
+ interactionSource = remember { MutableInteractionSource() },
195
+ indication = null,
196
+ onClick = onPressButtonText
197
+ )
198
+ )
199
+ }
200
+ }
201
+ },
202
+ )
203
+ // show error
204
+ if (error.isNotEmpty()) {
205
+ Row(
206
+ Modifier.padding(top = Spacing.XS),
207
+ verticalAlignment = Alignment.CenterVertically
208
+ ) {
209
+ Icon(
210
+ size = 16.dp,
211
+ color = AppTheme.current.colors.error.primary,
212
+ source = "ic_error"
213
+ )
214
+ Text(
215
+ error,
216
+ style = Typography.descriptionS,
217
+ modifier = Modifier.padding(start = Spacing.XS),
218
+ color = AppTheme.current.colors.error.primary,
219
+ )
220
+ }
221
+ }
222
+ }
223
+ }