@momo-kits/native-kits 0.155.1-hello.2 → 0.155.1-hello.2-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 (117) hide show
  1. package/.gitlab-ci.yml +15 -0
  2. package/.npmignore.backup +22 -0
  3. package/build.gradle.kts +11 -0
  4. package/compose/build.gradle.kts +180 -0
  5. package/compose/compose.podspec +54 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +113 -0
  7. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +95 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +715 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +35 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +343 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +353 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +98 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +138 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +78 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +151 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +190 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +119 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +447 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +175 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +244 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +233 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +257 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +240 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +59 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +44 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +95 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +43 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +355 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +106 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +72 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +99 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +99 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +95 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +132 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +217 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +180 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +208 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +189 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +15 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +241 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +122 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +163 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +331 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +499 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +233 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +190 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +277 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +135 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
  107. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +152 -0
  108. package/gradle/libs.versions.toml +57 -0
  109. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  110. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  111. package/gradle.properties +26 -0
  112. package/gradlew +252 -0
  113. package/gradlew.bat +94 -0
  114. package/local.properties +8 -0
  115. package/package.json +1 -1
  116. package/publish_release.sh +103 -0
  117. package/settings.gradle.kts +52 -0
@@ -0,0 +1,44 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.layout.BoxWithConstraints
6
+ import androidx.compose.foundation.layout.padding
7
+ import androidx.compose.foundation.shape.RoundedCornerShape
8
+ import androidx.compose.runtime.Composable
9
+ import androidx.compose.ui.Alignment
10
+ import androidx.compose.ui.Modifier
11
+ import androidx.compose.ui.graphics.Color
12
+ import androidx.compose.ui.unit.dp
13
+ import vn.momo.kits.application.ApplicationContext
14
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
15
+ import vn.momo.kits.const.Colors
16
+ import vn.momo.kits.const.Spacing
17
+ import vn.momo.kits.const.Typography
18
+ import vn.momo.kits.modifier.conditional
19
+
20
+ @Composable
21
+ fun PaginationNumber(
22
+ activeIndex: Int = 0,
23
+ dataLength: Int = 2
24
+ ) {
25
+ val application = ApplicationContext.current
26
+
27
+ BoxWithConstraints(
28
+ modifier = Modifier.background(
29
+ color = Color(0x33000000),
30
+ shape = RoundedCornerShape(Spacing.L)
31
+ )
32
+ .conditional(application.isShowBaselineDebug()) {
33
+ border(1.dp, Colors.blue_03)
34
+ },
35
+ contentAlignment = Alignment.Center
36
+ ) {
37
+ Text(
38
+ modifier = Modifier.padding(horizontal = Spacing.S),
39
+ text = "${1 + activeIndex}/$dataLength",
40
+ color = Colors.black_01,
41
+ style = Typography.labelDefaultMedium
42
+ )
43
+ }
44
+ }
@@ -0,0 +1,95 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.horizontalScroll
6
+ import androidx.compose.foundation.layout.Box
7
+ import androidx.compose.foundation.layout.Column
8
+ import androidx.compose.foundation.layout.Row
9
+ import androidx.compose.foundation.layout.fillMaxWidth
10
+ import androidx.compose.foundation.layout.height
11
+ import androidx.compose.foundation.layout.offset
12
+ import androidx.compose.foundation.layout.padding
13
+ import androidx.compose.foundation.layout.width
14
+ import androidx.compose.foundation.rememberScrollState
15
+ import androidx.compose.foundation.shape.RoundedCornerShape
16
+ import androidx.compose.runtime.Composable
17
+ import androidx.compose.runtime.derivedStateOf
18
+ import androidx.compose.runtime.getValue
19
+ import androidx.compose.runtime.remember
20
+ import androidx.compose.ui.Alignment
21
+ import androidx.compose.ui.Modifier
22
+ import androidx.compose.ui.draw.clip
23
+ import androidx.compose.ui.unit.Dp
24
+ import androidx.compose.ui.unit.dp
25
+ import vn.momo.kits.application.ApplicationContext
26
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
27
+ import vn.momo.kits.const.AppTheme
28
+ import vn.momo.kits.const.Colors
29
+ import vn.momo.kits.const.Spacing
30
+ import vn.momo.kits.modifier.conditional
31
+
32
+ val INDICATOR_WIDTH = 24.dp
33
+ val PROGRESS_WIDTH = 72.dp
34
+
35
+ // Memoized offset calculation to avoid repeated computations during scroll
36
+ private fun calculateOffset(currentPosition: Int, maxBound: Int): Dp {
37
+ return if (maxBound == 0) 0.dp else {
38
+ (PROGRESS_WIDTH - INDICATOR_WIDTH) * (currentPosition / maxBound.toFloat())
39
+ }
40
+ }
41
+
42
+ @Composable
43
+ fun PaginationScroll(
44
+ modifier: Modifier = Modifier,
45
+ content: @Composable () -> Unit
46
+ ) {
47
+ val scrollState = rememberScrollState()
48
+ val theme = AppTheme.current
49
+
50
+ // Use derivedStateOf to optimize scroll position calculations
51
+ val indicatorOffset by remember {
52
+ derivedStateOf {
53
+ calculateOffset(scrollState.value, scrollState.maxValue)
54
+ }
55
+ }
56
+
57
+ // Cache theme colors to avoid repeated access
58
+ val (progressBackground, indicatorColor) = remember(theme) {
59
+ theme.colors.background.pressed to theme.colors.primary
60
+ }
61
+
62
+ val application = ApplicationContext.current
63
+
64
+ Column(horizontalAlignment = Alignment.CenterHorizontally) {
65
+ Row(
66
+ modifier = modifier
67
+ .fillMaxWidth()
68
+ .conditional(application.isShowBaselineDebug()) {
69
+ border(1.dp, Colors.blue_03)
70
+ }
71
+ .padding(bottom = Spacing.L)
72
+ .horizontalScroll(scrollState)
73
+ ) {
74
+ content()
75
+ }
76
+
77
+ // Progress indicator
78
+ Box(
79
+ modifier = Modifier
80
+ .clip(RoundedCornerShape(Spacing.XS))
81
+ .width(PROGRESS_WIDTH)
82
+ .height(4.dp)
83
+ .background(color = progressBackground)
84
+ ) {
85
+ Box(
86
+ modifier = Modifier
87
+ .offset(x = indicatorOffset)
88
+ .clip(RoundedCornerShape(Spacing.XS))
89
+ .width(INDICATOR_WIDTH)
90
+ .height(4.dp)
91
+ .background(color = indicatorColor)
92
+ )
93
+ }
94
+ }
95
+ }
@@ -0,0 +1,43 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.layout.Row
6
+ import androidx.compose.foundation.layout.padding
7
+ import androidx.compose.foundation.shape.RoundedCornerShape
8
+ import androidx.compose.runtime.Composable
9
+ import androidx.compose.ui.Modifier
10
+ import androidx.compose.ui.graphics.Color
11
+ import androidx.compose.ui.unit.dp
12
+ import vn.momo.kits.application.ApplicationContext
13
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
14
+ import vn.momo.kits.const.Colors
15
+ import vn.momo.kits.const.Spacing
16
+ import vn.momo.kits.modifier.conditional
17
+
18
+ @Composable
19
+ fun PaginationWhiteDot(
20
+ activeIndex: Int = 0,
21
+ dataLength: Int = 3
22
+ ) {
23
+ val application = ApplicationContext.current
24
+
25
+ Row(
26
+ modifier = Modifier.background(
27
+ color = Color(0x33000000),
28
+ shape = RoundedCornerShape(Spacing.S)
29
+ )
30
+ .conditional(application.isShowBaselineDebug()) {
31
+ border(1.dp, Colors.blue_03)
32
+ }
33
+ .padding(Spacing.XS)
34
+ ) {
35
+ for (i in 0 until dataLength) {
36
+ Dot(
37
+ i == activeIndex,
38
+ Colors.black_01,
39
+ modifier = Modifier.padding(end = if (i != dataLength - 1) Spacing.XS else 0.dp)
40
+ )
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,355 @@
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.const.AppTheme
33
+ import vn.momo.kits.const.Radius
34
+ import vn.momo.kits.const.Spacing
35
+ import vn.momo.kits.application.ApplicationContext
36
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
37
+ import vn.momo.kits.const.Colors
38
+ import vn.momo.kits.const.Typography
39
+ import vn.momo.kits.modifier.conditional
40
+ import vn.momo.kits.modifier.setAutomationId
41
+ import androidx.compose.ui.platform.LocalDensity
42
+ import androidx.compose.ui.unit.Dp
43
+ import vn.momo.kits.application.AppLanguage
44
+ import kotlin.math.min
45
+
46
+ data class PopupAction(
47
+ val title: String,
48
+ val onPress: (() -> Unit)?,
49
+ )
50
+
51
+ enum class PopupActionDirection {
52
+ ROW,
53
+ COLUMN,
54
+ AUTO
55
+ }
56
+
57
+ private fun heightForLines(
58
+ layout: TextLayoutResult,
59
+ targetLines: Float
60
+ ): Float {
61
+ val clampedLines = targetLines.coerceAtLeast(1f)
62
+ val wholeLines = kotlin.math.floor(clampedLines).toInt()
63
+ val fractionalPart = clampedLines - wholeLines
64
+
65
+ val baseLineIndex = (wholeLines - 1)
66
+ .coerceAtLeast(0)
67
+ .coerceAtMost(layout.lineCount - 1)
68
+
69
+ var heightPx = layout.getLineBottom(baseLineIndex)
70
+
71
+ if (fractionalPart > 0f) {
72
+ val nextLineIndex = (baseLineIndex + 1)
73
+ .coerceAtMost(layout.lineCount - 1)
74
+ val nextBottomPx = layout.getLineBottom(nextLineIndex)
75
+ heightPx += (nextBottomPx - heightPx) * fractionalPart
76
+ }
77
+ return heightPx
78
+ }
79
+
80
+ data class PopupNotifyProps(
81
+ val image: String = "",
82
+ val title: String = "Title",
83
+ val description: String = "Description",
84
+ val error: String = "",
85
+ val primary: PopupAction? = null,
86
+ val secondary: PopupAction? = null,
87
+ val buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
88
+ val onIconClose: () -> Unit,
89
+ val isShowCloseIcon: Boolean = true,
90
+ )
91
+
92
+ @Composable
93
+ fun PopupNotify(
94
+ props: PopupNotifyProps,
95
+ ) {
96
+ var isScroll by remember { mutableStateOf(false) }
97
+ val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }
98
+
99
+ val density = LocalDensity.current
100
+ var scrollHeight: Dp by remember { mutableStateOf(0.dp) }
101
+
102
+ LaunchedEffect(layoutResult.value) {
103
+ if ((layoutResult.value?.lineCount ?: 0) > 3) {
104
+ isScroll = true
105
+ }
106
+ }
107
+
108
+ val language = AppLanguage.current ?: "vi"
109
+ val errorCode: Map<String, String> = mapOf("vi" to "Mã lỗi: ", "en" to "Error code: ")
110
+
111
+ LaunchedEffect(layoutResult.value) {
112
+ layoutResult.value?.let { v ->
113
+ // cap visible height at ~8.5 lines
114
+ val textPx = v.size.height.toFloat()
115
+ val capPx = heightForLines(v, 8.5f)
116
+
117
+ isScroll = textPx >= capPx
118
+ scrollHeight = with(density) { min(textPx, capPx).toDp() }
119
+ }
120
+ }
121
+
122
+ val content: @Composable (Modifier) -> Unit = if (isScroll) {
123
+ { modifier ->
124
+ LazyColumn(
125
+ modifier = modifier.height(scrollHeight)
126
+ ) {
127
+ item {
128
+ Text(
129
+ text = props.description,
130
+ onTextLayout = { layoutResult.value = it },
131
+ style = Typography.bodyDefaultRegular
132
+ )
133
+ }
134
+ }
135
+ }
136
+ } else {
137
+ { modifier ->
138
+ Box(modifier = modifier) {
139
+ Text(
140
+ text = props.description,
141
+ onTextLayout = { layoutResult.value = it },
142
+ style = Typography.bodyDefaultRegular
143
+ )
144
+ }
145
+ }
146
+ }
147
+
148
+ fun onClose(callback: (() -> Unit)?) {
149
+ callback?.invoke()
150
+ }
151
+
152
+ Box(
153
+ Modifier.setAutomationId("popup_notify"), contentAlignment = Alignment.TopEnd
154
+ ) {
155
+ val application = ApplicationContext.current
156
+
157
+ Column(
158
+ modifier = Modifier
159
+ .fillMaxWidth()
160
+ .padding(horizontal = 12.dp)
161
+ .clip(RoundedCornerShape(Radius.L))
162
+ .background(
163
+ AppTheme.current.colors.background.surface,
164
+ RoundedCornerShape(Radius.L)
165
+ )
166
+ .conditional(application.isShowBaselineDebug()) {
167
+ border(1.dp, Colors.blue_03)
168
+ }
169
+ ) {
170
+ if(props.image.isNotEmpty()) {
171
+ Image(
172
+ source = props.image,
173
+ modifier = Modifier.fillMaxWidth().aspectRatio(1.777f),
174
+ options = Options(alignment = Alignment.Center)
175
+ )
176
+ }
177
+
178
+ Column(modifier = Modifier.padding(Spacing.XL)) {
179
+ Text(
180
+ style = Typography.headerDefaultBold,
181
+ maxLines = 2,
182
+ text = props.title,
183
+ modifier = Modifier.setAutomationId("title_popup_permission")
184
+ )
185
+ content(Modifier.padding(top = Spacing.S))
186
+ if (props.error.isNotEmpty()) {
187
+ Text(
188
+ text = errorCode[language] + props.error,
189
+ style = Typography.descriptionXsRegular,
190
+ color = AppTheme.current.colors.text.hint,
191
+ maxLines = 1,
192
+ modifier = Modifier.padding(top = Spacing.S)
193
+ )
194
+ }
195
+ }
196
+
197
+ Box(
198
+ modifier = Modifier.padding(horizontal = Spacing.XL)
199
+ .padding(bottom = Spacing.XL)
200
+ ) {
201
+ BuildAction(props.primary, props.secondary, props.buttonDirection, onAction = { callback ->
202
+ onClose(callback)
203
+ })
204
+ }
205
+ }
206
+
207
+ if(props.isShowCloseIcon) {
208
+ Box(
209
+ Modifier
210
+ .width(22.dp)
211
+ .height(22.dp)
212
+ .offset(x = -(1).dp, y = (-11).dp)
213
+ .background(
214
+ color = AppTheme.current.colors.text.default,
215
+ shape = RoundedCornerShape(Radius.M)
216
+ )
217
+ .border(
218
+ width = 2.dp,
219
+ color = AppTheme.current.colors.background.surface,
220
+ shape = RoundedCornerShape(Radius.M)
221
+ )
222
+ .clip(RoundedCornerShape(100))
223
+ .clickable(
224
+ interactionSource = remember { MutableInteractionSource() },
225
+ indication = null,
226
+ onClick = { onClose { props.onIconClose() } }
227
+ ),
228
+ contentAlignment = Alignment.Center
229
+ ) {
230
+ Icon(
231
+ source = "navigation_close",
232
+ color = AppTheme.current.colors.background.surface,
233
+ size = 16.dp,
234
+ modifier = Modifier.setAutomationId("ic_popup_close")
235
+ )
236
+ }
237
+ }
238
+ }
239
+ }
240
+
241
+ @Composable
242
+ fun BuildAction(
243
+ primary: PopupAction?,
244
+ secondary: PopupAction?,
245
+ buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
246
+ onAction: (onPress: (() -> Unit)?) -> Unit,
247
+ ) {
248
+ val closeAction = remember { mutableStateOf("button_action") }
249
+ when (buttonDirection) {
250
+ PopupActionDirection.AUTO -> {
251
+ if (secondary != null && (secondary.title.length > 12 || primary?.title?.length!! > 12)) {
252
+ renderColumn(
253
+ secondary = secondary,
254
+ onAction = onAction,
255
+ closeAction = closeAction,
256
+ primary = primary
257
+ )
258
+ } else {
259
+ renderRow(
260
+ secondary = secondary,
261
+ onAction = onAction,
262
+ closeAction = closeAction,
263
+ primary = primary
264
+ )
265
+ }
266
+ }
267
+
268
+ PopupActionDirection.ROW -> renderRow(
269
+ secondary = secondary,
270
+ onAction = onAction,
271
+ closeAction = closeAction,
272
+ primary = primary
273
+ )
274
+
275
+ else -> renderColumn(
276
+ secondary = secondary,
277
+ onAction = onAction,
278
+ closeAction = closeAction,
279
+ primary = primary
280
+ )
281
+ }
282
+ }
283
+
284
+ @Composable
285
+ fun renderRow(
286
+ secondary: PopupAction?,
287
+ closeAction: MutableState<String>,
288
+ primary: PopupAction?,
289
+ onAction: (onPress: (() -> Unit)?) -> Unit,
290
+ ) {
291
+ Row(horizontalArrangement = Arrangement.Center) {
292
+ secondary?.let {
293
+ Box(Modifier.weight(1f)) {
294
+ Button(
295
+ size = Size.MEDIUM,
296
+ onClick = {
297
+ closeAction.value = "button_action"
298
+ onAction(it.onPress)
299
+ },
300
+ title = it.title,
301
+ type = ButtonType.TEXT,
302
+ modifier = Modifier.setAutomationId("btn_popup_cancel")
303
+ )
304
+ }
305
+ Spacer(modifier = Modifier.width(Spacing.S))
306
+ }
307
+ Box(Modifier.weight(1f)) {
308
+ Button(
309
+ size = Size.MEDIUM,
310
+ onClick = {
311
+ closeAction.value = "button_action"
312
+ onAction(primary?.onPress)
313
+ },
314
+ title = primary?.title ?: "",
315
+ modifier = Modifier.setAutomationId("btn_popup_allow")
316
+ )
317
+ }
318
+ }
319
+ }
320
+
321
+ @Composable
322
+ fun renderColumn(
323
+ secondary: PopupAction?,
324
+ closeAction: MutableState<String>,
325
+ primary: PopupAction?,
326
+ onAction: (onPress: (() -> Unit)?) -> Unit,
327
+ ) {
328
+ Column(horizontalAlignment = Alignment.CenterHorizontally) {
329
+ Button(
330
+ size = Size.MEDIUM,
331
+ onClick = {
332
+ closeAction.value = "button_action"
333
+ onAction(primary?.onPress)
334
+ },
335
+ title = primary?.title ?: "",
336
+ modifier = Modifier.setAutomationId("btn_popup_allow")
337
+ )
338
+ secondary?.let {
339
+ Spacer(modifier = Modifier.height(Spacing.S))
340
+ secondary.let {
341
+ Button(
342
+ size = Size.MEDIUM,
343
+ onClick = {
344
+ closeAction.value = "button_action"
345
+ onAction(it.onPress)
346
+ },
347
+ title = it.title,
348
+ type = ButtonType.TEXT,
349
+ modifier = Modifier.setAutomationId("btn_popup_cancel")
350
+ )
351
+ }
352
+ }
353
+ }
354
+ }
355
+
@@ -0,0 +1,106 @@
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.layout.ContentScale
21
+ import androidx.compose.ui.unit.dp
22
+ import vn.momo.kits.const.AppTheme
23
+ import vn.momo.kits.const.Radius
24
+ import vn.momo.kits.application.ApplicationContext
25
+ import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
26
+ import vn.momo.kits.const.Colors
27
+ import vn.momo.kits.const.Spacing
28
+ import vn.momo.kits.modifier.conditional
29
+ import vn.momo.kits.modifier.setAutomationId
30
+ import vn.momo.kits.utils.ifNotNull
31
+
32
+ @Composable
33
+ fun PopupPromotion(
34
+ source: String = "",
35
+ onPress: (() -> Unit) = {},
36
+ onClose: (() -> Unit) = {},
37
+ ) {
38
+ val application = ApplicationContext.current
39
+
40
+ Column(Modifier
41
+ .padding(horizontal = Spacing.M)
42
+ .conditional(application.isShowBaselineDebug()) {
43
+ border(1.dp, Colors.blue_03)
44
+ }
45
+ .setAutomationId("popup_notify")) {
46
+ source.ifNotNull(
47
+ Image(
48
+ source = source,
49
+ modifier = Modifier.fillMaxWidth()
50
+ .aspectRatio(0.72f)
51
+ .clickable(
52
+ interactionSource = remember { MutableInteractionSource() },
53
+ indication = null,
54
+ onClick = onPress
55
+ ),
56
+ options = Options(alignment = Alignment.Center, contentScale = ContentScale.Crop)
57
+ ), null
58
+ )
59
+ Box(
60
+ modifier = Modifier
61
+ .padding(top = Spacing.S)
62
+ .fillMaxWidth()
63
+ .width(40.dp)
64
+ .height(40.dp),
65
+ contentAlignment = Alignment.Center
66
+ ) {
67
+ Box(
68
+ modifier = Modifier
69
+ .width(40.dp)
70
+ .height(40.dp)
71
+ .clickable(
72
+ interactionSource = remember { MutableInteractionSource() },
73
+ indication = null,
74
+ onClick = onClose
75
+ ),
76
+ contentAlignment = Alignment.Center
77
+ ) {
78
+ Box(
79
+ Modifier
80
+ .width(22.dp)
81
+ .height(22.dp)
82
+ .background(
83
+ color = AppTheme.current.colors.text.default,
84
+ shape = RoundedCornerShape(Radius.M)
85
+ )
86
+ .border(
87
+ width = 2.dp,
88
+ color = AppTheme.current.colors.background.surface,
89
+ shape = RoundedCornerShape(Radius.M)
90
+ )
91
+ .clip(RoundedCornerShape(100))
92
+ ,
93
+ contentAlignment = Alignment.Center
94
+ ) {
95
+ Icon(
96
+ source = "navigation_close",
97
+ color = AppTheme.current.colors.background.surface,
98
+ size = 16.dp,
99
+ modifier = Modifier.setAutomationId("ic_popup_close")
100
+ )
101
+ }
102
+ }
103
+
104
+ }
105
+ }
106
+ }