@momo-kits/native-kits 0.169.4-debug → 0.169.5-beta.1

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 (148) hide show
  1. package/CLAUDE.md +1 -1
  2. package/PUBLISH_GUIDE.md +3 -10
  3. package/ios/Navigation/BottomTab/BottomTabBar.swift +21 -6
  4. package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -0
  5. package/ios/Typography/FontScale.swift +28 -5
  6. package/ios/native-kits.podspec +1 -1
  7. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  8. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +21 -9
  9. package/package.json +1 -4
  10. package/publish.sh +10 -36
  11. package/build.gradle.kts +0 -11
  12. package/compose/build.gradle.kts +0 -198
  13. package/compose/compose.podspec +0 -47
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  17. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  20. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -195
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -393
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -113
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -739
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -239
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -389
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -94
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -203
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -104
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  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 -399
  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 -192
  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 -92
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  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 -22
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -219
  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 -144
  141. package/gradle/libs.versions.toml +0 -69
  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-demo/README.md +0 -120
  148. package/settings.gradle.kts +0 -64
@@ -1,338 +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.layout.Box
7
- import androidx.compose.foundation.layout.Row
8
- import androidx.compose.foundation.layout.height
9
- import androidx.compose.foundation.layout.padding
10
- import androidx.compose.foundation.layout.size
11
- import androidx.compose.foundation.layout.width
12
- import androidx.compose.foundation.shape.RoundedCornerShape
13
- import androidx.compose.runtime.Composable
14
- import androidx.compose.runtime.remember
15
- import androidx.compose.ui.Alignment
16
- import androidx.compose.ui.Modifier
17
- import androidx.compose.ui.geometry.CornerRadius
18
- import androidx.compose.ui.geometry.Offset
19
- import androidx.compose.ui.geometry.Rect
20
- import androidx.compose.ui.geometry.RoundRect
21
- import androidx.compose.ui.geometry.Size
22
- import androidx.compose.ui.graphics.Color
23
- import androidx.compose.ui.graphics.Path
24
- import androidx.compose.ui.graphics.graphicsLayer
25
- import androidx.compose.ui.layout.ContentScale
26
- import androidx.compose.ui.platform.LocalDensity
27
- import androidx.compose.ui.text.rememberTextMeasurer
28
- import androidx.compose.ui.text.style.TextAlign
29
- import androidx.compose.ui.text.style.TextOverflow
30
- import androidx.compose.ui.unit.Dp
31
- import androidx.compose.ui.unit.dp
32
- import androidx.compose.ui.unit.sp
33
- import vn.momo.kits.application.IsShowBaseLineDebug
34
- import vn.momo.kits.const.AppTheme
35
- import vn.momo.kits.const.Colors
36
- import vn.momo.kits.const.Typography
37
- import vn.momo.kits.const.getFontFamily
38
- import vn.momo.kits.const.scaleSize
39
- import vn.momo.kits.modifier.conditional
40
-
41
- @Composable
42
- fun BadgeRibbon(
43
- position: RibbonPosition = RibbonPosition.TopRight,
44
- label: String = "Label",
45
- isRound: Boolean = false,
46
- modifier: Modifier = Modifier,
47
- ) {
48
- val theme = AppTheme.current
49
-
50
- val rotate = if (position == RibbonPosition.TopRight || position == RibbonPosition.BottomRight) 180f else 0f
51
- val useUpTail = position == RibbonPosition.BottomLeft || position == RibbonPosition.TopRight
52
- val verticalAlignment = when(position){
53
- RibbonPosition.TopLeft, RibbonPosition.BottomRight -> Alignment.Top
54
- RibbonPosition.BottomLeft, RibbonPosition.TopRight -> Alignment.Bottom
55
- }
56
-
57
- Row(
58
- modifier = modifier
59
- .height(ribbonHeight)
60
- .conditional(IsShowBaseLineDebug) {
61
- border(1.dp, Colors.blue_03)
62
- }
63
- .graphicsLayer { rotationZ = rotate },
64
- verticalAlignment = verticalAlignment
65
- ) {
66
- if (useUpTail) {
67
- UpTail()
68
- } else {
69
- DownTail()
70
- }
71
-
72
- if (isRound) {
73
- RenderRoundContent(label, rotate, theme.colors.warning.primary)
74
- } else {
75
- RenderSkewContent(label, rotate, theme.colors.warning.primary)
76
- }
77
- }
78
- }
79
-
80
- @Composable
81
- internal fun RenderRoundContent(label: String, rotate: Float, backgroundColor: Color){
82
- Box(
83
- modifier = Modifier
84
- .height(roundHeight)
85
- .background(
86
- color = backgroundColor,
87
- shape = RoundedCornerShape(
88
- topEnd = roundRightRadius,
89
- bottomEnd = roundRightRadius,
90
- )
91
- )
92
- .padding(end = roundPaddingEnd),
93
- contentAlignment = Alignment.Center,
94
- ) {
95
- Label(label, rotate)
96
- }
97
- }
98
-
99
- @Composable
100
- internal fun RenderSkewContent(label: String, rotate: Float, backgroundColor: Color){
101
- Box(
102
- modifier = Modifier
103
- .height(skewBodyHeight)
104
- .background(backgroundColor),
105
- contentAlignment = Alignment.Center
106
- ) {
107
- Label(label, rotate)
108
- }
109
- RightTail()
110
- }
111
-
112
- @Composable
113
- internal fun Label(label: String, rotate: Float){
114
- Text(
115
- text = label,
116
- color = Colors.black_01,
117
- maxLines = 1,
118
- overflow = TextOverflow.Ellipsis,
119
- style = Typography.labelXsMedium,
120
- modifier = Modifier.graphicsLayer { rotationZ = rotate }
121
- )
122
- }
123
-
124
- @Composable
125
- internal fun UpTail() {
126
- Image(
127
- source = "https://static.momocdn.net/app/img/kits/utils/Head_down_4x.png",
128
- modifier = Modifier
129
- .graphicsLayer { rotationZ = 180f }
130
- .width(headTailWidth)
131
- .height(headTailHeight),
132
- options = Options(
133
- contentScale = ContentScale.FillBounds,
134
- )
135
- )
136
- }
137
-
138
- @Composable
139
- internal fun DownTail() {
140
- Image(
141
- source = "https://static.momocdn.net/app/img/kits/utils/Head_4x.png",
142
- modifier = Modifier
143
- .width(headTailWidth)
144
- .height(headTailHeight),
145
- options = Options(
146
- contentScale = ContentScale.FillBounds,
147
- )
148
- )
149
- }
150
-
151
- @Composable
152
- internal fun RightTail() {
153
- Image(
154
- source = "https://static.momocdn.net/app/img/kits/utils/Tail_4x.png",
155
- modifier = Modifier
156
- .width(skewTailWidth)
157
- .height(skewTailHeight),
158
- options = Options(
159
- contentScale = ContentScale.FillBounds,
160
- )
161
- )
162
- }
163
-
164
- @Composable
165
- fun RoundedBadgeRibbon(
166
- text: String = "Label",
167
- position: RibbonPosition = RibbonPosition.TopLeft,
168
- modifier: Modifier = Modifier
169
- ) {
170
- val theme = AppTheme.current
171
- val density = LocalDensity.current
172
- val style = Typography.labelXsMedium
173
- val fontFamily = style.fontFamily
174
-
175
- val scaledFontSize = scaleSize(style.fontSize.value).sp
176
- val fontFamilyResult = getFontFamily(fontFamily?.toString() ?: theme.font, style.fontWeight)
177
-
178
- val fontSize = remember(scaledFontSize) { scaledFontSize }
179
- val font = remember(fontFamilyResult) { fontFamilyResult }
180
- val textMeasurer = rememberTextMeasurer()
181
-
182
- val textLayoutResult = remember(text, fontSize, font) {
183
- textMeasurer.measure(
184
- text = text,
185
- style = style.copy(fontSize = fontSize, fontFamily = font)
186
- )
187
- }
188
-
189
- val textWidth = with(density) { textLayoutResult.size.width.toDp() }
190
- val textHeight = with(density) { textLayoutResult.size.height.toDp() }
191
-
192
- val minRibbonHeight = (textHeight * 1.2f).coerceAtLeast(16.dp)
193
- val padding = minRibbonHeight / 4f
194
- val badgeHeight = minRibbonHeight + padding
195
- val badgeWidth = (textWidth + padding * 2).coerceAtLeast(28.dp)
196
-
197
- val (rotateZ, scaleY, scaleX) = when (position) {
198
- RibbonPosition.TopLeft -> Triple(0f, 1f, -1f)
199
- RibbonPosition.TopRight -> Triple(0f, 1f, 1f)
200
- RibbonPosition.BottomRight -> Triple(0f, -1f, 1f)
201
- RibbonPosition.BottomLeft -> Triple(0f, -1f, -1f)
202
- }
203
-
204
- Box(
205
- modifier = modifier
206
- .size(width = badgeWidth, height = badgeHeight)
207
- .graphicsLayer {
208
- rotationZ = rotateZ
209
- this.scaleY = scaleY
210
- this.scaleX = scaleX
211
- }
212
- ) {
213
- val roundedRect = (badgeHeight - padding) / 2f
214
-
215
- Canvas(modifier = Modifier.matchParentSize()) {
216
- val width = size.width
217
- val height = size.height
218
- val ribbonHeight = height - padding.toPx()
219
- val cornerRadius = roundedRect.toPx()
220
-
221
- val mainColor = Color(0xFFFA541C)
222
- val tailColor = Color(0xFFC41B24)
223
-
224
- val headWidth = 4.dp.toPx()
225
- val leftSectionWidth = width * (9f / 28f)
226
- val middleSectionWidth = width - leftSectionWidth - headWidth
227
- val rightX = leftSectionWidth + middleSectionWidth
228
-
229
- // 1. Tail + 2. BG
230
- val leftMiddlePath = Path().apply {
231
- addRoundRect(
232
- RoundRect(
233
- rect = Rect(
234
- left = 0f,
235
- top = 0f,
236
- right = rightX + 1f,
237
- bottom = ribbonHeight
238
- ),
239
- topLeft = CornerRadius(cornerRadius, cornerRadius),
240
- topRight = CornerRadius.Zero,
241
- bottomRight = CornerRadius.Zero,
242
- bottomLeft = CornerRadius(cornerRadius, cornerRadius)
243
- )
244
- )
245
- }
246
- drawPath(
247
- path = leftMiddlePath,
248
- color = mainColor
249
- )
250
-
251
- // 3. Head
252
- val headPath = Path().apply {
253
- addRoundRect(
254
- RoundRect(
255
- rect = Rect(
256
- left = rightX,
257
- top = 0f,
258
- right = rightX + headWidth,
259
- bottom = ribbonHeight
260
- ),
261
- topLeft = CornerRadius.Zero,
262
- topRight = CornerRadius(cornerRadius, cornerRadius),
263
- bottomRight = CornerRadius.Zero,
264
- bottomLeft = CornerRadius.Zero
265
- )
266
- )
267
- }
268
- drawPath(
269
- path = headPath,
270
- color = mainColor
271
- )
272
-
273
- // Draw bottom tail section
274
- val tailY = ribbonHeight
275
- val tailHeight = padding.toPx()
276
- val halfHeadWidth = headWidth / 2f
277
- val tailStartX = rightX + headWidth - halfHeadWidth
278
-
279
- // Background square (main color)
280
- drawRect(
281
- color = mainColor,
282
- topLeft = Offset(tailStartX, tailY),
283
- size = Size(halfHeadWidth, halfHeadWidth)
284
- )
285
-
286
- val tailRightPath = Path().apply {
287
- addRoundRect(
288
- RoundRect(
289
- rect = Rect(
290
- left = tailStartX,
291
- top = tailY,
292
- right = tailStartX + halfHeadWidth,
293
- bottom = tailY + tailHeight
294
- ),
295
- topLeft = CornerRadius.Zero,
296
- topRight = CornerRadius(tailHeight, tailHeight),
297
- bottomRight = CornerRadius(tailHeight, tailHeight),
298
- bottomLeft = CornerRadius.Zero
299
- )
300
- )
301
- }
302
- drawPath(
303
- path = tailRightPath,
304
- color = tailColor
305
- )
306
- }
307
-
308
- Text(
309
- text = text,
310
- modifier = Modifier
311
- .padding(bottom = padding)
312
- .padding(horizontal = padding / 2)
313
- .align(Alignment.Center)
314
- .graphicsLayer {
315
- rotationZ = rotateZ
316
- this.scaleY = scaleY
317
- this.scaleX = scaleX
318
- },
319
- textAlign = TextAlign.Center,
320
- style = Typography.labelXsMedium,
321
- maxLines = 1,
322
- overflow = TextOverflow.Ellipsis,
323
- color = Colors.black_01
324
- )
325
- }
326
- }
327
-
328
- private val ribbonHeight: Dp = 20.dp
329
- private val roundHeight: Dp = 16.dp
330
- private val skewBodyHeight: Dp = 16.dp
331
- private val roundRightRadius: Dp = 12.dp
332
- private val roundPaddingEnd: Dp = 6.dp
333
- private val skewTailWidth: Dp = 8.dp
334
- private val skewTailHeight: Dp = 16.dp
335
- private val headTailWidth: Dp = 5.dp
336
- private val headTailHeight: Dp = 20.dp
337
-
338
- enum class RibbonPosition {TopLeft, TopRight, BottomLeft, BottomRight}
@@ -1,175 +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.layout.*
6
- import androidx.compose.runtime.Composable
7
- import androidx.compose.ui.Alignment
8
- import androidx.compose.ui.Modifier
9
- import androidx.compose.ui.geometry.Offset
10
- import androidx.compose.ui.graphics.Color
11
- import androidx.compose.ui.graphics.PathEffect
12
- import androidx.compose.ui.graphics.StrokeCap
13
- import androidx.compose.ui.unit.dp
14
- import vn.momo.kits.platform.getPlatformName
15
- import vn.momo.kits.platform.getStatusBarHeight
16
-
17
- @Composable
18
- fun BaselineView(enabled: Boolean = true) {
19
- if (!enabled) return
20
-
21
- val bottomInsetHeight = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
22
- val topInset = if (getPlatformName() == "Android") getStatusBarHeight() - 14.dp else getStatusBarHeight()
23
- val bottomInset = if (getPlatformName() == "iOS") minOf(bottomInsetHeight, 21.dp) else bottomInsetHeight
24
-
25
- Box(modifier = Modifier.fillMaxSize()) {
26
- // Danger zones
27
- Box(
28
- modifier = Modifier
29
- .fillMaxWidth()
30
- .height(topInset)
31
- .background(Color.Red.copy(alpha = 0.15f))
32
- )
33
- Box(
34
- modifier = Modifier
35
- .width(12.dp)
36
- .fillMaxHeight()
37
- .padding(top = topInset, bottom = bottomInset)
38
- .background(Color.Red.copy(alpha = 0.15f))
39
- )
40
- Box(
41
- modifier = Modifier
42
- .width(12.dp)
43
- .fillMaxHeight()
44
- .padding(top = topInset, bottom = bottomInset)
45
- .background(Color.Red.copy(alpha = 0.15f))
46
- .align(Alignment.TopEnd)
47
- )
48
- Box(
49
- modifier = Modifier
50
- .fillMaxWidth()
51
- .height(bottomInset)
52
- .background(Color.Red.copy(alpha = 0.15f))
53
- .align(Alignment.BottomCenter)
54
- )
55
-
56
- // Danger lines
57
- BaselineDottedLine(
58
- Modifier
59
- .padding(top = topInset)
60
- .fillMaxWidth(),
61
- isDotted = false,
62
- color = Color(0xFFE400FF)
63
- )
64
- BaselineDottedLine(
65
- Modifier
66
- .padding(top = topInset + 52.dp)
67
- .fillMaxWidth(),
68
- color = Color(0xFFE400FF)
69
- )
70
- BaselineDottedLine(
71
- Modifier
72
- .padding(top = topInset + 104.dp)
73
- .fillMaxWidth(),
74
- color = Color(0xFFE400FF)
75
- )
76
- BaselineDottedLine(
77
- Modifier
78
- .padding(bottom = bottomInset + 64.dp)
79
- .fillMaxWidth()
80
- .align(Alignment.BottomCenter),
81
- color = Color(0xFFE400FF)
82
- )
83
- BaselineDottedLine(
84
- Modifier
85
- .padding(bottom = bottomInset)
86
- .fillMaxWidth()
87
- .align(Alignment.BottomCenter),
88
- isDotted = false,
89
- color = Color(0xFFE400FF)
90
- )
91
- BaselineDottedLine(
92
- Modifier
93
- .padding(start = 12.dp)
94
- .fillMaxHeight(),
95
- orientation = BaselineOrientation.Vertical,
96
- isDotted = false,
97
- color = Color(0xFFE400FF)
98
- )
99
- BaselineDottedLine(
100
- Modifier
101
- .padding(end = 12.dp)
102
- .fillMaxHeight()
103
- .align(Alignment.BottomEnd),
104
- orientation = BaselineOrientation.Vertical,
105
- isDotted = false,
106
- color = Color(0xFFE400FF)
107
- )
108
-
109
- // Warning lines
110
- BaselineDottedLine(
111
- Modifier
112
- .padding(top = topInset + 26.dp)
113
- .fillMaxWidth(),
114
- color = Color(0xFFFF7A00)
115
- )
116
- BaselineDottedLine(
117
- Modifier
118
- .padding(bottom = bottomInset + 56.dp)
119
- .fillMaxWidth()
120
- .align(Alignment.BottomCenter),
121
- color = Color(0xFFFFCC00)
122
- )
123
- BaselineDottedLine(
124
- Modifier
125
- .padding(bottom = bottomInset + 8.dp)
126
- .fillMaxWidth()
127
- .align(Alignment.BottomCenter),
128
- color = Color(0xFFFFCC00)
129
- )
130
-
131
- // Header background warning lines
132
- BaselineDottedLine(
133
- Modifier
134
- .padding(start = 40.dp, top = topInset)
135
- .height(52.dp),
136
- color = Color(0xFF00C520),
137
- orientation = BaselineOrientation.Vertical
138
- )
139
- BaselineDottedLine(
140
- Modifier
141
- .padding(start = 48.dp, top = topInset)
142
- .height(52.dp),
143
- color = Color(0xFF00C520),
144
- orientation = BaselineOrientation.Vertical
145
- )
146
- }
147
- }
148
-
149
- private enum class BaselineOrientation { Horizontal, Vertical }
150
-
151
- @Composable
152
- private fun BaselineDottedLine(
153
- modifier: Modifier = Modifier,
154
- color: Color = Color.Red,
155
- orientation: BaselineOrientation = BaselineOrientation.Horizontal,
156
- isDotted: Boolean = true
157
- ) {
158
- Canvas(modifier = modifier) {
159
- val pathEffect = if (isDotted) PathEffect.dashPathEffect(floatArrayOf(8f, 8f)) else null
160
- drawLine(
161
- color = color,
162
- start = if (orientation == BaselineOrientation.Horizontal) Offset(
163
- 0f,
164
- size.height / 2
165
- ) else Offset(size.width / 2, 0f),
166
- end = if (orientation == BaselineOrientation.Horizontal) Offset(
167
- size.width,
168
- size.height / 2
169
- ) else Offset(size.width / 2, size.height),
170
- strokeWidth = 1.dp.toPx(),
171
- pathEffect = pathEffect,
172
- cap = StrokeCap.Round,
173
- )
174
- }
175
- }