@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,80 @@
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.Row
9
+ import androidx.compose.foundation.layout.Spacer
10
+ import androidx.compose.foundation.layout.size
11
+ import androidx.compose.foundation.shape.RoundedCornerShape
12
+ import androidx.compose.material.ripple.rememberRipple
13
+ import androidx.compose.runtime.Composable
14
+ import androidx.compose.runtime.remember
15
+ import androidx.compose.ui.Alignment
16
+ import androidx.compose.ui.Modifier
17
+ import androidx.compose.ui.unit.dp
18
+ import vn.momo.kits.const.AppTheme
19
+ import vn.momo.kits.const.Colors
20
+ import vn.momo.kits.const.Radius
21
+ import vn.momo.kits.const.Spacing
22
+ import vn.momo.kits.const.Typography
23
+
24
+ @Composable
25
+ fun CheckBox(
26
+ disabled: Boolean = false,
27
+ checked: Boolean = false,
28
+ onCheckedChange: () -> Unit,
29
+ indeterminate: Boolean = false,
30
+ title: String = "",
31
+ ) {
32
+ var borderColor = AppTheme.current.colors.text.default
33
+ var backgroundColor = AppTheme.current.colors.background.surface
34
+ val iconSource = if (indeterminate) "minus" else "ic_checked"
35
+
36
+
37
+ if (checked) {
38
+ borderColor = AppTheme.current.colors.primary
39
+ backgroundColor = AppTheme.current.colors.primary
40
+ }
41
+ if (disabled) {
42
+ borderColor = AppTheme.current.colors.border.disable
43
+ backgroundColor = AppTheme.current.colors.background.surface
44
+ if (checked) {
45
+ borderColor = AppTheme.current.colors.background.tonal
46
+ backgroundColor = AppTheme.current.colors.background.tonal
47
+ }
48
+ }
49
+ Row(
50
+ verticalAlignment = Alignment.CenterVertically,
51
+ ) {
52
+ Box(
53
+ modifier = Modifier.size(20.dp)
54
+ .background(backgroundColor, RoundedCornerShape(Radius.XS))
55
+ .border(Spacing.XXS, borderColor, RoundedCornerShape(Radius.XS))
56
+ .clickable(
57
+ onClick = onCheckedChange,
58
+ enabled = !disabled,
59
+ indication = rememberRipple(),
60
+ interactionSource = remember { MutableInteractionSource() }
61
+ ),
62
+ ) {
63
+ if (checked) {
64
+ Icon(
65
+ source = iconSource,
66
+ size = 20.dp,
67
+ color = Colors.black_01
68
+ )
69
+ }
70
+ }
71
+ if (title.isNotEmpty()) {
72
+ Spacer(Modifier.size(Spacing.S))
73
+ Text(
74
+ style = Typography.descriptionDefault,
75
+ text = title,
76
+ )
77
+ }
78
+ }
79
+
80
+ }
@@ -0,0 +1,23 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.layout.Box
5
+ import androidx.compose.foundation.layout.fillMaxWidth
6
+ import androidx.compose.foundation.layout.height
7
+ import androidx.compose.foundation.layout.padding
8
+ import androidx.compose.runtime.Composable
9
+ import androidx.compose.ui.Modifier
10
+ import androidx.compose.ui.unit.dp
11
+ import vn.momo.kits.const.AppTheme
12
+ import vn.momo.kits.const.Spacing
13
+
14
+ @Composable
15
+ fun Divider() {
16
+ Box(
17
+ modifier = Modifier
18
+ .fillMaxWidth()
19
+ .height(1.dp)
20
+ .background(color = AppTheme.current.colors.border.default)
21
+ .padding(vertical = Spacing.XS)
22
+ )
23
+ }
@@ -0,0 +1,42 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.layout.Box
4
+ import androidx.compose.foundation.layout.fillMaxSize
5
+ import androidx.compose.foundation.layout.size
6
+ import androidx.compose.runtime.Composable
7
+ import androidx.compose.ui.Alignment
8
+ import androidx.compose.ui.Modifier
9
+ import androidx.compose.ui.graphics.Color
10
+ import androidx.compose.ui.graphics.ColorFilter
11
+ import androidx.compose.ui.layout.ContentScale
12
+ import androidx.compose.ui.unit.Dp
13
+ import androidx.compose.ui.unit.dp
14
+ import com.skydoves.landscapist.ImageOptions
15
+ import com.skydoves.landscapist.coil3.CoilImage
16
+ import vn.momo.kits.const.AppTheme
17
+ import vn.momo.kits.utils.Icons
18
+
19
+ @Composable
20
+ fun Icon(
21
+ source: String,
22
+ size: Dp = 24.dp,
23
+ color: Color? = AppTheme.current.colors.text.default,
24
+ modifier: Modifier = Modifier,
25
+ ) {
26
+ val icon = if (source.contains("https")) {
27
+ source
28
+ } else {
29
+ Icons[source]
30
+ }
31
+ Box(modifier.size(size), contentAlignment = Alignment.Center) {
32
+ CoilImage(
33
+ modifier = Modifier.fillMaxSize(),
34
+ imageOptions = ImageOptions(
35
+ contentScale = ContentScale.Fit,
36
+ colorFilter = color?.let { ColorFilter.tint(it) }
37
+ ),
38
+ imageModel = { icon },
39
+ )
40
+ }
41
+ }
42
+
@@ -0,0 +1,126 @@
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.size
9
+ import androidx.compose.foundation.shape.RoundedCornerShape
10
+ import androidx.compose.material.ripple.rememberRipple
11
+ import androidx.compose.runtime.Composable
12
+ import androidx.compose.runtime.remember
13
+ import androidx.compose.ui.Alignment
14
+ import androidx.compose.ui.Modifier
15
+ import androidx.compose.ui.draw.clip
16
+ import androidx.compose.ui.graphics.Color
17
+ import androidx.compose.ui.unit.Dp
18
+ import androidx.compose.ui.unit.dp
19
+ import vn.momo.kits.const.AppTheme
20
+ import vn.momo.kits.const.Colors
21
+ import vn.momo.kits.const.Radius
22
+
23
+ data class IconSpecs(
24
+ val width: Dp,
25
+ val height: Dp,
26
+ val radius: Dp,
27
+ val size: Dp
28
+ )
29
+
30
+ enum class IconSize(val value: IconSpecs) {
31
+ LARGE(
32
+ IconSpecs(
33
+ height = 48.dp,
34
+ radius = Radius.XL,
35
+ width = 48.dp,
36
+ size = 48.dp
37
+ )
38
+ ),
39
+ SMALL(
40
+ IconSpecs(
41
+ height = 40.dp,
42
+ radius = Radius.XL,
43
+ width = 40.dp,
44
+ size = 40.dp
45
+ )
46
+ )
47
+ }
48
+
49
+ @Composable
50
+ fun getIconStyle(type: ButtonType, color: Color? = AppTheme.current.colors.primary): Modifier {
51
+ val theme = AppTheme.current
52
+
53
+ return when (type) {
54
+ ButtonType.DISABLED -> Modifier.background(
55
+ theme.colors.background.disable,
56
+ RoundedCornerShape(Radius.XL)
57
+ ).border(0.dp, Color.Unspecified, RoundedCornerShape(Radius.XL))
58
+
59
+ ButtonType.PRIMARY -> Modifier.background(
60
+ theme.colors.primary,
61
+ RoundedCornerShape(Radius.XL)
62
+ ).border(0.dp, Color.Unspecified, RoundedCornerShape(Radius.XL))
63
+
64
+ ButtonType.SECONDARY -> Modifier
65
+ .background(theme.colors.background.surface, RoundedCornerShape(Radius.XL))
66
+ .border(1.dp, theme.colors.border.default, RoundedCornerShape(Radius.XL))
67
+
68
+ ButtonType.OUTLINE -> Modifier
69
+ .background(theme.colors.background.surface, RoundedCornerShape(Radius.XL))
70
+ .border(1.dp, color ?: theme.colors.primary, RoundedCornerShape(Radius.XL))
71
+
72
+ ButtonType.TONAL -> Modifier.background(
73
+ theme.colors.background.tonal,
74
+ RoundedCornerShape(Radius.XL)
75
+ ).border(0.dp, Color.Unspecified, RoundedCornerShape(Radius.XL))
76
+
77
+ ButtonType.DANGER -> Modifier.background(
78
+ theme.colors.error.primary,
79
+ RoundedCornerShape(Radius.XL)
80
+ ).border(0.dp, Color.Unspecified, RoundedCornerShape(Radius.XL))
81
+
82
+ ButtonType.TEXT -> Modifier
83
+ }
84
+ }
85
+
86
+ @Composable
87
+ fun getIconColor(type: ButtonType): Color {
88
+ return when (type) {
89
+ ButtonType.DISABLED -> AppTheme.current.colors.text.disable
90
+ ButtonType.PRIMARY -> Colors.black_01
91
+ ButtonType.SECONDARY -> AppTheme.current.colors.text.default
92
+ ButtonType.OUTLINE -> AppTheme.current.colors.primary
93
+ ButtonType.TONAL -> AppTheme.current.colors.primary
94
+ ButtonType.DANGER -> Colors.black_01
95
+ ButtonType.TEXT -> AppTheme.current.colors.primary
96
+ }
97
+ }
98
+
99
+ @Composable
100
+ fun IconButton(
101
+ onClick: () -> Unit,
102
+ type: ButtonType = ButtonType.PRIMARY,
103
+ size: IconSize = IconSize.SMALL,
104
+ icon: String = "",
105
+ ) {
106
+ val iconSize = if (size.name == IconSize.SMALL.name) 16.dp else 24.dp
107
+ Box(
108
+ modifier = Modifier
109
+ .size(size.value.size)
110
+ .then(getIconStyle(type))
111
+ .clip(RoundedCornerShape(size.value.radius))
112
+ .clickable(
113
+ interactionSource = remember { MutableInteractionSource() },
114
+ indication = rememberRipple(),
115
+ enabled = type == ButtonType.DISABLED,
116
+ onClick = onClick
117
+ ),
118
+ contentAlignment = Alignment.Center
119
+ ) {
120
+ Icon(
121
+ source = icon,
122
+ color = getIconColor(type),
123
+ size = iconSize,
124
+ )
125
+ }
126
+ }
@@ -0,0 +1,51 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.ui.Alignment
5
+ import androidx.compose.ui.Modifier
6
+ import androidx.compose.ui.graphics.ColorFilter
7
+ import androidx.compose.ui.graphics.DefaultAlpha
8
+ import androidx.compose.ui.layout.ContentScale
9
+ import com.skydoves.landscapist.ImageOptions
10
+ import com.skydoves.landscapist.coil3.CoilImage
11
+ import vn.momo.kits.const.AppTheme
12
+
13
+ data class Options(
14
+ public val alignment: Alignment = Alignment.TopStart,
15
+ public val contentScale: ContentScale = ContentScale.Crop,
16
+ public val colorFilter: ColorFilter? = null,
17
+ public val alpha: Float = DefaultAlpha,
18
+ )
19
+
20
+ @Composable
21
+ fun Image(
22
+ source: String,
23
+ modifier: Modifier = Modifier,
24
+ options: Options? = null,
25
+ loading: Boolean = true,
26
+ ) {
27
+ var imageOptions = ImageOptions()
28
+ options?.let {
29
+ imageOptions = ImageOptions(
30
+ alignment = options.alignment,
31
+ contentScale = options.contentScale,
32
+ colorFilter = options.colorFilter,
33
+ alpha = DefaultAlpha,
34
+ )
35
+ }
36
+
37
+ CoilImage(
38
+ modifier = modifier,
39
+ imageOptions = imageOptions,
40
+ imageModel = { source },
41
+ loading = {
42
+ if (loading) Skeleton()
43
+ },
44
+ failure = {
45
+ Icon(
46
+ source = "media_fail",
47
+ color = AppTheme.current.colors.text.disable,
48
+ )
49
+ }
50
+ )
51
+ }
@@ -0,0 +1,299 @@
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.size
16
+ import androidx.compose.foundation.layout.width
17
+ import androidx.compose.foundation.layout.wrapContentSize
18
+ import androidx.compose.foundation.shape.RoundedCornerShape
19
+ import androidx.compose.foundation.text.BasicTextField
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.font.FontWeight
34
+ import androidx.compose.ui.text.input.KeyboardType
35
+ import androidx.compose.ui.unit.Dp
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.Radius
41
+ import vn.momo.kits.const.Spacing
42
+ import vn.momo.kits.const.Typography
43
+
44
+ data class InputSizeDetail(
45
+ val borderWidth: Dp,
46
+ val borderRadius: Dp,
47
+ val height: Dp,
48
+ )
49
+
50
+ enum class InputSize(val values: InputSizeDetail) {
51
+ SMALL(
52
+ InputSizeDetail(
53
+ borderWidth = 1.dp,
54
+ borderRadius = Radius.S,
55
+ height = 48.dp
56
+ )
57
+ ),
58
+ LARGE(
59
+ InputSizeDetail(
60
+ borderWidth = 1.dp,
61
+ borderRadius = Radius.S,
62
+ height = 56.dp
63
+ )
64
+ )
65
+ }
66
+
67
+ enum class InputFontWeight(val value: FontWeight) {
68
+ REGULAR(
69
+ FontWeight(400)
70
+ ),
71
+ BOLD(
72
+ FontWeight(700)
73
+ )
74
+ }
75
+
76
+ @Composable
77
+ fun getBorderColor(isFocused: Boolean, error: String, disabled: Boolean): Color {
78
+ var borderColors = AppTheme.current.colors.border.default
79
+
80
+ if (isFocused) {
81
+ borderColors = AppTheme.current.colors.primary
82
+ }
83
+ if (error.isNotEmpty()) {
84
+ borderColors = AppTheme.current.colors.error.primary
85
+ }
86
+
87
+ if (disabled) {
88
+ borderColors = AppTheme.current.colors.border.disable
89
+ }
90
+ return borderColors
91
+ }
92
+
93
+ @Composable
94
+ fun RenderRightIcon(loading: Boolean, icon: String, color: Color, onClick: () -> Unit) {
95
+ if (loading) {
96
+ Box(Modifier.padding(horizontal = Spacing.S)) {
97
+ CircularProgressIndicator(
98
+ modifier = Modifier.size(16.dp),
99
+ color = color,
100
+ trackColor = Color.Transparent,
101
+ strokeWidth = 2.dp
102
+ )
103
+ }
104
+ }
105
+ if (icon.isNotEmpty()) {
106
+ Icon(
107
+ source = icon,
108
+ color = color,
109
+ size = 24.dp,
110
+ modifier = Modifier.padding(horizontal = Spacing.S).clickable(
111
+ onClick = onClick,
112
+ interactionSource = remember { MutableInteractionSource() },
113
+ indication = null
114
+ )
115
+ )
116
+ }
117
+ }
118
+
119
+ @Composable
120
+ fun Input(
121
+ text: MutableState<String> = remember { mutableStateOf("") },
122
+ floatingValue: String = "",
123
+ floatingValueColor: Color = AppTheme.current.colors.text.hint,
124
+ floatingIcon: String = "",
125
+ floatingIconColor: Color = AppTheme.current.colors.text.default,
126
+ placeholder: String = "",
127
+ size: InputSize = InputSize.SMALL,
128
+ onChangeText: (String) -> Unit = {},
129
+ error: String = "",
130
+ disabled: Boolean = false,
131
+ icon: String = "",
132
+ iconColor: Color = AppTheme.current.colors.text.default,
133
+ onRightIconPressed: () -> Unit = {},
134
+ leadingIcon: String = "",
135
+ leadingIconColor: Color = AppTheme.current.colors.text.hint,
136
+ onFocus: () -> Unit = {},
137
+ onBlur: () -> Unit = {},
138
+ loading: Boolean = false,
139
+ required: Boolean = false,
140
+ fontWeight: InputFontWeight = InputFontWeight.REGULAR,
141
+ keyboardType: KeyboardType = KeyboardType.Text,
142
+ ) {
143
+ var isFocused by remember { mutableStateOf(false) }
144
+ var isBlurred = false
145
+ val disabledColor = AppTheme.current.colors.text.disable
146
+ var textColor = AppTheme.current.colors.text.default
147
+ var placeholderColor = AppTheme.current.colors.text.hint
148
+ var iconTintColor = iconColor
149
+ val floatingTitleColor = when {
150
+ disabled -> AppTheme.current.colors.text.disable
151
+ else -> floatingValueColor
152
+ }
153
+ val floatingIconTintColor = when {
154
+ disabled -> AppTheme.current.colors.text.disable
155
+ else -> floatingIconColor
156
+ }
157
+
158
+ if (disabled) {
159
+ textColor = disabledColor
160
+ placeholderColor = disabledColor
161
+ iconTintColor = disabledColor
162
+ }
163
+
164
+ Column {
165
+ BasicTextField(
166
+ enabled = !disabled,
167
+ singleLine = true,
168
+ value = text.value,
169
+ textStyle = TextStyle(
170
+ color = textColor,
171
+ fontSize = 16.sp,
172
+ lineHeight = 24.sp,
173
+ fontWeight = fontWeight.value
174
+ ),
175
+ keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
176
+ modifier = Modifier.height(size.values.height).onFocusChanged {
177
+ isFocused = it.isFocused
178
+ if (it.isFocused) {
179
+ onFocus()
180
+ }
181
+ if (!it.isFocused && isBlurred) onBlur()
182
+ if (it.isFocused && !isBlurred) isBlurred = true
183
+ },
184
+ onValueChange = onChangeText,
185
+ decorationBox = { innerTextField ->
186
+ // Floating Icon
187
+ if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
188
+ Box(
189
+ modifier = Modifier.wrapContentSize()
190
+ .offset(y = (-size.values.height / 2), x = (Spacing.S))
191
+ .background(AppTheme.current.colors.background.surface)
192
+ .zIndex(10f),
193
+ ) {
194
+ Row(
195
+ modifier = Modifier
196
+ .padding(horizontal = Spacing.S),
197
+ verticalAlignment = Alignment.Bottom
198
+ ) {
199
+ Text(
200
+ floatingValue,
201
+ style = Typography.labelS,
202
+ color = floatingTitleColor
203
+ )
204
+ if (required) {
205
+ Text(
206
+ "*",
207
+ style = Typography.labelS,
208
+ color = AppTheme.current.colors.error.primary,
209
+ )
210
+ }
211
+ if (floatingIcon.isNotEmpty()) {
212
+ Icon(
213
+ source = floatingIcon,
214
+ modifier = Modifier.padding(start = Spacing.XS),
215
+ size = 16.dp,
216
+ color = floatingIconTintColor
217
+ )
218
+ }
219
+ }
220
+ }
221
+ }
222
+ //input box wrapper
223
+ Box(
224
+ modifier = Modifier.fillMaxWidth()
225
+ .border(
226
+ 1.dp,
227
+ getBorderColor(isFocused, error, disabled),
228
+ RoundedCornerShape(size.values.borderRadius)
229
+ ),
230
+ contentAlignment = Alignment.CenterStart
231
+ ) {
232
+ Row(
233
+ modifier = Modifier.padding(horizontal = Spacing.M),
234
+ verticalAlignment = Alignment.CenterVertically
235
+ ) {
236
+ //leading icon
237
+ if (leadingIcon.isNotEmpty()) {
238
+ Icon(
239
+ source = leadingIcon,
240
+ modifier = Modifier.padding(end = Spacing.XS),
241
+ size = if (size.name == InputSize.SMALL.name) 24.dp else 32.dp,
242
+ color = leadingIconColor
243
+ )
244
+ }
245
+ Box(Modifier.weight(1f)) {
246
+ if (text.value.isEmpty()) {
247
+ Text(
248
+ text = placeholder,
249
+ style = TextStyle(
250
+ fontSize = 16.sp,
251
+ lineHeight = 24.sp,
252
+ fontWeight = fontWeight.value
253
+ ),
254
+ color = placeholderColor
255
+ )
256
+ }
257
+ innerTextField()
258
+ }
259
+ if (isFocused && text.value.isNotEmpty()) {
260
+ Row {
261
+ Spacer(Modifier.width(Spacing.XS))
262
+ Icon(
263
+ source = "24_navigation_close_circle_full",
264
+ size = 16.dp,
265
+ color = AppTheme.current.colors.text.hint,
266
+ modifier = Modifier.clickable(
267
+ onClick = { text.value = "" },
268
+ interactionSource = remember { MutableInteractionSource() },
269
+ indication = null
270
+ )
271
+ )
272
+ }
273
+ }
274
+ RenderRightIcon(loading, icon, iconTintColor, onRightIconPressed)
275
+ }
276
+ }
277
+ },
278
+ )
279
+ // show error
280
+ if (error.isNotEmpty()) {
281
+ Row(
282
+ Modifier.padding(top = Spacing.XS),
283
+ verticalAlignment = Alignment.CenterVertically
284
+ ) {
285
+ Icon(
286
+ size = 16.dp,
287
+ color = AppTheme.current.colors.error.primary,
288
+ source = "ic_error"
289
+ )
290
+ Text(
291
+ error,
292
+ style = Typography.descriptionS,
293
+ modifier = Modifier.padding(start = Spacing.XS),
294
+ color = AppTheme.current.colors.error.primary,
295
+ )
296
+ }
297
+ }
298
+ }
299
+ }