@momo-kits/native-kits 0.157.1 → 0.157.2-beta.1-debug
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.
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +180 -0
- package/compose/build.gradle.kts.backup +180 -0
- package/compose/compose.podspec +54 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +110 -0
- package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +107 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +720 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +340 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +198 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +448 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +254 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +352 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +130 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +590 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +14 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +119 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +161 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +331 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +497 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +243 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +279 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +149 -0
- package/example/ios/Example.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +46 -0
- package/gradle/libs.versions.toml +57 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Input/Input.swift +112 -50
- package/ios/Input/InputPhoneNumber.swift +2 -1
- package/local.properties +8 -0
- package/package.json +1 -1
- package/settings.gradle.kts +52 -0
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
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}
|
|
@@ -0,0 +1,198 @@
|
|
|
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.WindowInsets
|
|
8
|
+
import androidx.compose.foundation.layout.asPaddingValues
|
|
9
|
+
import androidx.compose.foundation.layout.fillMaxHeight
|
|
10
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
11
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
12
|
+
import androidx.compose.foundation.layout.height
|
|
13
|
+
import androidx.compose.foundation.layout.navigationBars
|
|
14
|
+
import androidx.compose.foundation.layout.padding
|
|
15
|
+
import androidx.compose.foundation.layout.width
|
|
16
|
+
import androidx.compose.runtime.Composable
|
|
17
|
+
import androidx.compose.ui.Alignment
|
|
18
|
+
import androidx.compose.ui.Modifier
|
|
19
|
+
import androidx.compose.ui.geometry.Offset
|
|
20
|
+
import androidx.compose.ui.graphics.Color
|
|
21
|
+
import androidx.compose.ui.graphics.PathEffect
|
|
22
|
+
import androidx.compose.ui.graphics.StrokeCap
|
|
23
|
+
import androidx.compose.ui.unit.dp
|
|
24
|
+
import io.ktor.util.Platform
|
|
25
|
+
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
26
|
+
import vn.momo.kits.const.Colors
|
|
27
|
+
import vn.momo.kits.modifier.conditional
|
|
28
|
+
import vn.momo.kits.platform.getPlatformName
|
|
29
|
+
import vn.momo.kits.platform.getStatusBarHeight
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A debug overlay that draws danger/warning baseline guides on top of the screen.
|
|
33
|
+
*
|
|
34
|
+
* Highlights safe-area boundaries, header regions, and bottom navigation zones
|
|
35
|
+
* using colored solid or dotted lines and semi-transparent red zones.
|
|
36
|
+
*
|
|
37
|
+
* @param enabled When `false` the composable renders nothing. Pass `false` when
|
|
38
|
+
* your QC automation flag is active to suppress the overlay.
|
|
39
|
+
*/
|
|
40
|
+
@Composable
|
|
41
|
+
fun BaselineView(enabled: Boolean = true) {
|
|
42
|
+
if (!enabled) return
|
|
43
|
+
|
|
44
|
+
val bottomInsetHeight = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
|
|
45
|
+
val topInset = if (getPlatformName() == "Android") getStatusBarHeight() - 14.dp else getStatusBarHeight()
|
|
46
|
+
val bottomInset = if (getPlatformName() == "iOS") minOf(bottomInsetHeight, 21.dp) else bottomInsetHeight
|
|
47
|
+
|
|
48
|
+
Box(modifier = Modifier.fillMaxSize()) {
|
|
49
|
+
// Danger zones
|
|
50
|
+
Box(
|
|
51
|
+
modifier = Modifier
|
|
52
|
+
.fillMaxWidth()
|
|
53
|
+
.height(topInset)
|
|
54
|
+
.background(Color.Red.copy(alpha = 0.15f))
|
|
55
|
+
)
|
|
56
|
+
Box(
|
|
57
|
+
modifier = Modifier
|
|
58
|
+
.width(12.dp)
|
|
59
|
+
.fillMaxHeight()
|
|
60
|
+
.padding(top = topInset, bottom = bottomInset)
|
|
61
|
+
.background(Color.Red.copy(alpha = 0.15f))
|
|
62
|
+
)
|
|
63
|
+
Box(
|
|
64
|
+
modifier = Modifier
|
|
65
|
+
.width(12.dp)
|
|
66
|
+
.fillMaxHeight()
|
|
67
|
+
.padding(top = topInset, bottom = bottomInset)
|
|
68
|
+
.background(Color.Red.copy(alpha = 0.15f))
|
|
69
|
+
.align(Alignment.TopEnd)
|
|
70
|
+
)
|
|
71
|
+
Box(
|
|
72
|
+
modifier = Modifier
|
|
73
|
+
.fillMaxWidth()
|
|
74
|
+
.height(bottomInset)
|
|
75
|
+
.background(Color.Red.copy(alpha = 0.15f))
|
|
76
|
+
.align(Alignment.BottomCenter)
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
// Danger lines
|
|
80
|
+
BaselineDottedLine(
|
|
81
|
+
Modifier
|
|
82
|
+
.padding(top = topInset)
|
|
83
|
+
.fillMaxWidth(),
|
|
84
|
+
isDotted = false,
|
|
85
|
+
color = Color(0xFFE400FF)
|
|
86
|
+
)
|
|
87
|
+
BaselineDottedLine(
|
|
88
|
+
Modifier
|
|
89
|
+
.padding(top = topInset + 52.dp)
|
|
90
|
+
.fillMaxWidth(),
|
|
91
|
+
color = Color(0xFFE400FF)
|
|
92
|
+
)
|
|
93
|
+
BaselineDottedLine(
|
|
94
|
+
Modifier
|
|
95
|
+
.padding(top = topInset + 104.dp)
|
|
96
|
+
.fillMaxWidth(),
|
|
97
|
+
color = Color(0xFFE400FF)
|
|
98
|
+
)
|
|
99
|
+
BaselineDottedLine(
|
|
100
|
+
Modifier
|
|
101
|
+
.padding(bottom = bottomInset + 64.dp)
|
|
102
|
+
.fillMaxWidth()
|
|
103
|
+
.align(Alignment.BottomCenter),
|
|
104
|
+
color = Color(0xFFE400FF)
|
|
105
|
+
)
|
|
106
|
+
BaselineDottedLine(
|
|
107
|
+
Modifier
|
|
108
|
+
.padding(bottom = bottomInset)
|
|
109
|
+
.fillMaxWidth()
|
|
110
|
+
.align(Alignment.BottomCenter),
|
|
111
|
+
isDotted = false,
|
|
112
|
+
color = Color(0xFFE400FF)
|
|
113
|
+
)
|
|
114
|
+
BaselineDottedLine(
|
|
115
|
+
Modifier
|
|
116
|
+
.padding(start = 12.dp)
|
|
117
|
+
.fillMaxHeight(),
|
|
118
|
+
orientation = BaselineOrientation.Vertical,
|
|
119
|
+
isDotted = false,
|
|
120
|
+
color = Color(0xFFE400FF)
|
|
121
|
+
)
|
|
122
|
+
BaselineDottedLine(
|
|
123
|
+
Modifier
|
|
124
|
+
.padding(end = 12.dp)
|
|
125
|
+
.fillMaxHeight()
|
|
126
|
+
.align(Alignment.BottomEnd),
|
|
127
|
+
orientation = BaselineOrientation.Vertical,
|
|
128
|
+
isDotted = false,
|
|
129
|
+
color = Color(0xFFE400FF)
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
// Warning lines
|
|
133
|
+
BaselineDottedLine(
|
|
134
|
+
Modifier
|
|
135
|
+
.padding(top = topInset + 26.dp)
|
|
136
|
+
.fillMaxWidth(),
|
|
137
|
+
color = Color(0xFFFF7A00)
|
|
138
|
+
)
|
|
139
|
+
BaselineDottedLine(
|
|
140
|
+
Modifier
|
|
141
|
+
.padding(bottom = bottomInset + 56.dp)
|
|
142
|
+
.fillMaxWidth()
|
|
143
|
+
.align(Alignment.BottomCenter),
|
|
144
|
+
color = Color(0xFFFFCC00)
|
|
145
|
+
)
|
|
146
|
+
BaselineDottedLine(
|
|
147
|
+
Modifier
|
|
148
|
+
.padding(bottom = bottomInset + 8.dp)
|
|
149
|
+
.fillMaxWidth()
|
|
150
|
+
.align(Alignment.BottomCenter),
|
|
151
|
+
color = Color(0xFFFFCC00)
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
// Header background warning lines
|
|
155
|
+
BaselineDottedLine(
|
|
156
|
+
Modifier
|
|
157
|
+
.padding(start = 40.dp, top = topInset)
|
|
158
|
+
.height(52.dp),
|
|
159
|
+
color = Color(0xFF00C520),
|
|
160
|
+
orientation = BaselineOrientation.Vertical
|
|
161
|
+
)
|
|
162
|
+
BaselineDottedLine(
|
|
163
|
+
Modifier
|
|
164
|
+
.padding(start = 48.dp, top = topInset)
|
|
165
|
+
.height(52.dp),
|
|
166
|
+
color = Color(0xFF00C520),
|
|
167
|
+
orientation = BaselineOrientation.Vertical
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
enum class BaselineOrientation { Horizontal, Vertical }
|
|
173
|
+
|
|
174
|
+
@Composable
|
|
175
|
+
fun BaselineDottedLine(
|
|
176
|
+
modifier: Modifier = Modifier,
|
|
177
|
+
color: Color = Color.Red,
|
|
178
|
+
orientation: BaselineOrientation = BaselineOrientation.Horizontal,
|
|
179
|
+
isDotted: Boolean = true
|
|
180
|
+
) {
|
|
181
|
+
Canvas(modifier = modifier) {
|
|
182
|
+
val pathEffect = if (isDotted) PathEffect.dashPathEffect(floatArrayOf(8f, 8f)) else null
|
|
183
|
+
drawLine(
|
|
184
|
+
color = color,
|
|
185
|
+
start = if (orientation == BaselineOrientation.Horizontal) Offset(
|
|
186
|
+
0f,
|
|
187
|
+
size.height / 2
|
|
188
|
+
) else Offset(size.width / 2, 0f),
|
|
189
|
+
end = if (orientation == BaselineOrientation.Horizontal) Offset(
|
|
190
|
+
size.width,
|
|
191
|
+
size.height / 2
|
|
192
|
+
) else Offset(size.width / 2, size.height),
|
|
193
|
+
strokeWidth = 1.dp.toPx(),
|
|
194
|
+
pathEffect = pathEffect,
|
|
195
|
+
cap = StrokeCap.Round,
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
}
|