@momo-kits/native-kits 0.168.1-beta.11-debug → 0.168.1-beta.13

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