@momo-kits/native-kits 0.168.1-beta.35-debug → 0.168.1-beta.36

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