@momo-kits/native-kits 0.169.10-beta.1-debug → 0.169.10

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 (189) hide show
  1. package/ios/Application/DesignSystemKits.swift +2 -3
  2. package/ios/Application/LanguageSource.swift +2 -3
  3. package/ios/Application/Localize.swift +4 -7
  4. package/ios/Application/LocalizeModifier.swift +2 -3
  5. package/ios/Badge/Badge.swift +5 -7
  6. package/ios/Button/Button.swift +2 -3
  7. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +3 -5
  8. package/ios/Carousel/Carousel.swift +2 -3
  9. package/ios/Collapse/Collapse.swift +17 -11
  10. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  11. package/ios/Icon/Icon.swift +2 -3
  12. package/ios/IconButton/IconButton.swift +2 -3
  13. package/ios/Input/InputSearch.swift +6 -23
  14. package/ios/Layout/ModalLayout.swift +2 -3
  15. package/ios/Layout/ScreenLayout.swift +10 -12
  16. package/ios/Layout/Section.swift +2 -3
  17. package/ios/Navigation/BottomSheet.swift +6 -9
  18. package/ios/Navigation/BottomTab/BottomTab.swift +6 -9
  19. package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -6
  20. package/ios/Navigation/BottomTab/CurvedContainer.swift +2 -3
  21. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  22. package/ios/Navigation/BottomTab/DuoTabBar.swift +6 -6
  23. package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -6
  24. package/ios/Navigation/Component/Header.swift +46 -31
  25. package/ios/Navigation/Component/HeaderJourney.swift +1 -2
  26. package/ios/Navigation/Component/HeaderLocation.swift +1 -2
  27. package/ios/Navigation/Component/HeaderRight.swift +15 -18
  28. package/ios/Navigation/Component/HeaderUser.swift +1 -2
  29. package/ios/Navigation/Component/SideBar.swift +15 -7
  30. package/ios/Navigation/HostBackGestureBridge.swift +2 -3
  31. package/ios/Navigation/ModalScreen.swift +13 -11
  32. package/ios/Navigation/Navigation.swift +3 -9
  33. package/ios/Navigation/NavigationContainer.swift +4 -6
  34. package/ios/Navigation/Navigator.swift +12 -18
  35. package/ios/Navigation/StackScreen.swift +25 -40
  36. package/ios/Navigation/StackTransition.swift +7 -6
  37. package/ios/Skeleton/Skeleton.swift +3 -6
  38. package/ios/Steps/Steps.swift +20 -15
  39. package/ios/TabView/TabView.swift +2 -3
  40. package/ios/Title/Title.swift +1 -3
  41. package/ios/Typography/FontScale.swift +6 -9
  42. package/ios/Typography/Text.swift +2 -3
  43. package/ios/Typography/Typography.swift +3 -4
  44. package/ios/native-kits.podspec +1 -1
  45. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  46. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
  47. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
  48. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
  49. package/package.json +1 -1
  50. package/build.gradle.kts +0 -11
  51. package/compose/build.gradle.kts +0 -198
  52. package/compose/compose.podspec +0 -47
  53. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  54. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  55. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  56. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  57. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  58. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  59. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -267
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -195
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -263
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -307
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -306
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -457
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -120
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -210
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -292
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -67
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -747
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -400
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -100
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  150. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -207
  151. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -132
  152. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  153. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  154. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  155. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  156. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  157. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -398
  158. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  159. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  160. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  161. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  162. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  163. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  164. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  165. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  166. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  167. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  168. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -22
  169. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  170. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  171. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  172. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  173. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  174. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  175. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  176. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  177. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  178. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  179. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  180. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -144
  181. package/gradle/libs.versions.toml +0 -67
  182. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  183. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  184. package/gradle.properties +0 -24
  185. package/gradlew +0 -252
  186. package/gradlew.bat +0 -94
  187. package/ios/Layout/HeaderLayout.swift +0 -67
  188. package/ios-demo/README.md +0 -120
  189. 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 = Colors.orange_03
222
- val tailColor = Colors.red_01
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
- }