@momo-kits/native-kits 0.169.14-beta.2-debug → 0.169.14

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