@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,244 @@
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
+ disabled: Boolean = false,
57
+ icon: String = "",
58
+ iconColor: Color = AppTheme.current.colors.text.default,
59
+ onRightIconPressed: () -> Unit = {},
60
+ onFocus: () -> Unit = {},
61
+ onBlur: () -> Unit = {},
62
+ loading: Boolean = false,
63
+ required: Boolean = false,
64
+ fontWeight: InputFontWeight = InputFontWeight.REGULAR,
65
+ keyboardType: KeyboardType = KeyboardType.Text,
66
+ ) {
67
+ var isFocused by remember { mutableStateOf(false) }
68
+ var isBlurred = false
69
+ val disabledColor = AppTheme.current.colors.text.disable
70
+ var textColor = AppTheme.current.colors.text.default
71
+ var placeholderColor = AppTheme.current.colors.text.hint
72
+ var iconTintColor = iconColor
73
+ val floatingTitleColor = when {
74
+ disabled -> AppTheme.current.colors.text.disable
75
+ else -> floatingValueColor
76
+ }
77
+ val floatingIconTintColor = when {
78
+ disabled -> AppTheme.current.colors.text.disable
79
+ else -> floatingIconColor
80
+ }
81
+
82
+ if (disabled) {
83
+ textColor = disabledColor
84
+ placeholderColor = disabledColor
85
+ iconTintColor = disabledColor
86
+ }
87
+
88
+
89
+
90
+ Column {
91
+ BasicTextField(
92
+ enabled = !disabled,
93
+ singleLine = false,
94
+ value = text.value,
95
+ textStyle = TextStyle(
96
+ color = textColor,
97
+ fontSize = 16.sp,
98
+ lineHeight = 24.sp,
99
+ fontWeight = fontWeight.value
100
+ ),
101
+ keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
102
+ modifier = Modifier.height(height).onFocusChanged {
103
+ isFocused = it.isFocused
104
+ if (it.isFocused) {
105
+ onFocus()
106
+ }
107
+ if (!it.isFocused && isBlurred) onBlur()
108
+ if (it.isFocused && !isBlurred) isBlurred = true
109
+ },
110
+ onValueChange = {
111
+ if (it.length <= maxLength) {
112
+ onChangeText(it)
113
+ }
114
+ },
115
+ decorationBox = { innerTextField ->
116
+ // Floating Icon
117
+ if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
118
+ Box(
119
+ modifier = Modifier.wrapContentSize()
120
+ .offset(y = (-height / 2), x = (Spacing.S))
121
+ .background(AppTheme.current.colors.background.surface)
122
+ .zIndex(10f),
123
+ ) {
124
+ Row(
125
+ modifier = Modifier
126
+ .padding(horizontal = Spacing.S),
127
+ verticalAlignment = Alignment.Bottom
128
+ ) {
129
+ Text(
130
+ floatingValue,
131
+ style = Typography.labelS,
132
+ color = floatingTitleColor
133
+ )
134
+ if (required) {
135
+ Text(
136
+ "*",
137
+ style = Typography.labelS,
138
+ color = AppTheme.current.colors.error.primary,
139
+ )
140
+ }
141
+ if (floatingIcon.isNotEmpty()) {
142
+ Icon(
143
+ source = floatingIcon,
144
+ modifier = Modifier.padding(start = Spacing.XS),
145
+ size = 16.dp,
146
+ color = floatingIconTintColor
147
+ )
148
+ }
149
+ }
150
+ }
151
+ }
152
+ //input box wrapper
153
+ Box(
154
+ modifier = Modifier.fillMaxWidth()
155
+ .background(
156
+ AppTheme.current.colors.background.surface,
157
+ RoundedCornerShape(size.values.borderRadius)
158
+ )
159
+ .border(
160
+ 1.dp,
161
+ getBorderColor(isFocused, error, disabled),
162
+ RoundedCornerShape(size.values.borderRadius)
163
+ ),
164
+ contentAlignment = Alignment.TopStart
165
+ ) {
166
+ Column {
167
+ Row(
168
+ modifier = Modifier.weight(9f).padding(
169
+ horizontal = Spacing.M,
170
+ vertical = Spacing.M
171
+ ),
172
+ verticalAlignment = Alignment.Top
173
+ ) {
174
+ Box(Modifier.weight(1f)) {
175
+ if (text.value.isEmpty()) {
176
+ Text(
177
+ text = placeholder,
178
+ style = TextStyle(
179
+ fontSize = 16.sp,
180
+ lineHeight = 24.sp,
181
+ fontWeight = fontWeight.value
182
+ ),
183
+ color = placeholderColor
184
+ )
185
+ }
186
+ innerTextField()
187
+ }
188
+ if (isFocused && text.value.isNotEmpty()) {
189
+ Row {
190
+ Spacer(Modifier.width(Spacing.XS))
191
+ Icon(
192
+ source = "24_navigation_close_circle_full",
193
+ size = 16.dp,
194
+ color = AppTheme.current.colors.text.hint,
195
+ modifier = Modifier.clickable(
196
+ onClick = { text.value = "" },
197
+ interactionSource = remember { MutableInteractionSource() },
198
+ indication = null
199
+ )
200
+ )
201
+ }
202
+ }
203
+ RenderRightIcon(loading, icon, iconTintColor, onRightIconPressed)
204
+ }
205
+
206
+ Box(
207
+ modifier = Modifier
208
+ .weight(1.5f)
209
+ .fillMaxWidth()
210
+ .padding(end = Spacing.M),
211
+ contentAlignment = Alignment.CenterEnd
212
+ ) {
213
+ Text(
214
+ "${text.value.length}/$maxLength",
215
+ style = Typography.descriptionXs,
216
+ color = AppTheme.current.colors.text.hint
217
+ )
218
+ }
219
+ Spacer(Modifier.height(Spacing.M))
220
+ }
221
+ }
222
+ },
223
+ )
224
+ // show error
225
+ if (error.isNotEmpty()) {
226
+ Row(
227
+ Modifier.padding(top = Spacing.XS),
228
+ verticalAlignment = Alignment.CenterVertically
229
+ ) {
230
+ Icon(
231
+ size = 16.dp,
232
+ color = AppTheme.current.colors.error.primary,
233
+ source = "ic_error"
234
+ )
235
+ Text(
236
+ error,
237
+ style = Typography.descriptionS,
238
+ modifier = Modifier.padding(start = Spacing.XS),
239
+ color = AppTheme.current.colors.error.primary,
240
+ )
241
+ }
242
+ }
243
+ }
244
+ }
@@ -0,0 +1,281 @@
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.aspectRatio
13
+ import androidx.compose.foundation.layout.fillMaxWidth
14
+ import androidx.compose.foundation.layout.height
15
+ import androidx.compose.foundation.layout.offset
16
+ import androidx.compose.foundation.layout.padding
17
+ import androidx.compose.foundation.layout.width
18
+ import androidx.compose.foundation.lazy.LazyColumn
19
+ import androidx.compose.foundation.shape.RoundedCornerShape
20
+ import androidx.compose.runtime.Composable
21
+ import androidx.compose.runtime.LaunchedEffect
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.draw.clip
30
+ import androidx.compose.ui.text.TextLayoutResult
31
+ import androidx.compose.ui.unit.dp
32
+ import vn.momo.kits.application.AppNavigator
33
+ import vn.momo.kits.const.AppTheme
34
+ import vn.momo.kits.const.Radius
35
+ import vn.momo.kits.const.Spacing
36
+ import vn.momo.kits.const.Typography
37
+ import vn.momo.kits.utils.ifNotNull
38
+
39
+ data class PopupAction(
40
+ val title: String,
41
+ val onPress: (() -> Unit)?,
42
+ )
43
+
44
+ enum class PopupActionDirection {
45
+ ROW,
46
+ COLUMN,
47
+ AUTO
48
+ }
49
+
50
+ @Composable
51
+ fun PopupNotify(
52
+ image: String = "",
53
+ title: String = "Title",
54
+ description: String = "Description",
55
+ error: String = "",
56
+ primary: PopupAction? = null,
57
+ secondary: PopupAction? = null,
58
+ buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
59
+ onIconClose: () -> Unit,
60
+ ) {
61
+ var isScroll by remember { mutableStateOf(false) }
62
+ val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }
63
+ val navigator = AppNavigator.current
64
+
65
+ LaunchedEffect(layoutResult.value) {
66
+ if ((layoutResult.value?.lineCount ?: 0) > 3) {
67
+ isScroll = true
68
+ }
69
+ }
70
+ val content: @Composable (Modifier) -> Unit = if (isScroll) {
71
+ { modifier ->
72
+ LazyColumn(modifier = modifier.height(80.dp)) {
73
+ item {
74
+ Text(
75
+ text = description,
76
+ onTextLayout = { layoutResult.value = it },
77
+ style = Typography.paragraphDefault
78
+ )
79
+ }
80
+ }
81
+ }
82
+ } else {
83
+ { modifier ->
84
+ Box(modifier = modifier) {
85
+ Text(
86
+ text = description,
87
+ onTextLayout = { layoutResult.value = it },
88
+ style = Typography.paragraphDefault
89
+ )
90
+ }
91
+ }
92
+ }
93
+
94
+ fun onClose(callback: (() -> Unit)?) {
95
+ navigator.pop()
96
+ callback?.invoke()
97
+ }
98
+
99
+ Box(contentAlignment = Alignment.TopEnd) {
100
+ Column(
101
+ modifier = Modifier
102
+ .fillMaxWidth()
103
+ .clip(RoundedCornerShape(Radius.L))
104
+ .background(
105
+ AppTheme.current.colors.background.surface,
106
+ RoundedCornerShape(Radius.L)
107
+ )
108
+ ) {
109
+ image.ifNotNull(
110
+ Image(
111
+ source = image,
112
+ modifier = Modifier.fillMaxWidth().aspectRatio(1.777f)
113
+ ), null
114
+ )
115
+
116
+ Column(modifier = Modifier.padding(Spacing.XL)) {
117
+ Text(style = Typography.titleXs, maxLines = 1, text = title)
118
+ content(Modifier.padding(top = Spacing.S))
119
+ if (error.isNotEmpty()) {
120
+ Text(
121
+ text = error,
122
+ style = Typography.descriptionXs,
123
+ color = AppTheme.current.colors.text.hint,
124
+ maxLines = 1,
125
+ modifier = Modifier.padding(top = Spacing.S)
126
+ )
127
+ }
128
+ }
129
+
130
+ Box(
131
+ modifier = Modifier.padding(horizontal = Spacing.XL)
132
+ .padding(bottom = Spacing.XL)
133
+ ) {
134
+ BuildAction(primary, secondary, buttonDirection, onAction = { callback ->
135
+ onClose(callback)
136
+ })
137
+ }
138
+ }
139
+
140
+ Box(
141
+ Modifier
142
+ .width(20.dp)
143
+ .height(20.dp)
144
+ .offset(x = Spacing.S, y = -Spacing.S)
145
+ .background(
146
+ color = AppTheme.current.colors.text.default,
147
+ shape = RoundedCornerShape(Radius.M)
148
+ )
149
+ .border(
150
+ width = 2.dp,
151
+ color = AppTheme.current.colors.background.surface,
152
+ shape = RoundedCornerShape(Radius.M)
153
+ )
154
+ .clip(RoundedCornerShape(100))
155
+ .clickable(
156
+ interactionSource = remember { MutableInteractionSource() },
157
+ indication = null,
158
+ onClick = { onClose { onIconClose() } }
159
+ ),
160
+ contentAlignment = Alignment.Center
161
+ ) {
162
+ Icon(
163
+ source = "navigation_close",
164
+ color = AppTheme.current.colors.background.surface,
165
+ size = 14.dp,
166
+ )
167
+ }
168
+ }
169
+ }
170
+
171
+ @Composable
172
+ fun BuildAction(
173
+ primary: PopupAction?,
174
+ secondary: PopupAction?,
175
+ buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
176
+ onAction: (onPress: (() -> Unit)?) -> Unit,
177
+ ) {
178
+ val closeAction = remember { mutableStateOf("button_action") }
179
+ when (buttonDirection) {
180
+ PopupActionDirection.AUTO -> {
181
+ if (secondary != null && (secondary.title.length > 12 || primary?.title?.length!! > 12)) {
182
+ renderColumn(
183
+ secondary = secondary,
184
+ onAction = onAction,
185
+ closeAction = closeAction,
186
+ primary = primary
187
+ )
188
+ } else {
189
+ renderRow(
190
+ secondary = secondary,
191
+ onAction = onAction,
192
+ closeAction = closeAction,
193
+ primary = primary
194
+ )
195
+ }
196
+ }
197
+
198
+ PopupActionDirection.ROW -> renderRow(
199
+ secondary = secondary,
200
+ onAction = onAction,
201
+ closeAction = closeAction,
202
+ primary = primary
203
+ )
204
+
205
+ else -> renderColumn(
206
+ secondary = secondary,
207
+ onAction = onAction,
208
+ closeAction = closeAction,
209
+ primary = primary
210
+ )
211
+ }
212
+ }
213
+
214
+ @Composable
215
+ fun renderRow(
216
+ secondary: PopupAction?,
217
+ closeAction: MutableState<String>,
218
+ primary: PopupAction?,
219
+ onAction: (onPress: (() -> Unit)?) -> Unit,
220
+ ) {
221
+ Row(horizontalArrangement = Arrangement.Center) {
222
+ secondary?.let {
223
+ Box(Modifier.weight(1f)) {
224
+ Button(
225
+ size = Size.MEDIUM,
226
+ onClick = {
227
+ closeAction.value = "button_action"
228
+ onAction(it.onPress)
229
+ },
230
+ title = it.title,
231
+ type = ButtonType.TEXT,
232
+ )
233
+ }
234
+ Spacer(modifier = Modifier.width(Spacing.S))
235
+ }
236
+ Box(Modifier.weight(1f)) {
237
+ Button(
238
+ size = Size.MEDIUM,
239
+ onClick = {
240
+ closeAction.value = "button_action"
241
+ onAction(primary?.onPress)
242
+ },
243
+ title = primary?.title ?: "",
244
+ )
245
+ }
246
+ }
247
+ }
248
+
249
+ @Composable
250
+ fun renderColumn(
251
+ secondary: PopupAction?,
252
+ closeAction: MutableState<String>,
253
+ primary: PopupAction?,
254
+ onAction: (onPress: (() -> Unit)?) -> Unit,
255
+ ) {
256
+ Column(horizontalAlignment = Alignment.CenterHorizontally) {
257
+ Button(
258
+ size = Size.MEDIUM,
259
+ onClick = {
260
+ closeAction.value = "button_action"
261
+ onAction(primary?.onPress)
262
+ },
263
+ title = primary?.title ?: ""
264
+ )
265
+ secondary?.let {
266
+ Spacer(modifier = Modifier.height(Spacing.S))
267
+ secondary.let {
268
+ Button(
269
+ size = Size.MEDIUM,
270
+ onClick = {
271
+ closeAction.value = "button_action"
272
+ onAction(it.onPress)
273
+ },
274
+ title = it.title,
275
+ type = ButtonType.TEXT
276
+ )
277
+ }
278
+ }
279
+ }
280
+ }
281
+
@@ -0,0 +1,72 @@
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.aspectRatio
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.width
14
+ import androidx.compose.foundation.shape.RoundedCornerShape
15
+ import androidx.compose.runtime.Composable
16
+ import androidx.compose.runtime.remember
17
+ import androidx.compose.ui.Alignment
18
+ import androidx.compose.ui.Modifier
19
+ import androidx.compose.ui.draw.clip
20
+ import androidx.compose.ui.unit.dp
21
+ import vn.momo.kits.const.AppTheme
22
+ import vn.momo.kits.const.Radius
23
+ import vn.momo.kits.const.Spacing
24
+
25
+ @Composable
26
+ fun PromotionPopup(
27
+ source: String = "",
28
+ onClose: (() -> Unit) = {},
29
+ ) {
30
+ Column {
31
+ if (source.isNotEmpty()) {
32
+ Image(
33
+ source = source,
34
+ modifier = Modifier.fillMaxWidth().aspectRatio(0.72f),
35
+ )
36
+ }
37
+ Box(
38
+ modifier = Modifier
39
+ .padding(top = Spacing.S)
40
+ .fillMaxWidth(),
41
+ contentAlignment = Alignment.Center
42
+ ) {
43
+ Box(
44
+ Modifier
45
+ .width(20.dp)
46
+ .height(20.dp)
47
+ .background(
48
+ color = AppTheme.current.colors.text.default,
49
+ shape = RoundedCornerShape(Radius.M)
50
+ )
51
+ .border(
52
+ width = 2.dp,
53
+ color = AppTheme.current.colors.background.surface,
54
+ shape = RoundedCornerShape(Radius.M)
55
+ )
56
+ .clip(RoundedCornerShape(100))
57
+ .clickable(
58
+ interactionSource = remember { MutableInteractionSource() },
59
+ indication = null,
60
+ onClick = onClose
61
+ ),
62
+ contentAlignment = Alignment.Center
63
+ ) {
64
+ Icon(
65
+ source = "navigation_close",
66
+ color = AppTheme.current.colors.background.surface,
67
+ size = 14.dp,
68
+ )
69
+ }
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,65 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.border
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.padding
10
+ import androidx.compose.foundation.layout.size
11
+ import androidx.compose.foundation.shape.RoundedCornerShape
12
+ import androidx.compose.runtime.Composable
13
+ import androidx.compose.runtime.remember
14
+ import androidx.compose.ui.Alignment
15
+ import androidx.compose.ui.Modifier
16
+ import androidx.compose.ui.draw.clip
17
+ import androidx.compose.ui.unit.dp
18
+ import vn.momo.kits.const.AppTheme
19
+ import vn.momo.kits.const.Radius
20
+ import vn.momo.kits.const.Spacing
21
+ import vn.momo.kits.const.Typography
22
+
23
+ @Composable
24
+ fun Radio(
25
+ value: Any,
26
+ groupValue: Any,
27
+ disabled: Boolean = false,
28
+ onChange: () -> Unit = {},
29
+ label: String = "",
30
+ modifier: Modifier = Modifier,
31
+ ) {
32
+ val selected = value == groupValue
33
+ val borderColor = when {
34
+ disabled && selected -> AppTheme.current.colors.background.tonal
35
+ disabled -> AppTheme.current.colors.text.disable
36
+ selected -> AppTheme.current.colors.primary
37
+ else -> AppTheme.current.colors.text.default
38
+ }
39
+ val borderWidth = if (selected) 6.dp else 2.dp
40
+
41
+ Row(
42
+ modifier = modifier.clickable(
43
+ onClick = onChange,
44
+ enabled = !disabled,
45
+ indication = null,
46
+ interactionSource = remember { MutableInteractionSource() }
47
+ ),
48
+ horizontalArrangement = Arrangement.Center,
49
+ verticalAlignment = Alignment.CenterVertically,
50
+ ) {
51
+ Box(
52
+ modifier = modifier
53
+ .padding(end = if (label.isEmpty()) 0.dp else Spacing.XS)
54
+ .border(borderWidth, borderColor, RoundedCornerShape(Radius.M))
55
+ .clip(RoundedCornerShape(Radius.M))
56
+ .size(20.dp)
57
+ )
58
+ if (label.isNotEmpty()) {
59
+ Text(
60
+ style = Typography.descriptionDefault,
61
+ text = label,
62
+ )
63
+ }
64
+ }
65
+ }