@momo-kits/native-kits 0.168.1-beta.7-debug → 0.168.1-beta.8

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 (140) hide show
  1. package/ios/Extensions/Color++.swift +2 -4
  2. package/ios/native-kits.podspec +1 -1
  3. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  4. package/package.json +1 -1
  5. package/.claude/settings.local.json +0 -185
  6. package/build.gradle.kts +0 -11
  7. package/compose/build.gradle.kts +0 -198
  8. package/compose/build.gradle.kts.backup +0 -198
  9. package/compose/compose.podspec +0 -47
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -306
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -399
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -228
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -377
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  132. package/gradle/libs.versions.toml +0 -69
  133. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  134. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  135. package/gradle.properties +0 -26
  136. package/gradlew +0 -252
  137. package/gradlew.bat +0 -94
  138. package/ios-demo/README.md +0 -120
  139. package/local.properties +0 -8
  140. package/settings.gradle.kts +0 -64
@@ -1,501 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.Canvas
4
- import androidx.compose.foundation.background
5
- import androidx.compose.foundation.border
6
- import androidx.compose.foundation.clickable
7
- import androidx.compose.foundation.interaction.MutableInteractionSource
8
- import androidx.compose.foundation.layout.*
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.graphics.Paint
15
- import androidx.compose.ui.graphics.Path
16
- import androidx.compose.ui.graphics.PathEffect
17
- import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
18
- import androidx.compose.ui.platform.LocalDensity
19
- import androidx.compose.ui.text.style.TextOverflow
20
- import androidx.compose.ui.unit.*
21
- import androidx.compose.ui.window.Popup
22
- import androidx.compose.ui.window.PopupPositionProvider
23
- import androidx.compose.ui.window.PopupProperties
24
- import kotlinx.coroutines.flow.drop
25
- import vn.momo.kits.application.IsShowBaseLineDebug
26
- import vn.momo.kits.const.*
27
- import vn.momo.kits.modifier.activeOpacityClickable
28
- import vn.momo.kits.modifier.conditional
29
-
30
-
31
- enum class TooltipPlacement {
32
- TOP,
33
- BOTTOM,
34
- LEFT,
35
- RIGHT,
36
- }
37
- enum class TooltipAlign {
38
- START,
39
- CENTER,
40
- END,
41
- }
42
- data class TooltipButton(
43
- val title: String? = null,
44
- val icon: String? = null,
45
- val onPress: (() -> Unit)? = null,
46
- )
47
- @Stable
48
- class TooltipState {
49
- var isVisible by mutableStateOf(false)
50
- private set
51
-
52
- /** Shows the tooltip. */
53
- fun show() {
54
- isVisible = true
55
- }
56
-
57
- /** Hides the tooltip. */
58
- fun hide() {
59
- isVisible = false
60
- }
61
-
62
- /** Toggles the tooltip visibility. */
63
- fun toggle() {
64
- isVisible = !isVisible
65
- }
66
- }
67
- @Composable
68
- fun rememberTooltipState(): TooltipState {
69
- return remember { TooltipState() }
70
- }
71
- private val TOOLTIP_OFFSET = Spacing.S
72
- private val ARROW_SIZE = 6.dp
73
- private class TooltipPositionProvider(
74
- private val placement: TooltipPlacement,
75
- private val align: TooltipAlign,
76
- private val offsetPx: Int,
77
- ) : PopupPositionProvider {
78
-
79
- override fun calculatePosition(
80
- anchorBounds: IntRect,
81
- windowSize: IntSize,
82
- layoutDirection: LayoutDirection,
83
- popupContentSize: IntSize,
84
- ): IntOffset {
85
- val anchorX = anchorBounds.left
86
- val anchorY = anchorBounds.top
87
- val anchorW = anchorBounds.width
88
- val anchorH = anchorBounds.height
89
- val popW = popupContentSize.width
90
- val popH = popupContentSize.height
91
-
92
- var x: Int
93
- var y: Int
94
-
95
- when (placement) {
96
- TooltipPlacement.TOP -> {
97
- y = anchorY - popH - offsetPx
98
- x = alignHorizontal(anchorX, anchorW, popW)
99
- }
100
-
101
- TooltipPlacement.BOTTOM -> {
102
- y = anchorY + anchorH + offsetPx
103
- x = alignHorizontal(anchorX, anchorW, popW)
104
- }
105
-
106
- TooltipPlacement.LEFT -> {
107
- x = anchorX - popW - offsetPx
108
- y = alignVertical(anchorY, anchorH, popH)
109
- }
110
-
111
- TooltipPlacement.RIGHT -> {
112
- x = anchorX + anchorW + offsetPx
113
- y = alignVertical(anchorY, anchorH, popH)
114
- }
115
- }
116
-
117
- return IntOffset(x, y)
118
- }
119
- private fun alignHorizontal(anchorX: Int, anchorW: Int, popW: Int): Int {
120
- return when (align) {
121
- TooltipAlign.START -> anchorX
122
- TooltipAlign.END -> anchorX + anchorW - popW
123
- TooltipAlign.CENTER -> anchorX + (anchorW - popW) / 2
124
- }
125
- }
126
- private fun alignVertical(anchorY: Int, anchorH: Int, popH: Int): Int {
127
- return when (align) {
128
- TooltipAlign.START -> anchorY
129
- TooltipAlign.END -> anchorY + anchorH - popH
130
- TooltipAlign.CENTER -> anchorY + (anchorH - popH) / 2
131
- }
132
- }
133
- }
134
-
135
- @Composable
136
- fun Tooltip(
137
- state: TooltipState,
138
- title: String? = null,
139
- description: String,
140
- buttons: List<TooltipButton> = emptyList(),
141
- placement: TooltipPlacement = TooltipPlacement.TOP,
142
- align: TooltipAlign = TooltipAlign.CENTER,
143
- onVisibleChange: ((Boolean) -> Unit)? = null,
144
- onPressClose: (() -> Unit)? = null,
145
- modifier: Modifier = Modifier,
146
- content: @Composable () -> Unit,
147
- ) {
148
- val density = LocalDensity.current
149
- val offsetPx = with(density) { (TOOLTIP_OFFSET + ARROW_SIZE).roundToPx() }
150
-
151
- val currentOnVisibleChange by rememberUpdatedState(onVisibleChange)
152
- LaunchedEffect(state) {
153
- // changes only, like RN: the initial value is not reported
154
- snapshotFlow { state.isVisible }.drop(1).collect { currentOnVisibleChange?.invoke(it) }
155
- }
156
-
157
- Box(modifier = modifier) {
158
- content()
159
-
160
- if (state.isVisible) {
161
- val positionProvider = remember(placement, align, offsetPx) {
162
- TooltipPositionProvider(
163
- placement = placement,
164
- align = align,
165
- offsetPx = offsetPx,
166
- )
167
- }
168
-
169
- Popup(
170
- popupPositionProvider = positionProvider,
171
- onDismissRequest = { state.hide() },
172
- properties = PopupProperties(clippingEnabled = false),
173
- ) {
174
- TooltipPopupContent(
175
- title = title,
176
- description = description,
177
- buttons = buttons,
178
- placement = placement,
179
- align = align,
180
- onPressClose = onPressClose,
181
- )
182
- }
183
- }
184
- }
185
- }
186
- @Composable
187
- private fun TooltipPopupContent(
188
- title: String?,
189
- description: String?,
190
- buttons: List<TooltipButton>,
191
- placement: TooltipPlacement,
192
- align: TooltipAlign,
193
- onPressClose: (() -> Unit)? = null,
194
- ) {
195
- val tooltipMaxWidth = 300.dp
196
- val tooltipShape = remember { RoundedCornerShape(Radius.S) }
197
-
198
- Box(modifier = Modifier.wrapContentSize()) {
199
- Column(
200
- modifier = Modifier
201
- .widthIn(max = tooltipMaxWidth)
202
- .width(IntrinsicSize.Max)
203
- .background(Colors.black_17, tooltipShape)
204
- .clip(tooltipShape)
205
- .conditional(IsShowBaseLineDebug) {
206
- border(1.dp, Colors.blue_03)
207
- }
208
- .padding(Spacing.M)
209
- ) {
210
- Row(Modifier.fillMaxWidth()) {
211
- Column(modifier = Modifier.weight(1f)) {
212
- if (!title.isNullOrEmpty()) {
213
- Text(
214
- text = title,
215
- style = Typography.headerSSemibold,
216
- color = Colors.black_01,
217
- maxLines = 1,
218
- modifier = Modifier.padding(bottom = Spacing.XS),
219
- overflow = TextOverflow.Ellipsis,
220
- )
221
- }
222
- if (!description.isNullOrEmpty()) {
223
- Text(
224
- text = description,
225
- style = Typography.descriptionDefaultRegular,
226
- color = Colors.black_01,
227
- maxLines = 2,
228
- overflow = TextOverflow.Ellipsis,
229
- )
230
- }
231
- }
232
- if (onPressClose != null) {
233
- Spacer(Modifier.width(Spacing.M))
234
- Box(
235
- modifier = Modifier
236
- .size(20.dp)
237
- .activeOpacityClickable {
238
- onPressClose.invoke()
239
- }
240
- ) {
241
- Icon(
242
- source = "navigation_close",
243
- size = 20.dp,
244
- color = Colors.black_01,
245
- )
246
- }
247
- }
248
- }
249
- if (buttons.isNotEmpty()) {
250
- Spacer(Modifier.height(Spacing.M))
251
- TooltipButtons(
252
- buttons = buttons,
253
- modifier = Modifier.align(Alignment.End),
254
- )
255
- }
256
- }
257
-
258
- TooltipArrow(
259
- placement = placement,
260
- align = align,
261
- modifier = Modifier.matchParentSize(),
262
- )
263
- }
264
- }
265
- @Composable
266
- private fun TooltipArrow(
267
- placement: TooltipPlacement,
268
- align: TooltipAlign,
269
- modifier: Modifier = Modifier,
270
- ) {
271
- val arrowWidth = ARROW_SIZE * 2
272
- val arrowHeight = ARROW_SIZE
273
- val arrowEdgeMargin = Spacing.M
274
-
275
- val boxAlignment = when (placement) {
276
- TooltipPlacement.TOP -> when (align) {
277
- TooltipAlign.START -> Alignment.BottomStart
278
- TooltipAlign.CENTER -> Alignment.BottomCenter
279
- TooltipAlign.END -> Alignment.BottomEnd
280
- }
281
-
282
- TooltipPlacement.BOTTOM -> when (align) {
283
- TooltipAlign.START -> Alignment.TopStart
284
- TooltipAlign.CENTER -> Alignment.TopCenter
285
- TooltipAlign.END -> Alignment.TopEnd
286
- }
287
-
288
- TooltipPlacement.LEFT -> when (align) {
289
- TooltipAlign.START -> Alignment.TopEnd
290
- TooltipAlign.CENTER -> Alignment.CenterEnd
291
- TooltipAlign.END -> Alignment.BottomEnd
292
- }
293
-
294
- TooltipPlacement.RIGHT -> when (align) {
295
- TooltipAlign.START -> Alignment.TopStart
296
- TooltipAlign.CENTER -> Alignment.CenterStart
297
- TooltipAlign.END -> Alignment.BottomStart
298
- }
299
- }
300
-
301
- val canvasWidth = when (placement) {
302
- TooltipPlacement.TOP, TooltipPlacement.BOTTOM -> arrowWidth
303
- TooltipPlacement.LEFT, TooltipPlacement.RIGHT -> arrowHeight
304
- }
305
- val canvasHeight = when (placement) {
306
- TooltipPlacement.TOP, TooltipPlacement.BOTTOM -> arrowHeight
307
- TooltipPlacement.LEFT, TooltipPlacement.RIGHT -> arrowWidth
308
- }
309
-
310
- val arrowOverlap = 1.dp
311
- val offsetX = when (placement) {
312
- TooltipPlacement.LEFT -> arrowHeight - arrowOverlap
313
- TooltipPlacement.RIGHT -> -arrowHeight + arrowOverlap
314
- else -> when (align) {
315
- TooltipAlign.START -> arrowEdgeMargin
316
- TooltipAlign.END -> -arrowEdgeMargin
317
- TooltipAlign.CENTER -> 0.dp
318
- }
319
- }
320
- val offsetY = when (placement) {
321
- TooltipPlacement.TOP -> arrowHeight - arrowOverlap
322
- TooltipPlacement.BOTTOM -> -arrowHeight + arrowOverlap
323
- else -> when (align) {
324
- TooltipAlign.START -> arrowEdgeMargin
325
- TooltipAlign.END -> -arrowEdgeMargin
326
- TooltipAlign.CENTER -> 0.dp
327
- }
328
- }
329
-
330
- val arrowColor = Colors.black_17
331
-
332
- Box(modifier = modifier) {
333
- Canvas(
334
- modifier = Modifier
335
- .align(boxAlignment)
336
- .offset(x = offsetX, y = offsetY)
337
- .size(width = canvasWidth, height = canvasHeight)
338
- ) {
339
- val w = size.width
340
- val h = size.height
341
- val path = Path().apply {
342
- when (placement) {
343
- TooltipPlacement.TOP -> {
344
- moveTo(0f, 0f)
345
- lineTo(w, 0f)
346
- lineTo(w / 2f, h)
347
- close()
348
- }
349
- TooltipPlacement.BOTTOM -> {
350
- moveTo(0f, h)
351
- lineTo(w, h)
352
- lineTo(w / 2f, 0f)
353
- close()
354
- }
355
- TooltipPlacement.LEFT -> {
356
- moveTo(0f, 0f)
357
- lineTo(0f, h)
358
- lineTo(w, h / 2f)
359
- close()
360
- }
361
- TooltipPlacement.RIGHT -> {
362
- moveTo(w, 0f)
363
- lineTo(w, h)
364
- lineTo(0f, h / 2f)
365
- close()
366
- }
367
- }
368
- }
369
- drawIntoCanvas { canvas ->
370
- val paint = Paint().apply {
371
- color = arrowColor
372
- pathEffect = PathEffect.cornerPathEffect(2.dp.toPx())
373
- }
374
- canvas.drawPath(path, paint)
375
- }
376
- }
377
- }
378
- }
379
- @Composable
380
- private fun TooltipButtons(buttons: List<TooltipButton>, modifier: Modifier = Modifier) {
381
- Row(
382
- modifier = modifier,
383
- horizontalArrangement = Arrangement.End,
384
- verticalAlignment = Alignment.CenterVertically,
385
- ) {
386
-
387
- if (buttons.size == 1) {
388
- val btn = buttons[0]
389
- TooltipSingleButton(btn)
390
- } else if (buttons.size == 2) {
391
- val primary = buttons[0]
392
- val secondary = buttons[1]
393
- val bothIcons = primary.icon != null && secondary.icon != null
394
-
395
- if (bothIcons) {
396
- TooltipIconButton(
397
- icon = secondary.icon,
398
- onPress = secondary.onPress ?: {},
399
- )
400
- Spacer(modifier = Modifier.width(Spacing.S))
401
- TooltipIconButton(
402
- icon = primary.icon,
403
- onPress = primary.onPress ?: {},
404
- )
405
- } else {
406
- TooltipSecondaryButton(
407
- title = secondary.title ?: "",
408
- onPress = secondary.onPress ?: {},
409
- modifier = Modifier.weight(1f, fill = false),
410
- )
411
- Spacer(modifier = Modifier.width(Spacing.S))
412
- TooltipPrimaryButton(
413
- title = primary.title ?: "",
414
- onPress = primary.onPress ?: {},
415
- )
416
- }
417
- } else {
418
- buttons.forEachIndexed { index, btn ->
419
- if (index > 0) {
420
- Spacer(modifier = Modifier.width(Spacing.XXS))
421
- }
422
- TooltipSingleButton(btn)
423
- }
424
- }
425
- }
426
- }
427
-
428
- @Composable
429
- private fun TooltipSingleButton(btn: TooltipButton) {
430
- if (btn.icon != null) {
431
- TooltipIconButton(
432
- icon = btn.icon,
433
- onPress = btn.onPress ?: {},
434
- )
435
- } else {
436
- TooltipPrimaryButton(
437
- title = btn.title ?: "",
438
- onPress = btn.onPress ?: {},
439
- )
440
- }
441
- }
442
- private fun String.limitWithEllipsis(max: Int = 16): String {
443
- return if (length > max) take(max) + "…" else this
444
- }
445
- @Composable
446
- private fun TooltipPrimaryButton(
447
- title: String,
448
- onPress: () -> Unit,
449
- ) {
450
- Button(
451
- onClick = onPress,
452
- title = title.limitWithEllipsis(),
453
- type = ButtonType.SECONDARY,
454
- size = Size.MEDIUM,
455
- isFull = false,
456
- )
457
- }
458
- @Composable
459
- private fun TooltipSecondaryButton(
460
- title: String,
461
- onPress: () -> Unit,
462
- modifier: Modifier = Modifier,
463
- ) {
464
- Box(
465
- modifier = modifier
466
- .activeOpacityClickable {
467
- onPress()
468
- }
469
- .padding(horizontal = Spacing.M, vertical = Spacing.S),
470
- ) {
471
- Text(
472
- text = title.limitWithEllipsis(),
473
- color = Colors.black_01,
474
- style = Typography.actionSBold,
475
- maxLines = 1,
476
- overflow = TextOverflow.Ellipsis,
477
- )
478
- }
479
- }
480
- @Composable
481
- private fun TooltipIconButton(
482
- icon: String,
483
- onPress: () -> Unit,
484
- ) {
485
- val iconButtonSize = scaleSize(36f).dp
486
-
487
- Box(
488
- modifier = Modifier
489
- .size(iconButtonSize)
490
- .background(Colors.black_01, RoundedCornerShape(Radius.XL))
491
- .clip(RoundedCornerShape(Radius.XL))
492
- .clickable(
493
- interactionSource = remember { MutableInteractionSource() },
494
- indication = null,
495
- onClick = onPress,
496
- ),
497
- contentAlignment = Alignment.Center,
498
- ) {
499
- Icon(source = icon)
500
- }
501
- }
@@ -1,176 +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.layout.Arrangement
7
- import androidx.compose.foundation.layout.Column
8
- import androidx.compose.foundation.layout.Row
9
- import androidx.compose.foundation.layout.fillMaxWidth
10
- import androidx.compose.foundation.layout.height
11
- import androidx.compose.foundation.layout.padding
12
- import androidx.compose.foundation.layout.width
13
- import androidx.compose.foundation.shape.RoundedCornerShape
14
- import androidx.compose.runtime.Composable
15
- import androidx.compose.ui.Alignment
16
- import androidx.compose.ui.Modifier
17
- import androidx.compose.ui.draw.clip
18
- import androidx.compose.ui.graphics.Color
19
- import androidx.compose.ui.layout.ContentScale
20
- import androidx.compose.ui.unit.dp
21
- import vn.momo.kits.application.LocalDesignSystemConfig
22
- import vn.momo.kits.application.LocalLocalize
23
- import vn.momo.kits.application.IsShowBaseLineDebug
24
- import vn.momo.kits.const.Colors
25
- import vn.momo.kits.const.Typography
26
- import vn.momo.kits.modifier.conditional
27
- import vn.momo.kits.modifier.noFeedbackClickable
28
-
29
- val defaultBanner = TrustBannerData(
30
- content = mapOf(
31
- "vi" to "An toàn tài sản & Bảo mật thông tin của bạn là ưu tiên hàng đầu của MoMo.",
32
- "en" to "Ensuring financial security and data privacy is MoMo's highest priority."
33
- ),
34
- subContent = mapOf(
35
- "vi" to "Tìm hiểu thêm",
36
- "en" to "Learn more"
37
- ),
38
- pciImage = "https://static.momocdn.net/app/img/kits/trustBanner/pci_dss.png",
39
- sslImage = "https://static.momocdn.net/app/img/kits/trustBanner/ssl.png",
40
- urlConfig = "login_and_security",
41
- icons = listOf(
42
- "https://static.momocdn.net/app/img/kits/trustBanner/ic_viettinbank.png",
43
- "https://static.momocdn.net/app/img/kits/trustBanner/ic_agribank.png",
44
- "https://static.momocdn.net/app/img/kits/trustBanner/ic_vietcombank.png",
45
- "https://static.momocdn.net/app/img/kits/trustBanner/ic_bidv.png"
46
- ),
47
- momoImage = "https://static.momocdn.net/app/img/kits/trustBanner/ic_secu.png"
48
- )
49
-
50
- const val backgroundBlue = 0xFFF2F8FF
51
- const val contentColor = 0xFF484848
52
- const val subContentColor = 0xFFEB2F96
53
-
54
- data class TrustBannerData(
55
- val content: Map<String, String> = mapOf("vi" to "", "en" to ""),
56
- val subContent: Map<String, String> = mapOf("vi" to "", "en" to ""),
57
- val pciImage: String? = null,
58
- val momoImage: String? = null,
59
- val sslImage: String? = null,
60
- val icons: List<String>? = null,
61
- val urlConfig: String = ""
62
- )
63
-
64
- @Composable
65
- fun TrustBanner(
66
- serviceName: String = "",
67
- screenName: String = "",
68
- onPress: ((Map<String, String>) -> Unit)? = null,
69
- trackEvent: ((String, Map<String, String>) -> Unit)? = null
70
- ) {
71
- val localize = LocalLocalize.current
72
- val trustBanner = LocalDesignSystemConfig.current?.trustBanner ?: defaultBanner
73
- val trackParams = mapOf(
74
- "service_name" to serviceName,
75
- "screen_name" to screenName,
76
- "component_name" to "logo_trust",
77
- "url_config" to trustBanner.urlConfig
78
- )
79
-
80
- Row(
81
- modifier = Modifier
82
- .clip(RoundedCornerShape(12.dp))
83
- .background(color = Color(backgroundBlue))
84
- .conditional(IsShowBaseLineDebug) {
85
- border(1.dp, Colors.blue_03)
86
- }
87
- .padding(12.dp)
88
- .then(
89
- if (onPress != null) {
90
- Modifier.clickable {
91
- trackEvent?.invoke(
92
- "service_component_clicked", trackParams
93
- )
94
-
95
- onPress(
96
- mapOf(
97
- "service_name" to serviceName,
98
- "screen_name" to screenName,
99
- "url_config" to trustBanner.urlConfig,
100
- )
101
- )
102
-
103
- }
104
- } else {
105
- Modifier.noFeedbackClickable {
106
- trackEvent?.invoke(
107
- "service_component_clicked", trackParams
108
- )
109
- }
110
- }
111
- )
112
- ) {
113
- if (trustBanner.momoImage != null) {
114
- Image(
115
- source = trustBanner.momoImage,
116
- modifier = Modifier
117
- .width(64.dp)
118
- .height(64.dp)
119
- )
120
- }
121
- Column(
122
- modifier = Modifier
123
- .padding(start = 10.dp)
124
- ) {
125
- Text(
126
- text = localize.translateData(trustBanner.content),
127
- modifier = Modifier.padding(bottom = 8.dp),
128
- color = Color(contentColor),
129
- style = Typography.descriptionDefaultRegular,
130
- maxLines = 2
131
- )
132
- Row(
133
- modifier = Modifier.fillMaxWidth(),
134
- horizontalArrangement = Arrangement.SpaceBetween
135
- ) {
136
- Row(
137
- verticalAlignment = Alignment.CenterVertically,
138
- ) {
139
- Text(
140
- text = localize.translateData(trustBanner.subContent),
141
- color = Color(subContentColor),
142
- style = Typography.actionXsBold,
143
- maxLines = 2
144
- )
145
- Icon(
146
- source = "https://img.mservice.io/momo_app_v2/new_version/img/appx_icon/16_arrow_chevron_right_small.png",
147
- color = Color(subContentColor),
148
- )
149
- }
150
- Row {
151
- if (trustBanner.pciImage != null) {
152
- Image(
153
- source = trustBanner.pciImage, modifier = Modifier
154
- .padding(end = 4.dp)
155
- .width(27.dp)
156
- .height(20.dp), options = Options(
157
- contentScale = ContentScale.Fit,
158
- )
159
- )
160
- }
161
- if (trustBanner.sslImage != null) {
162
- Image(
163
- source = trustBanner.sslImage, modifier = Modifier
164
- .width(52.dp)
165
- .height(20.dp),
166
- options = Options(
167
- contentScale = ContentScale.Fit,
168
- )
169
- )
170
- }
171
-
172
- }
173
- }
174
- }
175
- }
176
- }