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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +180 -0
  3. package/compose/compose.podspec +54 -0
  4. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +113 -0
  5. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  6. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  7. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +95 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +715 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +35 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +343 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +353 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +98 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +138 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +78 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +151 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +190 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +119 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +407 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +175 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +244 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +233 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +257 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +240 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +59 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +44 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +95 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +43 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +351 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +106 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +72 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +99 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +99 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +95 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +132 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +217 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +180 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +208 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +189 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +15 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +271 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +152 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +95 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +162 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +347 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +551 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +169 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +233 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +190 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +258 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +135 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +218 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
  106. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +152 -0
  107. package/gradle/libs.versions.toml +57 -0
  108. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  109. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  110. package/gradle.properties +26 -0
  111. package/gradlew +252 -0
  112. package/gradlew.bat +94 -0
  113. package/local.properties +8 -0
  114. package/package.json +1 -1
  115. package/publish_release.sh +105 -0
  116. package/settings.gradle.kts +52 -0
@@ -0,0 +1,151 @@
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.layout.Box
7
+ import androidx.compose.foundation.layout.size
8
+ import androidx.compose.foundation.shape.RoundedCornerShape
9
+ import androidx.compose.runtime.Composable
10
+ import androidx.compose.runtime.remember
11
+ import androidx.compose.ui.Alignment
12
+ import androidx.compose.ui.Modifier
13
+ import androidx.compose.ui.draw.clip
14
+ import androidx.compose.ui.graphics.Color
15
+ import androidx.compose.ui.unit.Dp
16
+ import androidx.compose.ui.unit.dp
17
+ import vn.momo.kits.application.ApplicationContext
18
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
19
+ import vn.momo.kits.const.AppTheme
20
+ import vn.momo.kits.const.Colors
21
+ import vn.momo.kits.const.Radius
22
+ import vn.momo.kits.modifier.conditional
23
+
24
+ data class IconSpecs(
25
+ val width: Dp,
26
+ val height: Dp,
27
+ val radius: Dp,
28
+ val size: Dp
29
+ )
30
+
31
+ enum class IconSize(val value: IconSpecs) {
32
+ LARGE(
33
+ IconSpecs(
34
+ height = 48.dp,
35
+ radius = Radius.XL,
36
+ width = 48.dp,
37
+ size = 48.dp
38
+ )
39
+ ),
40
+ SMALL(
41
+ IconSpecs(
42
+ height = 40.dp,
43
+ radius = Radius.XL,
44
+ width = 40.dp,
45
+ size = 40.dp
46
+ )
47
+ )
48
+ }
49
+
50
+ // Pre-computed shape to avoid repeated creation
51
+ private val iconButtonShape = RoundedCornerShape(Radius.XL)
52
+
53
+ // Cache for icon sizes to avoid repeated calculations
54
+ private val iconSizeMap = mapOf(
55
+ IconSize.SMALL to 16.dp,
56
+ IconSize.LARGE to 24.dp
57
+ )
58
+
59
+ @Composable
60
+ fun getIconStyle(type: ButtonType, color: Color? = null): Modifier {
61
+ val theme = AppTheme.current
62
+
63
+ return remember(type, color, theme) {
64
+ when (type) {
65
+ ButtonType.DISABLED -> Modifier
66
+ .background(theme.colors.background.disable, iconButtonShape)
67
+ .border(0.dp, Color.Unspecified, iconButtonShape)
68
+
69
+ ButtonType.PRIMARY -> Modifier
70
+ .background(theme.colors.primary, iconButtonShape)
71
+ .border(0.dp, Color.Unspecified, iconButtonShape)
72
+
73
+ ButtonType.SECONDARY -> Modifier
74
+ .background(theme.colors.background.surface, iconButtonShape)
75
+ .border(1.dp, theme.colors.border.default, iconButtonShape)
76
+
77
+ ButtonType.OUTLINE -> Modifier
78
+ .background(theme.colors.background.surface, iconButtonShape)
79
+ .border(1.dp, color ?: theme.colors.primary, iconButtonShape)
80
+
81
+ ButtonType.TONAL -> Modifier
82
+ .background(theme.colors.background.tonal, iconButtonShape)
83
+ .border(0.dp, Color.Unspecified, iconButtonShape)
84
+
85
+ ButtonType.DANGER -> Modifier
86
+ .background(theme.colors.error.primary, iconButtonShape)
87
+ .border(0.dp, Color.Unspecified, iconButtonShape)
88
+
89
+ ButtonType.TEXT -> Modifier
90
+ }
91
+ }
92
+ }
93
+
94
+ @Composable
95
+ fun getIconColor(type: ButtonType): Color {
96
+ val theme = AppTheme.current
97
+ return remember(type, theme) {
98
+ when (type) {
99
+ ButtonType.DISABLED -> theme.colors.text.disable
100
+ ButtonType.PRIMARY -> Colors.black_01
101
+ ButtonType.SECONDARY -> theme.colors.text.default
102
+ ButtonType.OUTLINE -> theme.colors.primary
103
+ ButtonType.TONAL -> theme.colors.primary
104
+ ButtonType.DANGER -> Colors.black_01
105
+ ButtonType.TEXT -> theme.colors.primary
106
+ }
107
+ }
108
+ }
109
+
110
+ @Composable
111
+ fun IconButton(
112
+ onClick: () -> Unit,
113
+ type: ButtonType = ButtonType.PRIMARY,
114
+ size: IconSize = IconSize.SMALL,
115
+ icon: String = "",
116
+ ) {
117
+ // Memoize icon size calculation
118
+ val iconSize = remember(size) {
119
+ iconSizeMap[size] ?: 16.dp
120
+ }
121
+
122
+ // Memoize enabled state
123
+ val isEnabled = remember(type) {
124
+ type != ButtonType.DISABLED
125
+ }
126
+
127
+ // Memoize radius for clipping
128
+ val radius = remember(size) {
129
+ size.value.radius
130
+ }
131
+
132
+ val application = ApplicationContext.current
133
+
134
+ Box(
135
+ modifier = Modifier
136
+ .size(size.value.size)
137
+ .then(getIconStyle(type))
138
+ .conditional(application.isShowBaselineDebug()) {
139
+ border(1.dp, Colors.blue_03)
140
+ }
141
+ .clip(RoundedCornerShape(radius))
142
+ .clickable(enabled = isEnabled, onClick = onClick),
143
+ contentAlignment = Alignment.Center
144
+ ) {
145
+ Icon(
146
+ source = icon,
147
+ color = getIconColor(type),
148
+ size = iconSize,
149
+ )
150
+ }
151
+ }
@@ -0,0 +1,190 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.border
4
+ import androidx.compose.foundation.layout.BoxWithConstraints
5
+ import androidx.compose.runtime.Composable
6
+ import androidx.compose.runtime.getValue
7
+ import androidx.compose.runtime.mutableStateOf
8
+ import androidx.compose.runtime.remember
9
+ import androidx.compose.runtime.setValue
10
+ import androidx.compose.ui.Alignment
11
+ import androidx.compose.ui.Modifier
12
+ import androidx.compose.ui.graphics.ColorFilter
13
+ import androidx.compose.ui.graphics.DefaultAlpha
14
+ import androidx.compose.ui.graphics.painter.Painter
15
+ import androidx.compose.ui.layout.ContentScale
16
+ import androidx.compose.ui.semantics.contentDescription
17
+ import androidx.compose.ui.semantics.semantics
18
+ import androidx.compose.ui.platform.LocalDensity
19
+ import androidx.compose.ui.unit.dp
20
+ import coil3.compose.AsyncImage
21
+ import vn.momo.kits.application.ApplicationContext
22
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
23
+ import vn.momo.kits.const.AppTheme
24
+ import vn.momo.kits.const.Colors
25
+ import vn.momo.kits.modifier.conditional
26
+
27
+ data class Options(
28
+ val alignment: Alignment = Alignment.TopStart,
29
+ val contentScale: ContentScale = ContentScale.Crop,
30
+ val colorFilter: ColorFilter? = null,
31
+ val alpha: Float = DefaultAlpha,
32
+ )
33
+
34
+ enum class ImageState {
35
+ Loading, Success, Error
36
+ }
37
+
38
+ // Cached domain set for better performance
39
+ private val supportedDomains = setOf(
40
+ "static.momocdn.net",
41
+ "img.mservice.com.vn",
42
+ "cdn.mservice.com.vn",
43
+ "img.mservice.io",
44
+ "image.momocdn.net"
45
+ )
46
+
47
+ // Pre-computed size chart for optimal image sizing
48
+ private val sizeChart = mapOf(
49
+ 64 to "XXS",
50
+ 128 to "XS",
51
+ 256 to "S",
52
+ 512 to "M",
53
+ 768 to "L",
54
+ 1024 to "XL",
55
+ 2048 to "XXL"
56
+ )
57
+
58
+ // Optimized size selection using binary search approach
59
+ private fun closestSizeForWidth(width: Float): String {
60
+ val targetWidth = width.toInt()
61
+ return sizeChart.entries
62
+ .minByOrNull { kotlin.math.abs(it.key - targetWidth) }
63
+ ?.value ?: "M"
64
+ }
65
+
66
+ // Cached regex for better URL parsing performance
67
+ private val urlHostRegex = Regex("^(?:https?://)?([^:/\\s]+)")
68
+
69
+ private fun getHostFromUrl(url: String): String? {
70
+ return try {
71
+ urlHostRegex.find(url)?.groupValues?.get(1)
72
+ } catch (_: Exception) {
73
+ null
74
+ }
75
+ }
76
+
77
+ // Optimized query parameter appending
78
+ private fun appendSizeQueryParam(url: String, value: String): String {
79
+ val fragmentIndex = url.indexOf('#')
80
+ val (baseUrl, fragment) = if (fragmentIndex != -1) {
81
+ url.take(fragmentIndex) to url.substring(fragmentIndex)
82
+ } else {
83
+ url to ""
84
+ }
85
+
86
+ val separator = if (baseUrl.contains('?')) "&" else "?"
87
+ return "${baseUrl}${separator}size=$value$fragment"
88
+ }
89
+
90
+ // Cache for processed URLs to avoid repeated calculations
91
+ private val urlCache = mutableMapOf<String, String>()
92
+
93
+ @Composable
94
+ fun Image(
95
+ source: Any,
96
+ modifier: Modifier = Modifier,
97
+ options: Options? = null,
98
+ loading: Boolean = true,
99
+ ) {
100
+ val imageOptions = remember(options) {
101
+ options ?: Options()
102
+ }
103
+
104
+ var imageState by remember { mutableStateOf(ImageState.Loading) }
105
+ val density = LocalDensity.current
106
+ val application = ApplicationContext.current
107
+
108
+ BoxWithConstraints(
109
+ modifier = modifier
110
+ .conditional(application.isShowBaselineDebug()) {
111
+ border(1.dp, Colors.blue_03)
112
+ }
113
+ .semantics { contentDescription = "img|$source" },
114
+ ) {
115
+ val urlToLoad = remember(source, maxWidth, maxHeight, density) {
116
+ when (source) {
117
+ is String -> {
118
+ // Check cache first
119
+ val cacheKey = "$source|${maxWidth}|${density.density}"
120
+ urlCache[cacheKey] ?: run {
121
+ val processedUrl = processImageUrl(source, maxWidth, density)
122
+ urlCache[cacheKey] = processedUrl
123
+ processedUrl
124
+ }
125
+ }
126
+ else -> source
127
+ }
128
+ }
129
+
130
+ AsyncImage(
131
+ modifier = Modifier.matchParentSize(),
132
+ model = urlToLoad,
133
+ contentDescription = null,
134
+ contentScale = imageOptions.contentScale,
135
+ alignment = imageOptions.alignment,
136
+ colorFilter = imageOptions.colorFilter,
137
+ alpha = imageOptions.alpha,
138
+ onLoading = { imageState = ImageState.Loading },
139
+ onSuccess = { imageState = ImageState.Success },
140
+ onError = { imageState = ImageState.Error },
141
+ )
142
+
143
+ when (imageState) {
144
+ ImageState.Loading -> if (loading) Skeleton()
145
+ ImageState.Error -> {
146
+ val theme = AppTheme.current
147
+ Icon(
148
+ source = "media_fail",
149
+ color = theme.colors.text.disable,
150
+ modifier = Modifier.align(Alignment.Center)
151
+ )
152
+ }
153
+ ImageState.Success -> {}
154
+ }
155
+ }
156
+ }
157
+
158
+ // Extracted URL processing logic for better performance
159
+ private fun processImageUrl(url: String, maxWidth: androidx.compose.ui.unit.Dp, density: androidx.compose.ui.unit.Density): String {
160
+ val host = getHostFromUrl(url)
161
+ return if (host != null && supportedDomains.contains(host)) {
162
+ val widthPx = with(density) { maxWidth.roundToPx() }
163
+ val pixelRatio = density.density
164
+ val pixelFitForWidth = widthPx * pixelRatio
165
+ val sizeKey = closestSizeForWidth(pixelFitForWidth)
166
+ appendSizeQueryParam(url, sizeKey)
167
+ } else {
168
+ url
169
+ }
170
+ }
171
+
172
+ @Composable
173
+ fun Image(
174
+ source: Painter,
175
+ modifier: Modifier = Modifier,
176
+ colorFilter: ColorFilter? = null,
177
+ alpha: Float = DefaultAlpha,
178
+ contentScale: ContentScale = ContentScale.Crop,
179
+ alignment: Alignment = Alignment.Center,
180
+ ) {
181
+ androidx.compose.foundation.Image(
182
+ modifier = modifier,
183
+ painter = source,
184
+ contentDescription = null,
185
+ contentScale = contentScale,
186
+ alignment = alignment,
187
+ colorFilter = colorFilter,
188
+ alpha = alpha,
189
+ )
190
+ }
@@ -0,0 +1,119 @@
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.layout.Column
7
+ import androidx.compose.foundation.layout.Row
8
+ import androidx.compose.foundation.layout.height
9
+ import androidx.compose.foundation.layout.padding
10
+ import androidx.compose.foundation.layout.width
11
+ import androidx.compose.foundation.shape.RoundedCornerShape
12
+ import androidx.compose.runtime.Composable
13
+ import androidx.compose.ui.Modifier
14
+ import androidx.compose.ui.draw.clip
15
+ import androidx.compose.ui.text.style.TextAlign
16
+ import androidx.compose.ui.unit.dp
17
+ import vn.momo.kits.application.ApplicationContext
18
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
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
+ import vn.momo.kits.modifier.conditional
24
+
25
+ enum class InformationState {
26
+ DEFAULT,
27
+ WARNING,
28
+ ERROR
29
+ }
30
+
31
+ @Composable
32
+ fun Information(
33
+ title: String? = null,
34
+ description: String = "Description",
35
+ state: InformationState = InformationState.DEFAULT,
36
+ image: String? = null,
37
+ onPressAction: (() -> Unit)? = null,
38
+ showIcon: Boolean = true,
39
+ action: String? = null,
40
+ showIconClose: Boolean = true,
41
+ onPressClose: (() -> Unit)? = null,
42
+ ) {
43
+ var borderColor = Colors.blue_07
44
+ var backgroundColor = Colors.blue_10
45
+ var color = Colors.blue_03
46
+ var iconSource = "notifications_info"
47
+
48
+ if (state === InformationState.WARNING) {
49
+ borderColor = Colors.yellow_06
50
+ backgroundColor = Colors.yellow_09
51
+ color = Colors.orange_03
52
+ iconSource = "24_notifications_alert_triangle"
53
+ }
54
+
55
+ if (state === InformationState.ERROR) {
56
+ borderColor = Colors.red_07
57
+ backgroundColor = Colors.red_10
58
+ color = Colors.red_03
59
+ iconSource = "24_notifications_alert_octagon"
60
+ }
61
+
62
+ val application = ApplicationContext.current
63
+
64
+ Column(
65
+ modifier = Modifier.border(
66
+ width = 0.5.dp,
67
+ shape = RoundedCornerShape(Radius.S),
68
+ color = borderColor
69
+ ).background(color = backgroundColor)
70
+ .conditional(application.isShowBaselineDebug()) {
71
+ border(1.dp, Colors.blue_03)
72
+ }
73
+ .padding(Spacing.M)
74
+ ) {
75
+ Row {
76
+ if (image != null) {
77
+ Image(
78
+ source = image,
79
+ modifier = Modifier.padding(end = Spacing.S).width(40.dp).height(40.dp).clip(
80
+ RoundedCornerShape(Radius.S)
81
+ )
82
+ )
83
+ }
84
+ if (image == null && showIcon) {
85
+ Icon(
86
+ source = iconSource,
87
+ size = 16.dp,
88
+ color = color,
89
+ modifier = Modifier.padding(end = Spacing.S)
90
+ )
91
+ }
92
+ Column(modifier = Modifier.weight(1f)) {
93
+ if (title != null) {
94
+ Text(title, style = Typography.labelDefaultMedium)
95
+ }
96
+ Text(description, style = Typography.descriptionDefaultRegular)
97
+ }
98
+ if (onPressClose != null && showIconClose) {
99
+ Icon(
100
+ source = "navigation_close",
101
+ size = 16.dp,
102
+ modifier = Modifier.clickable(onClick = onPressClose)
103
+ )
104
+ }
105
+ }
106
+ if (action != null && onPressAction != null) {
107
+ Row(modifier = Modifier.padding(top = Spacing.S)) {
108
+ Text(
109
+ action,
110
+ modifier = Modifier.weight(1f).clickable(onClick = onPressAction),
111
+ textAlign = TextAlign.End,
112
+ style = Typography.actionXsBold,
113
+ color = color
114
+ )
115
+ }
116
+ }
117
+ }
118
+
119
+ }