@momo-kits/native-kits 0.162.0-debug → 0.162.1-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 (147) hide show
  1. package/.claude/settings.local.json +32 -0
  2. package/package.json +1 -1
  3. package/publish.sh +2 -2
  4. package/build.gradle.kts +0 -11
  5. package/compose/build.gradle.kts +0 -186
  6. package/compose/build.gradle.kts.backup +0 -186
  7. package/compose/compose.podspec +0 -47
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -123
  10. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  11. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  22. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  23. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -109
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -305
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -921
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -121
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -403
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -85
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -340
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -198
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -123
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -94
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -136
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -224
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -148
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -116
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -452
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -172
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -255
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -233
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -241
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -92
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -352
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -103
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -338
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -70
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -96
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -348
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -256
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -494
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -131
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -215
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -96
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -531
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -92
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -135
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -214
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -590
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -177
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -192
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -205
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -239
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -285
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -57
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  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 -14
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -50
  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 -253
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -133
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -100
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -145
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -345
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -556
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -161
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -243
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -187
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -279
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -32
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -370
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -131
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -167
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -72
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -66
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -70
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -33
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -186
  131. package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  132. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  133. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
  134. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
  135. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
  136. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
  137. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
  138. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
  139. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
  140. package/gradle/libs.versions.toml +0 -67
  141. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  142. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  143. package/gradle.properties +0 -26
  144. package/gradlew +0 -252
  145. package/gradlew.bat +0 -94
  146. package/local.properties +0 -8
  147. package/settings.gradle.kts +0 -64
@@ -1,157 +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.fillMaxSize
7
- import androidx.compose.foundation.layout.offset
8
- import androidx.compose.foundation.layout.size
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.runtime.remember
12
- import androidx.compose.ui.Alignment
13
- import androidx.compose.ui.Modifier
14
- import androidx.compose.ui.draw.clip
15
- import androidx.compose.ui.semantics.contentDescription
16
- import androidx.compose.ui.semantics.semantics
17
- import androidx.compose.ui.unit.dp
18
- import androidx.compose.ui.zIndex
19
- import vn.momo.kits.application.IsShowBaseLineDebug
20
- import vn.momo.kits.const.AppTheme
21
- import vn.momo.kits.const.Colors
22
- import vn.momo.kits.const.Spacing
23
- import vn.momo.kits.const.Typography
24
- import vn.momo.kits.modifier.conditional
25
- import vn.momo.kits.modifier.setAutomationId
26
-
27
- private const val LOGO_MOMO_URL =
28
- "https://static.momocdn.net/app/img/kits/logo_momo_circle.png"
29
- private const val ICON_SUPPORT_DEFAULT_URL =
30
- "https://static.momocdn.net/app/img/kits/_indicator.png"
31
-
32
- enum class AvatarSize(val sizeDp: Int, val iconSizeDp: Int) {
33
- SIZE_24(24, 16),
34
- SIZE_32(32, 16),
35
- SIZE_40(40, 24),
36
- SIZE_48(48, 32),
37
- SIZE_56(56, 32),
38
- SIZE_72(72, 40),
39
- }
40
-
41
- @Composable
42
- fun Avatar(
43
- modifier: Modifier = Modifier,
44
- size: AvatarSize = AvatarSize.SIZE_32,
45
- rounded: Boolean = true,
46
- name: String? = null,
47
- image: String? = null,
48
- showIconMomo: Boolean = false,
49
- showIconSupport: Boolean = false,
50
- iconSupport: String = ICON_SUPPORT_DEFAULT_URL,
51
- accessibilityLabel: String? = null,
52
- ) {
53
- val theme = AppTheme.current
54
-
55
- val cornerRadius = remember(rounded, size) {
56
- if (rounded) (size.sizeDp / 2).dp else Spacing.XS
57
- }
58
- val shape = remember(cornerRadius) { RoundedCornerShape(cornerRadius) }
59
-
60
- val badgeSizeDp = remember(size) { (size.iconSizeDp / 2).dp }
61
- val badgeShape = remember(size) {
62
- RoundedCornerShape((size.iconSizeDp / 4).dp)
63
- }
64
-
65
- val shouldShowIconTop = showIconMomo && rounded
66
- val shouldShowIconBottom = showIconSupport && rounded
67
-
68
- val initials = remember(name) {
69
- name?.let { avatarInitials(it) }
70
- }
71
-
72
- val automationId = remember(accessibilityLabel, name) {
73
- accessibilityLabel ?: "Avatar${if (name != null) "/$name" else ""}"
74
- }
75
-
76
- Box(
77
- modifier = modifier
78
- .size(size.sizeDp.dp)
79
- .conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) }
80
- .setAutomationId(automationId)
81
- .semantics { contentDescription = automationId },
82
- ) {
83
- // Inner box with clip — holds avatar content
84
- Box(
85
- modifier = Modifier
86
- .fillMaxSize()
87
- .clip(shape)
88
- .background(color = Colors.pink_09)
89
- .border(width = 1.dp, color = theme.colors.border.default, shape = shape),
90
- contentAlignment = Alignment.Center,
91
- ) {
92
- when {
93
- image != null -> {
94
- Image(
95
- source = image,
96
- modifier = Modifier
97
- .fillMaxSize()
98
- .clip(shape)
99
- .semantics { contentDescription = "$automationId|img" },
100
- )
101
- }
102
-
103
- name != null -> {
104
- Text(
105
- text = initials ?: "",
106
- style = Typography.descriptionXsRegular,
107
- color = Colors.pink_03,
108
- modifier = Modifier
109
- .semantics { contentDescription = "$automationId|text" },
110
- )
111
- }
112
-
113
- else -> {
114
- Icon(
115
- source = "basic_person",
116
- size = size.iconSizeDp.dp,
117
- color = Colors.pink_03,
118
- modifier = Modifier
119
- .semantics { contentDescription = "$automationId|icon" },
120
- )
121
- }
122
- }
123
- }
124
-
125
- // Badge icons — outside clip so they are not cut by border
126
- if (shouldShowIconTop) {
127
- Image(
128
- source = LOGO_MOMO_URL,
129
- modifier = Modifier
130
- .zIndex(1f)
131
- .align(Alignment.TopEnd)
132
- .offset(x = 1.dp, y = (-1).dp)
133
- .size(badgeSizeDp)
134
- .clip(badgeShape)
135
- .semantics { contentDescription = "$automationId|top-icon" },
136
- )
137
- }
138
-
139
- if (shouldShowIconBottom) {
140
- Image(
141
- source = iconSupport,
142
- modifier = Modifier
143
- .zIndex(1f)
144
- .align(Alignment.BottomEnd)
145
- .offset(x = 1.dp, y = 1.dp)
146
- .size(badgeSizeDp)
147
- .clip(badgeShape)
148
- .semantics { contentDescription = "$automationId|bottom-icon" },
149
- )
150
- }
151
- }
152
- }
153
-
154
- private fun avatarInitials(name: String): String {
155
- val words = name.trim().split(" ").filter { it.isNotEmpty() }
156
- return words.takeLast(2).joinToString("") { it.first().uppercaseChar().toString() }
157
- }
@@ -1,85 +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.unit.dp
15
- import vn.momo.kits.application.IsShowBaseLineDebug
16
- import vn.momo.kits.const.AppTheme
17
- import vn.momo.kits.const.Colors
18
- import vn.momo.kits.const.Radius
19
- import vn.momo.kits.const.Spacing
20
- import vn.momo.kits.const.Typography
21
- import vn.momo.kits.const.scaleSize
22
- import vn.momo.kits.modifier.conditional
23
-
24
-
25
- @Composable
26
- fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Modifier? = null) {
27
- val primaryColors = listOf(
28
- Color(0xFFF0F0F0),
29
- Color(0xFFEB2F96),
30
- Color(0xFF962AF0),
31
- Color(0xFF4E4BFF),
32
- Color(0xFF007AFF),
33
- Color(0xFF13C2C2),
34
- Color(0xFF34C759),
35
- Color(0xFFA0D911),
36
- Color(0xFFFFCC00),
37
- Color(0xFFFA8C16),
38
- Color(0xFFFA541C),
39
- Color(0xFFF5222D)
40
- )
41
-
42
- fun isNumber(label: String): Boolean {
43
- val numberRegex = "^\\d+$".toRegex()
44
- return numberRegex.matches(label)
45
- }
46
-
47
- fun formatTitle(label: String): String {
48
- if (isNumber(label) && label.toInt() > 99) {
49
- return "99+"
50
- }
51
- return label
52
- }
53
-
54
- var badgeColor =
55
- if (isNumber(label)) {
56
- AppTheme.current.colors.error.primary
57
- } else {
58
- AppTheme.current.colors.warning.primary
59
- }
60
-
61
- if (backgroundColor != null && primaryColors.contains(backgroundColor)) {
62
- badgeColor = backgroundColor
63
- }
64
- val scaleSize = scaleSize(16f)
65
-
66
- if (modifier != null) {
67
- Box(
68
- modifier = modifier
69
- .height(scaleSize.dp)
70
- .widthIn(min = scaleSize.dp)
71
- .background(color = badgeColor, shape = RoundedCornerShape(Radius.M))
72
- .border(width = 1.dp, shape = RoundedCornerShape(Radius.M), color = Colors.black_01)
73
- .conditional(IsShowBaseLineDebug) {
74
- border(1.dp, Colors.blue_03)
75
- }
76
- .padding(horizontal = Spacing.XS), contentAlignment = Alignment.Center
77
- ) {
78
- Text(
79
- text = formatTitle(label),
80
- color = Colors.black_01,
81
- style = Typography.actionXxsBold
82
- )
83
- }
84
- }
85
- }
@@ -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,340 +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
- 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
- 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
- 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
- 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
- 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
- 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 paddingBottom = minRibbonHeight / 4f
194
- val badgeHeight = minRibbonHeight + paddingBottom
195
- val horizontalPadding = paddingBottom
196
- val badgeWidth = (textWidth + horizontalPadding * 2).coerceAtLeast(28.dp)
197
-
198
- val (rotateZ, scaleY, scaleX) = when (position) {
199
- RibbonPosition.TopLeft -> Triple(0f, 1f, -1f)
200
- RibbonPosition.TopRight -> Triple(0f, 1f, 1f)
201
- RibbonPosition.BottomRight -> Triple(0f, -1f, 1f)
202
- RibbonPosition.BottomLeft -> Triple(0f, -1f, -1f)
203
- }
204
-
205
- Box(
206
- modifier = modifier
207
- .size(width = badgeWidth, height = badgeHeight)
208
- .graphicsLayer {
209
- rotationZ = rotateZ
210
- this.scaleY = scaleY
211
- this.scaleX = scaleX
212
- }
213
- ) {
214
- val roundedRect = (badgeHeight - paddingBottom) / 2f
215
-
216
- Canvas(modifier = Modifier.matchParentSize()) {
217
- val width = size.width
218
- val height = size.height
219
- val ribbonHeight = height - paddingBottom.toPx()
220
- val cornerRadius = roundedRect.toPx()
221
-
222
- val mainColor = Color(0xFFFA541C)
223
- val tailColor = Color(0xFFC41B24)
224
-
225
- val headWidth = 4.dp.toPx()
226
- val leftSectionWidth = width * (9f / 28f)
227
- val middleSectionWidth = width - leftSectionWidth - headWidth
228
- val rightX = leftSectionWidth + middleSectionWidth
229
-
230
- // 1. Tail + 2. BG
231
- val leftMiddlePath = Path().apply {
232
- addRoundRect(
233
- RoundRect(
234
- rect = Rect(
235
- left = 0f,
236
- top = 0f,
237
- right = rightX + 1f,
238
- bottom = ribbonHeight
239
- ),
240
- topLeft = CornerRadius(cornerRadius, cornerRadius),
241
- topRight = CornerRadius.Zero,
242
- bottomRight = CornerRadius.Zero,
243
- bottomLeft = CornerRadius(cornerRadius, cornerRadius)
244
- )
245
- )
246
- }
247
- drawPath(
248
- path = leftMiddlePath,
249
- color = mainColor
250
- )
251
-
252
- // 3. Head
253
- val headPath = Path().apply {
254
- addRoundRect(
255
- RoundRect(
256
- rect = Rect(
257
- left = rightX,
258
- top = 0f,
259
- right = rightX + headWidth,
260
- bottom = ribbonHeight
261
- ),
262
- topLeft = CornerRadius.Zero,
263
- topRight = CornerRadius(cornerRadius, cornerRadius),
264
- bottomRight = CornerRadius.Zero,
265
- bottomLeft = CornerRadius.Zero
266
- )
267
- )
268
- }
269
- drawPath(
270
- path = headPath,
271
- color = mainColor
272
- )
273
-
274
- // Draw bottom tail section
275
- val tailY = ribbonHeight
276
- val tailHeight = paddingBottom.toPx()
277
- val halfHeadWidth = headWidth / 2f
278
- val tailStartX = rightX + headWidth - halfHeadWidth
279
-
280
- // Background square (main color)
281
- drawRect(
282
- color = mainColor,
283
- topLeft = Offset(tailStartX, tailY),
284
- size = Size(halfHeadWidth, halfHeadWidth)
285
- )
286
-
287
- val tailRoundRadius = tailHeight
288
- val tailRightPath = Path().apply {
289
- addRoundRect(
290
- RoundRect(
291
- rect = Rect(
292
- left = tailStartX,
293
- top = tailY,
294
- right = tailStartX + halfHeadWidth,
295
- bottom = tailY + tailHeight
296
- ),
297
- topLeft = CornerRadius.Zero,
298
- topRight = CornerRadius(tailRoundRadius, tailRoundRadius),
299
- bottomRight = CornerRadius(tailRoundRadius, tailRoundRadius),
300
- bottomLeft = CornerRadius.Zero
301
- )
302
- )
303
- }
304
- drawPath(
305
- path = tailRightPath,
306
- color = tailColor
307
- )
308
- }
309
-
310
- Text(
311
- text = text,
312
- modifier = Modifier
313
- .padding(bottom = paddingBottom)
314
- .padding(horizontal = paddingBottom / 2)
315
- .align(Alignment.Center)
316
- .graphicsLayer {
317
- rotationZ = rotateZ
318
- this.scaleY = scaleY
319
- this.scaleX = scaleX
320
- },
321
- textAlign = TextAlign.Center,
322
- style = Typography.labelXsMedium,
323
- maxLines = 1,
324
- overflow = TextOverflow.Ellipsis,
325
- color = Colors.black_01
326
- )
327
- }
328
- }
329
-
330
- val ribbonHeight: Dp = 20.dp
331
- val roundHeight: Dp = 16.dp
332
- val skewBodyHeight: Dp = 16.dp
333
- val roundRightRadius: Dp = 12.dp
334
- val roundPaddingEnd: Dp = 6.dp
335
- val skewTailWidth: Dp = 8.dp
336
- val skewTailHeight: Dp = 16.dp
337
- val headTailWidth: Dp = 5.dp
338
- val headTailHeight: Dp = 20.dp
339
-
340
- enum class RibbonPosition {TopLeft, TopRight, BottomLeft, BottomRight}