@momo-kits/native-kits 0.162.50-debug → 0.162.50

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 (135) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -198
  4. package/compose/build.gradle.kts.backup +0 -198
  5. package/compose/compose.podspec +0 -47
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -228
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -377
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  121. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  122. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  128. package/gradle/libs.versions.toml +0 -69
  129. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  130. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  131. package/gradle.properties +0 -26
  132. package/gradlew +0 -252
  133. package/gradlew.bat +0 -94
  134. package/ios-demo/README.md +0 -120
  135. package/settings.gradle.kts +0 -64
@@ -1,370 +0,0 @@
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.rememberScrollState
8
- import androidx.compose.foundation.verticalScroll
9
- import androidx.compose.foundation.layout.*
10
- import androidx.compose.foundation.lazy.LazyColumn
11
- import androidx.compose.foundation.shape.RoundedCornerShape
12
- import androidx.compose.runtime.*
13
- import androidx.compose.ui.Alignment
14
- import androidx.compose.ui.Modifier
15
- import androidx.compose.ui.draw.clip
16
- import androidx.compose.ui.platform.LocalDensity
17
- import androidx.compose.ui.text.TextLayoutResult
18
- import androidx.compose.ui.unit.Dp
19
- import androidx.compose.ui.unit.dp
20
- import vn.momo.kits.application.IsShowBaseLineDebug
21
- import vn.momo.kits.application.LocalLocalize
22
- import vn.momo.kits.const.*
23
- import vn.momo.kits.modifier.conditional
24
- import vn.momo.kits.modifier.setAutomationId
25
- import vn.momo.kits.layout.duoModalMaxHeight
26
- import vn.momo.kits.layout.duoModalMaxWidth
27
- import vn.momo.kits.layout.getScreenLayout
28
- import kotlin.math.min
29
-
30
- data class PopupAction(
31
- val title: String,
32
- val onPress: (() -> Unit)?,
33
- )
34
-
35
- enum class PopupActionDirection {
36
- ROW,
37
- COLUMN,
38
- AUTO
39
- }
40
-
41
- // Card width cap on iPhone Duo (the modal bounds, RN Popup/utils.ts); unbounded elsewhere.
42
- @Composable
43
- internal fun popupMaxWidth(): Dp {
44
- val layout = getScreenLayout()
45
- return if (layout.isIPhoneDuoDevice) layout.duoModalMaxWidth else Dp.Unspecified
46
- }
47
-
48
- // The modal bounds already keep iPhone Duo popups off the edges, so their own side padding goes.
49
- @Composable
50
- internal fun popupHorizontalPadding(padding: Dp): Dp =
51
- if (getScreenLayout().isIPhoneDuoDevice) 0.dp else padding
52
-
53
- // Tallest a popup gets on iPhone Duo, landscape and the inner display included; null elsewhere.
54
- @Composable
55
- internal fun popupMaxHeight(): Dp? {
56
- val layout = getScreenLayout()
57
- return if (layout.isIPhoneDuoDevice) layout.duoModalMaxHeight else null
58
- }
59
-
60
- // Rounder on iPhone Duo, closer to its system alerts.
61
- @Composable
62
- internal fun popupRadius(): Dp = if (getScreenLayout().isIPhoneDuoDevice) Radius.XL else Radius.L
63
-
64
- private fun heightForLines(
65
- layout: TextLayoutResult,
66
- ): Float {
67
- val clampedLines = (8.5f).coerceAtLeast(1f)
68
- val wholeLines = kotlin.math.floor(clampedLines).toInt()
69
- val fractionalPart = clampedLines - wholeLines
70
-
71
- val baseLineIndex = (wholeLines - 1)
72
- .coerceAtLeast(0)
73
- .coerceAtMost(layout.lineCount - 1)
74
-
75
- var heightPx = layout.getLineBottom(baseLineIndex)
76
-
77
- if (fractionalPart > 0f) {
78
- val nextLineIndex = (baseLineIndex + 1)
79
- .coerceAtMost(layout.lineCount - 1)
80
- val nextBottomPx = layout.getLineBottom(nextLineIndex)
81
- heightPx += (nextBottomPx - heightPx) * fractionalPart
82
- }
83
- return heightPx
84
- }
85
-
86
- data class PopupNotifyProps(
87
- val image: String = "",
88
- val title: String = "Title",
89
- val description: String = "Description",
90
- val error: String = "",
91
- val primary: PopupAction? = null,
92
- val secondary: PopupAction? = null,
93
- val buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
94
- val onIconClose: () -> Unit,
95
- val isShowCloseIcon: Boolean = true,
96
- )
97
-
98
- @Composable
99
- fun PopupNotify(
100
- props: PopupNotifyProps,
101
- ) {
102
- var isScroll by remember { mutableStateOf(false) }
103
- val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }
104
-
105
- val density = LocalDensity.current
106
- var scrollHeight: Dp by remember { mutableStateOf(0.dp) }
107
-
108
- LaunchedEffect(layoutResult.value) {
109
- if ((layoutResult.value?.lineCount ?: 0) > 3) {
110
- isScroll = true
111
- }
112
- }
113
-
114
- LaunchedEffect(layoutResult.value) {
115
- layoutResult.value?.let { v ->
116
- // cap visible height at ~8.5 lines
117
- val textPx = v.size.height.toFloat()
118
- val capPx = heightForLines(v)
119
-
120
- isScroll = textPx >= capPx
121
- scrollHeight = with(density) { min(textPx, capPx).toDp() }
122
- }
123
- }
124
-
125
- val content: @Composable (Modifier) -> Unit = if (isScroll) {
126
- { modifier ->
127
- LazyColumn(
128
- modifier = modifier.height(scrollHeight)
129
- ) {
130
- item {
131
- Text(
132
- text = props.description,
133
- onTextLayout = { layoutResult.value = it },
134
- style = Typography.bodyDefaultRegular
135
- )
136
- }
137
- }
138
- }
139
- } else {
140
- { modifier ->
141
- Box(modifier = modifier) {
142
- Text(
143
- text = props.description,
144
- onTextLayout = { layoutResult.value = it },
145
- style = Typography.bodyDefaultRegular
146
- )
147
- }
148
- }
149
- }
150
-
151
- fun onClose(callback: (() -> Unit)?) {
152
- callback?.invoke()
153
- }
154
-
155
- val maxHeight = popupMaxHeight()
156
- val bodyScrollState = rememberScrollState()
157
- val horizontalPadding = popupHorizontalPadding(12.dp)
158
- val shape = RoundedCornerShape(popupRadius())
159
-
160
- Box(
161
- Modifier.setAutomationId("popup_notify"), contentAlignment = Alignment.TopEnd
162
- ) {
163
- Column(
164
- modifier = Modifier
165
- .widthIn(max = popupMaxWidth())
166
- .fillMaxWidth()
167
- .padding(horizontal = horizontalPadding)
168
- .clip(shape)
169
- .background(AppTheme.current.colors.background.surface, shape)
170
- .conditional(IsShowBaseLineDebug) {
171
- border(1.dp, Colors.blue_03)
172
- }
173
- .conditional(maxHeight != null) {
174
- heightIn(max = maxHeight ?: Dp.Unspecified)
175
- }
176
- ) {
177
- // scrolls when iPhone Duo landscape is too short; actions stay visible
178
- Column(
179
- Modifier.conditional(maxHeight != null) {
180
- weight(1f, fill = false).verticalScroll(bodyScrollState)
181
- }
182
- ) {
183
- if(props.image.isNotEmpty()) {
184
- Image(
185
- source = props.image,
186
- modifier = Modifier.fillMaxWidth().aspectRatio(1.777f),
187
- options = Options(alignment = Alignment.Center)
188
- )
189
- }
190
-
191
- Column(modifier = Modifier.padding(Spacing.XL)) {
192
- Text(
193
- style = Typography.headerDefaultBold,
194
- maxLines = 2,
195
- text = props.title,
196
- modifier = Modifier.setAutomationId("title_popup_permission")
197
- )
198
- content(Modifier.padding(top = Spacing.S))
199
- if (props.error.isNotEmpty()) {
200
- Text(
201
- text = LocalLocalize.current.translate("errorCode") + props.error,
202
- style = Typography.descriptionXsRegular,
203
- color = AppTheme.current.colors.text.hint,
204
- maxLines = 1,
205
- modifier = Modifier.padding(top = Spacing.S)
206
- )
207
- }
208
- }
209
- }
210
-
211
- Box(
212
- modifier = Modifier.padding(horizontal = Spacing.XL)
213
- .padding(bottom = Spacing.XL)
214
- ) {
215
- BuildAction(props.primary, props.secondary, props.buttonDirection, onAction = { callback ->
216
- onClose(callback)
217
- })
218
- }
219
- }
220
-
221
- if(props.isShowCloseIcon) {
222
- Box(
223
- Modifier
224
- .width(22.dp)
225
- .height(22.dp)
226
- // centered on the card's top right corner
227
- .offset(x = 11.dp - horizontalPadding, y = (-11).dp)
228
- .background(
229
- color = AppTheme.current.colors.text.default,
230
- shape = RoundedCornerShape(Radius.M)
231
- )
232
- .border(
233
- width = 2.dp,
234
- color = AppTheme.current.colors.background.surface,
235
- shape = RoundedCornerShape(Radius.M)
236
- )
237
- .clip(RoundedCornerShape(100))
238
- .clickable(
239
- interactionSource = remember { MutableInteractionSource() },
240
- indication = null,
241
- onClick = { onClose { props.onIconClose() } }
242
- ),
243
- contentAlignment = Alignment.Center
244
- ) {
245
- Icon(
246
- source = "navigation_close",
247
- color = AppTheme.current.colors.background.surface,
248
- size = 16.dp,
249
- modifier = Modifier.setAutomationId("ic_popup_close")
250
- )
251
- }
252
- }
253
- }
254
- }
255
-
256
- @Composable
257
- internal fun BuildAction(
258
- primary: PopupAction?,
259
- secondary: PopupAction?,
260
- buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
261
- onAction: (onPress: (() -> Unit)?) -> Unit,
262
- ) {
263
- val closeAction = remember { mutableStateOf("button_action") }
264
- when (buttonDirection) {
265
- PopupActionDirection.AUTO -> {
266
- if (secondary != null && (secondary.title.length > 12 || (primary?.title?.length ?: 0) > 12)) {
267
- RenderColumn(
268
- secondary = secondary,
269
- onAction = onAction,
270
- closeAction = closeAction,
271
- primary = primary
272
- )
273
- } else {
274
- RenderRow(
275
- secondary = secondary,
276
- onAction = onAction,
277
- closeAction = closeAction,
278
- primary = primary
279
- )
280
- }
281
- }
282
-
283
- PopupActionDirection.ROW -> RenderRow(
284
- secondary = secondary,
285
- onAction = onAction,
286
- closeAction = closeAction,
287
- primary = primary
288
- )
289
-
290
- else -> RenderColumn(
291
- secondary = secondary,
292
- onAction = onAction,
293
- closeAction = closeAction,
294
- primary = primary
295
- )
296
- }
297
- }
298
-
299
- @Composable
300
- internal fun RenderRow(
301
- secondary: PopupAction?,
302
- closeAction: MutableState<String>,
303
- primary: PopupAction?,
304
- onAction: (onPress: (() -> Unit)?) -> Unit,
305
- ) {
306
- Row(horizontalArrangement = Arrangement.Center) {
307
- secondary?.let {
308
- Box(Modifier.weight(1f)) {
309
- Button(
310
- size = Size.MEDIUM,
311
- onClick = {
312
- closeAction.value = "button_action"
313
- onAction(it.onPress)
314
- },
315
- title = it.title,
316
- type = ButtonType.TEXT,
317
- modifier = Modifier.setAutomationId("btn_popup_cancel")
318
- )
319
- }
320
- Spacer(modifier = Modifier.width(Spacing.S))
321
- }
322
- Box(Modifier.weight(1f)) {
323
- Button(
324
- size = Size.MEDIUM,
325
- onClick = {
326
- closeAction.value = "button_action"
327
- onAction(primary?.onPress)
328
- },
329
- title = primary?.title ?: "",
330
- modifier = Modifier.setAutomationId("btn_popup_allow")
331
- )
332
- }
333
- }
334
- }
335
-
336
- @Composable
337
- internal fun RenderColumn(
338
- secondary: PopupAction?,
339
- closeAction: MutableState<String>,
340
- primary: PopupAction?,
341
- onAction: (onPress: (() -> Unit)?) -> Unit,
342
- ) {
343
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
344
- Button(
345
- size = Size.MEDIUM,
346
- onClick = {
347
- closeAction.value = "button_action"
348
- onAction(primary?.onPress)
349
- },
350
- title = primary?.title ?: "",
351
- modifier = Modifier.setAutomationId("btn_popup_allow")
352
- )
353
- secondary?.let {
354
- Spacer(modifier = Modifier.height(Spacing.S))
355
- secondary.let {
356
- Button(
357
- size = Size.MEDIUM,
358
- onClick = {
359
- closeAction.value = "button_action"
360
- onAction(it.onPress)
361
- },
362
- title = it.title,
363
- type = ButtonType.TEXT,
364
- modifier = Modifier.setAutomationId("btn_popup_cancel")
365
- )
366
- }
367
- }
368
- }
369
- }
370
-
@@ -1,108 +0,0 @@
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.*
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.layout.ContentScale
15
- import androidx.compose.ui.unit.dp
16
- import vn.momo.kits.application.IsShowBaseLineDebug
17
- import vn.momo.kits.const.AppTheme
18
- import vn.momo.kits.const.Colors
19
- import vn.momo.kits.const.Radius
20
- import vn.momo.kits.const.Spacing
21
- import vn.momo.kits.modifier.conditional
22
- import vn.momo.kits.modifier.setAutomationId
23
- import vn.momo.kits.utils.ifNotNull
24
-
25
- private const val ASPECT_RATIO = 0.72f
26
- private val CLOSE_ROW_HEIGHT = Spacing.S + 40.dp
27
-
28
- @Composable
29
- fun PopupPromotion(
30
- source: String = "",
31
- onPress: (() -> Unit) = {},
32
- onClose: (() -> Unit) = {},
33
- ) {
34
- val maxHeight = popupMaxHeight()
35
- var maxWidth = popupMaxWidth()
36
- if (maxHeight != null) {
37
- // fit the portrait image by height when iPhone Duo leaves too little room
38
- maxWidth = minOf(maxWidth, (maxHeight - CLOSE_ROW_HEIGHT) * ASPECT_RATIO)
39
- }
40
-
41
- Column(Modifier
42
- .widthIn(max = maxWidth)
43
- .padding(horizontal = popupHorizontalPadding(Spacing.M))
44
- .conditional(IsShowBaseLineDebug) {
45
- border(1.dp, Colors.blue_03)
46
- }
47
- .setAutomationId("popup_notify")) {
48
- source.ifNotNull(
49
- Image(
50
- source = source,
51
- modifier = Modifier.fillMaxWidth()
52
- .aspectRatio(ASPECT_RATIO)
53
- .clickable(
54
- interactionSource = remember { MutableInteractionSource() },
55
- indication = null,
56
- onClick = onPress
57
- ),
58
- options = Options(alignment = Alignment.Center, contentScale = ContentScale.FillBounds)
59
- ), null
60
- )
61
- Box(
62
- modifier = Modifier
63
- .padding(top = Spacing.S)
64
- .fillMaxWidth()
65
- .width(40.dp)
66
- .height(40.dp),
67
- contentAlignment = Alignment.Center
68
- ) {
69
- Box(
70
- modifier = Modifier
71
- .width(40.dp)
72
- .height(40.dp)
73
- .clickable(
74
- interactionSource = remember { MutableInteractionSource() },
75
- indication = null,
76
- onClick = onClose
77
- ),
78
- contentAlignment = Alignment.Center
79
- ) {
80
- Box(
81
- Modifier
82
- .width(22.dp)
83
- .height(22.dp)
84
- .background(
85
- color = AppTheme.current.colors.text.default,
86
- shape = RoundedCornerShape(Radius.M)
87
- )
88
- .border(
89
- width = 2.dp,
90
- color = AppTheme.current.colors.background.surface,
91
- shape = RoundedCornerShape(Radius.M)
92
- )
93
- .clip(RoundedCornerShape(100))
94
- ,
95
- contentAlignment = Alignment.Center
96
- ) {
97
- Icon(
98
- source = "navigation_close",
99
- color = AppTheme.current.colors.background.surface,
100
- size = 16.dp,
101
- modifier = Modifier.setAutomationId("ic_popup_close")
102
- )
103
- }
104
- }
105
-
106
- }
107
- }
108
- }