@momo-kits/native-kits 0.167.1-duo.17-debug → 0.167.1-duo.18

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 (154) hide show
  1. package/CLAUDE.md +1 -0
  2. package/ios/Layout/ScreenLayout.swift +49 -3
  3. package/ios/Navigation/Component/Header.swift +48 -11
  4. package/ios/Navigation/Component/HeaderRight.swift +34 -28
  5. package/ios/Navigation/Component/SideBar.swift +15 -8
  6. package/ios/Navigation/StackScreen.swift +13 -12
  7. package/package.json +1 -1
  8. package/build.gradle.kts +0 -11
  9. package/compose/build.gradle.kts +0 -204
  10. package/compose/build.gradle.kts.backup +0 -204
  11. package/compose/compose.podspec +0 -47
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  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/AnimationSearchInput.kt +0 -52
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -916
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -20
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -283
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -260
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -708
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -218
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -231
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -98
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -312
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -408
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -366
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -185
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -13
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -78
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  142. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  143. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  144. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  145. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  146. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -94
  147. package/gradle/libs.versions.toml +0 -69
  148. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  149. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  150. package/gradle.properties +0 -26
  151. package/gradlew +0 -252
  152. package/gradlew.bat +0 -94
  153. package/ios-demo/README.md +0 -120
  154. 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
- }