@momo-kits/native-kits 0.167.1-duo.13-debug → 0.167.1-duo.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CLAUDE.md +1 -1
  2. package/ios/Layout/ScreenLayout.swift +30 -52
  3. package/ios/Navigation/StackScreen.swift +8 -22
  4. package/ios/native-kits.podspec +1 -1
  5. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  6. package/package.json +1 -1
  7. package/.claude/settings.local.json +0 -185
  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 -831
  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 -76
  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 -16
  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 -188
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -297
  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 -209
  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 -37
  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 -40
  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/local.properties +0 -8
  155. package/settings.gradle.kts +0 -64
@@ -1,81 +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.layout.Box
6
- import androidx.compose.foundation.layout.height
7
- import androidx.compose.foundation.layout.padding
8
- import androidx.compose.foundation.layout.widthIn
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.ui.Alignment
12
- import androidx.compose.ui.Modifier
13
- import androidx.compose.ui.graphics.Color
14
- import androidx.compose.ui.text.style.TextOverflow
15
- import androidx.compose.ui.unit.dp
16
- import vn.momo.kits.application.IsShowBaseLineDebug
17
- import vn.momo.kits.const.*
18
- import vn.momo.kits.modifier.conditional
19
-
20
- private val badgePrimaryColors = listOf(
21
- Color(0xFFF0F0F0),
22
- Color(0xFFEB2F96),
23
- Color(0xFF962AF0),
24
- Color(0xFF4E4BFF),
25
- Color(0xFF007AFF),
26
- Color(0xFF13C2C2),
27
- Color(0xFF34C759),
28
- Color(0xFFA0D911),
29
- Color(0xFFFFCC00),
30
- Color(0xFFFA8C16),
31
- Color(0xFFFA541C),
32
- Color(0xFFF5222D)
33
- )
34
-
35
- private val badgeNumberRegex = "^\\d+$".toRegex()
36
-
37
- @Composable
38
- fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Modifier = Modifier) {
39
- fun isNumber(label: String): Boolean = badgeNumberRegex.matches(label)
40
-
41
- fun formatTitle(label: String): String {
42
- // Digits too long for Int are well over 99; toInt() would throw.
43
- if (isNumber(label) && (label.toIntOrNull() ?: Int.MAX_VALUE) > 99) {
44
- return "99+"
45
- }
46
- return label
47
- }
48
-
49
- var badgeColor =
50
- if (isNumber(label)) {
51
- AppTheme.current.colors.error.primary
52
- } else {
53
- AppTheme.current.colors.warning.primary
54
- }
55
-
56
- if (backgroundColor != null && badgePrimaryColors.contains(backgroundColor)) {
57
- badgeColor = backgroundColor
58
- }
59
- val scaleSize = scaleSize(16f)
60
-
61
- Box(
62
- modifier = modifier
63
- .height(scaleSize.dp)
64
- .widthIn(min = scaleSize.dp)
65
- .background(color = badgeColor, shape = RoundedCornerShape(Radius.M))
66
- .border(width = 1.dp, shape = RoundedCornerShape(Radius.M), color = Colors.black_01)
67
- .conditional(IsShowBaseLineDebug) {
68
- border(1.dp, Colors.blue_03)
69
- }
70
- .padding(horizontal = Spacing.XS),
71
- contentAlignment = Alignment.Center
72
- ) {
73
- Text(
74
- text = formatTitle(label),
75
- color = Colors.black_01,
76
- style = Typography.actionXxsBold,
77
- maxLines = 1,
78
- overflow = TextOverflow.Ellipsis
79
- )
80
- }
81
- }
@@ -1,32 +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.layout.Box
6
- import androidx.compose.foundation.layout.size
7
- import androidx.compose.foundation.shape.RoundedCornerShape
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Modifier
10
- import androidx.compose.ui.unit.dp
11
- import vn.momo.kits.application.IsShowBaseLineDebug
12
- import vn.momo.kits.const.Colors
13
- import vn.momo.kits.const.Radius
14
- import vn.momo.kits.modifier.conditional
15
-
16
- enum class DotSize(val size: Int) {
17
- Small(10),
18
- Large(16)
19
- }
20
-
21
- @Composable
22
- fun BadgeDot(size: DotSize = DotSize.Large, modifier: Modifier = Modifier) {
23
- Box(
24
- modifier = modifier
25
- .size(size.size.dp)
26
- .border(width = 1.dp, color = Colors.black_01, shape = RoundedCornerShape(Radius.S))
27
- .background(color = Colors.red_03, shape = RoundedCornerShape(Radius.S))
28
- .conditional(IsShowBaseLineDebug) {
29
- border(1.dp, Colors.blue_03)
30
- }
31
- )
32
- }
@@ -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
- }