@momo-kits/native-kits 0.155.1-tracking.13 → 0.155.1-tracking.14-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/compose.podspec +54 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +113 -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 +95 -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 +715 -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 +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +353 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +138 -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 +78 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +151 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +190 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +119 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +407 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +244 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +233 -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 +257 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +240 -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 +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +44 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +95 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +43 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +351 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +72 -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 +99 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +99 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +95 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +217 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +208 -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 +189 -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 +15 -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 +271 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +152 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +95 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +162 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +347 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +551 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +233 -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 +190 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +258 -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 +31 -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 +135 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +218 -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/Utils.kt +88 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +152 -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/local.properties +8 -0
- package/package.json +1 -1
- package/publish_release.sh +105 -0
- package/settings.gradle.kts +52 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.border
|
|
4
|
+
import androidx.compose.foundation.clickable
|
|
5
|
+
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
6
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
7
|
+
import androidx.compose.foundation.layout.Box
|
|
8
|
+
import androidx.compose.foundation.layout.Row
|
|
9
|
+
import androidx.compose.foundation.layout.padding
|
|
10
|
+
import androidx.compose.foundation.layout.size
|
|
11
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
12
|
+
import androidx.compose.runtime.Composable
|
|
13
|
+
import androidx.compose.runtime.remember
|
|
14
|
+
import androidx.compose.ui.Alignment
|
|
15
|
+
import androidx.compose.ui.Modifier
|
|
16
|
+
import androidx.compose.ui.draw.clip
|
|
17
|
+
import androidx.compose.ui.unit.dp
|
|
18
|
+
import vn.momo.kits.application.ApplicationContext
|
|
19
|
+
import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
|
|
20
|
+
import vn.momo.kits.const.AppTheme
|
|
21
|
+
import vn.momo.kits.const.Colors
|
|
22
|
+
import vn.momo.kits.const.Radius
|
|
23
|
+
import vn.momo.kits.const.Spacing
|
|
24
|
+
import vn.momo.kits.const.Typography
|
|
25
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
26
|
+
import vn.momo.kits.modifier.conditional
|
|
27
|
+
|
|
28
|
+
@Composable
|
|
29
|
+
fun Radio(
|
|
30
|
+
value: Any,
|
|
31
|
+
groupValue: Any,
|
|
32
|
+
disabled: Boolean = false,
|
|
33
|
+
onChange: () -> Unit = {},
|
|
34
|
+
label: String = "",
|
|
35
|
+
modifier: Modifier = Modifier,
|
|
36
|
+
) {
|
|
37
|
+
val selected = value == groupValue
|
|
38
|
+
val borderColor = when {
|
|
39
|
+
disabled && selected -> AppTheme.current.colors.background.tonal
|
|
40
|
+
disabled -> AppTheme.current.colors.text.disable
|
|
41
|
+
selected -> AppTheme.current.colors.primary
|
|
42
|
+
else -> AppTheme.current.colors.text.default
|
|
43
|
+
}
|
|
44
|
+
val borderWidth = if (selected) 6.dp else 2.dp
|
|
45
|
+
val application = ApplicationContext.current
|
|
46
|
+
|
|
47
|
+
Row(
|
|
48
|
+
modifier = modifier.activeOpacityClickable(
|
|
49
|
+
onClick = onChange,
|
|
50
|
+
enabled = !disabled,
|
|
51
|
+
),
|
|
52
|
+
horizontalArrangement = Arrangement.Center,
|
|
53
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
54
|
+
) {
|
|
55
|
+
Box(
|
|
56
|
+
modifier = modifier
|
|
57
|
+
.padding(end = if (label.isEmpty()) 0.dp else Spacing.XS)
|
|
58
|
+
.border(borderWidth, borderColor, RoundedCornerShape(Radius.M))
|
|
59
|
+
.conditional(application.isShowBaselineDebug()) {
|
|
60
|
+
border(1.dp, Colors.blue_03)
|
|
61
|
+
}
|
|
62
|
+
.clip(RoundedCornerShape(Radius.M))
|
|
63
|
+
.size(20.dp)
|
|
64
|
+
)
|
|
65
|
+
if (label.isNotEmpty()) {
|
|
66
|
+
Text(
|
|
67
|
+
style = Typography.descriptionDefaultRegular,
|
|
68
|
+
text = label,
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Composable
|
|
4
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
5
|
+
import vn.momo.kits.application.ScaleSizeMaxRate
|
|
6
|
+
|
|
7
|
+
@Composable
|
|
8
|
+
fun ScaleSizeScope(
|
|
9
|
+
scaleSizeMaxRate: Float? = null,
|
|
10
|
+
content: @Composable () -> Unit
|
|
11
|
+
) {
|
|
12
|
+
CompositionLocalProvider(
|
|
13
|
+
ScaleSizeMaxRate provides scaleSizeMaxRate,
|
|
14
|
+
) {
|
|
15
|
+
content()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.animation.core.LinearEasing
|
|
4
|
+
import androidx.compose.animation.core.RepeatMode
|
|
5
|
+
import androidx.compose.animation.core.animateFloat
|
|
6
|
+
import androidx.compose.animation.core.infiniteRepeatable
|
|
7
|
+
import androidx.compose.animation.core.rememberInfiniteTransition
|
|
8
|
+
import androidx.compose.animation.core.tween
|
|
9
|
+
import androidx.compose.foundation.background
|
|
10
|
+
import androidx.compose.foundation.border
|
|
11
|
+
import androidx.compose.foundation.layout.Box
|
|
12
|
+
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
13
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
14
|
+
import androidx.compose.runtime.Composable
|
|
15
|
+
import androidx.compose.runtime.remember
|
|
16
|
+
import androidx.compose.ui.Modifier
|
|
17
|
+
import androidx.compose.ui.draw.drawBehind
|
|
18
|
+
import androidx.compose.ui.geometry.Offset
|
|
19
|
+
import androidx.compose.ui.graphics.Brush
|
|
20
|
+
import androidx.compose.ui.unit.dp
|
|
21
|
+
import vn.momo.kits.application.ApplicationContext
|
|
22
|
+
import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
|
|
23
|
+
import vn.momo.kits.const.Colors
|
|
24
|
+
import vn.momo.kits.modifier.conditional
|
|
25
|
+
|
|
26
|
+
// Pre-computed shimmer colors to avoid repeated list creation
|
|
27
|
+
private val shimmerColors = listOf(
|
|
28
|
+
Colors.black_05,
|
|
29
|
+
Colors.black_03,
|
|
30
|
+
Colors.black_05,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// Constants for better performance
|
|
34
|
+
private const val SHADOW_BRUSH_PERCENTAGE = 0.6f
|
|
35
|
+
private const val DEFAULT_DURATION_MILLIS = 1000
|
|
36
|
+
|
|
37
|
+
@Composable
|
|
38
|
+
fun Skeleton() {
|
|
39
|
+
val application = ApplicationContext.current
|
|
40
|
+
|
|
41
|
+
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
|
42
|
+
// Memoize width calculation
|
|
43
|
+
val maxWidthValue = remember(maxWidth) { maxWidth.value.toInt() }
|
|
44
|
+
|
|
45
|
+
Box(
|
|
46
|
+
modifier = Modifier
|
|
47
|
+
.fillMaxSize()
|
|
48
|
+
.background(Colors.black_05)
|
|
49
|
+
.conditional(application.isShowBaselineDebug()) {
|
|
50
|
+
border(1.dp, Colors.blue_03)
|
|
51
|
+
}
|
|
52
|
+
.shimmerLoadingAnimation(maxWidth = maxWidthValue)
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Composable
|
|
58
|
+
fun Modifier.shimmerLoadingAnimation(
|
|
59
|
+
maxWidth: Int,
|
|
60
|
+
angleOfAxisY: Float = 0f,
|
|
61
|
+
durationMillis: Int = DEFAULT_DURATION_MILLIS,
|
|
62
|
+
): Modifier {
|
|
63
|
+
// Memoize calculations to avoid repeated computations
|
|
64
|
+
val widthOfShadowBrush = remember(maxWidth) {
|
|
65
|
+
(maxWidth * SHADOW_BRUSH_PERCENTAGE).toInt()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
val animationTarget = remember(durationMillis, widthOfShadowBrush) {
|
|
69
|
+
(durationMillis + widthOfShadowBrush).toFloat()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
val transition = rememberInfiniteTransition(label = "shimmer")
|
|
73
|
+
val translateAnimation = transition.animateFloat(
|
|
74
|
+
initialValue = 0f,
|
|
75
|
+
targetValue = animationTarget,
|
|
76
|
+
animationSpec = infiniteRepeatable(
|
|
77
|
+
animation = tween(
|
|
78
|
+
durationMillis = durationMillis,
|
|
79
|
+
easing = LinearEasing,
|
|
80
|
+
),
|
|
81
|
+
repeatMode = RepeatMode.Restart,
|
|
82
|
+
),
|
|
83
|
+
label = "shimmerTranslate"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
return drawBehind {
|
|
87
|
+
// Memoize brush creation by using remember in the calling composable
|
|
88
|
+
val startX = translateAnimation.value - widthOfShadowBrush
|
|
89
|
+
val endX = translateAnimation.value
|
|
90
|
+
|
|
91
|
+
drawRect(
|
|
92
|
+
brush = Brush.linearGradient(
|
|
93
|
+
colors = shimmerColors,
|
|
94
|
+
start = Offset(x = startX, y = 0f),
|
|
95
|
+
end = Offset(x = endX, y = angleOfAxisY)
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.background
|
|
4
|
+
import androidx.compose.foundation.border
|
|
5
|
+
import androidx.compose.foundation.clickable
|
|
6
|
+
import androidx.compose.foundation.layout.Box
|
|
7
|
+
import androidx.compose.foundation.layout.height
|
|
8
|
+
import androidx.compose.foundation.layout.padding
|
|
9
|
+
import androidx.compose.foundation.layout.size
|
|
10
|
+
import androidx.compose.foundation.layout.width
|
|
11
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
12
|
+
import androidx.compose.runtime.Composable
|
|
13
|
+
import androidx.compose.runtime.remember
|
|
14
|
+
import androidx.compose.ui.Alignment
|
|
15
|
+
import androidx.compose.ui.Modifier
|
|
16
|
+
import androidx.compose.ui.draw.clip
|
|
17
|
+
import androidx.compose.ui.graphics.Color
|
|
18
|
+
import androidx.compose.ui.unit.dp
|
|
19
|
+
import vn.momo.kits.application.ApplicationContext
|
|
20
|
+
import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
|
|
21
|
+
import vn.momo.kits.const.Colors
|
|
22
|
+
import vn.momo.kits.const.Spacing
|
|
23
|
+
import vn.momo.kits.modifier.conditional
|
|
24
|
+
import vn.momo.kits.modifier.setAutomationId
|
|
25
|
+
|
|
26
|
+
// Pre-computed shapes to avoid repeated creation
|
|
27
|
+
private val switchShape = RoundedCornerShape(20.dp)
|
|
28
|
+
private val circleShape = RoundedCornerShape(percent = 100)
|
|
29
|
+
|
|
30
|
+
@Composable
|
|
31
|
+
fun Switch(
|
|
32
|
+
value: Boolean = false,
|
|
33
|
+
onChange: (Boolean) -> Unit = {},
|
|
34
|
+
disabled: Boolean = false,
|
|
35
|
+
title: String? = "",
|
|
36
|
+
accessibilityId: String? = ""
|
|
37
|
+
) {
|
|
38
|
+
// Memoize color calculations to avoid repeated conditional logic
|
|
39
|
+
val colors = remember(value, disabled) {
|
|
40
|
+
val circleColor = if (value) Colors.black_01 else Colors.black_03
|
|
41
|
+
val bgColor = when {
|
|
42
|
+
disabled && value -> Colors.green_09
|
|
43
|
+
disabled && !value -> Colors.black_05
|
|
44
|
+
value -> Colors.green_03
|
|
45
|
+
else -> Colors.black_07
|
|
46
|
+
}
|
|
47
|
+
circleColor to bgColor
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
val (circleBackgroundColor, backgroundColor) = colors
|
|
51
|
+
|
|
52
|
+
// Memoize automation ID to avoid string concatenation on every render
|
|
53
|
+
val automationIdValue = remember(accessibilityId, title, value) {
|
|
54
|
+
accessibilityId ?: "toggle_${title ?: "unknown"}_$value"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Memoize alignment calculation
|
|
58
|
+
val contentAlignment = remember(value) {
|
|
59
|
+
if (value) Alignment.CenterEnd else Alignment.CenterStart
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Memoize click handler to avoid lambda recreation
|
|
63
|
+
val onClickHandler = remember(onChange, value) {
|
|
64
|
+
{ onChange(!value) }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
val application = ApplicationContext.current
|
|
68
|
+
|
|
69
|
+
Box(modifier = Modifier.setAutomationId(automationIdValue)) {
|
|
70
|
+
Box(
|
|
71
|
+
modifier = Modifier
|
|
72
|
+
.width(38.dp)
|
|
73
|
+
.height(20.dp)
|
|
74
|
+
.border(0.dp, Color.Unspecified, switchShape)
|
|
75
|
+
.background(backgroundColor, switchShape)
|
|
76
|
+
.conditional(application.isShowBaselineDebug()) {
|
|
77
|
+
border(1.dp, Colors.blue_03)
|
|
78
|
+
}
|
|
79
|
+
.clip(switchShape)
|
|
80
|
+
.clickable(enabled = !disabled, onClick = onClickHandler)
|
|
81
|
+
.padding(horizontal = Spacing.XS),
|
|
82
|
+
contentAlignment = contentAlignment
|
|
83
|
+
) {
|
|
84
|
+
Box(
|
|
85
|
+
modifier = Modifier
|
|
86
|
+
.size(14.dp)
|
|
87
|
+
.border(0.dp, Color.Unspecified, circleShape)
|
|
88
|
+
.background(circleBackgroundColor, circleShape),
|
|
89
|
+
contentAlignment = Alignment.Center
|
|
90
|
+
) {
|
|
91
|
+
Box(
|
|
92
|
+
Modifier
|
|
93
|
+
.size(6.dp)
|
|
94
|
+
.background(backgroundColor, circleShape)
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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.Row
|
|
7
|
+
import androidx.compose.foundation.layout.height
|
|
8
|
+
import androidx.compose.foundation.layout.padding
|
|
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.ApplicationContext
|
|
16
|
+
import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
|
|
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
|
+
enum class TagSize(val height: Float) {
|
|
25
|
+
Large(24.toFloat()),
|
|
26
|
+
Medium(18.toFloat())
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
enum class TagColor(val backgroundColor: Color, val textColor: Color) {
|
|
30
|
+
Default(Colors.black_04, Colors.black_17),
|
|
31
|
+
Orange(Colors.orange_08, Colors.orange_03),
|
|
32
|
+
Green(Colors.green_08, Colors.green_03),
|
|
33
|
+
Red(Colors.red_08, Colors.red_03),
|
|
34
|
+
Blue(Colors.blue_08, Colors.blue_03),
|
|
35
|
+
Grey(Colors.black_04, Colors.black_12),
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Composable
|
|
39
|
+
fun Tag(
|
|
40
|
+
label: String = "Label",
|
|
41
|
+
icon: String? = null,
|
|
42
|
+
color: TagColor = TagColor.Default,
|
|
43
|
+
size: TagSize = TagSize.Large,
|
|
44
|
+
customColor: Color? = null,
|
|
45
|
+
) {
|
|
46
|
+
val primaryColors = listOf(
|
|
47
|
+
Color(0xFFF0F0F0),
|
|
48
|
+
Color(0xFFEB2F96),
|
|
49
|
+
Color(0xFF962AF0),
|
|
50
|
+
Color(0xFF4E4BFF),
|
|
51
|
+
Color(0xFF007AFF),
|
|
52
|
+
Color(0xFF13C2C2),
|
|
53
|
+
Color(0xFF34C759),
|
|
54
|
+
Color(0xFFA0D911),
|
|
55
|
+
Color(0xFFFFCC00),
|
|
56
|
+
Color(0xFFFA8C16),
|
|
57
|
+
Color(0xFFFA541C),
|
|
58
|
+
Color(0xFFF5222D)
|
|
59
|
+
)
|
|
60
|
+
var tagColor = color.backgroundColor
|
|
61
|
+
var labelColor = color.textColor
|
|
62
|
+
|
|
63
|
+
if (primaryColors.contains(customColor)) {
|
|
64
|
+
tagColor = color.backgroundColor
|
|
65
|
+
labelColor = color.textColor
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
val application = ApplicationContext.current
|
|
69
|
+
|
|
70
|
+
Box(
|
|
71
|
+
modifier = Modifier
|
|
72
|
+
.height(scaleSize(size.height).dp)
|
|
73
|
+
.background(tagColor, shape = RoundedCornerShape(Radius.S))
|
|
74
|
+
.conditional(application.isShowBaselineDebug()) {
|
|
75
|
+
border(1.dp, Colors.blue_03)
|
|
76
|
+
}
|
|
77
|
+
.padding(horizontal = Spacing.S),
|
|
78
|
+
contentAlignment = Alignment.Center
|
|
79
|
+
) {
|
|
80
|
+
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
81
|
+
if (icon != null) {
|
|
82
|
+
Icon(
|
|
83
|
+
source = icon,
|
|
84
|
+
size = 16.dp,
|
|
85
|
+
color = labelColor
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
Text(
|
|
89
|
+
text = label,
|
|
90
|
+
color = labelColor,
|
|
91
|
+
style = Typography.labelSMedium
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.border
|
|
4
|
+
import androidx.compose.runtime.Composable
|
|
5
|
+
import androidx.compose.runtime.remember
|
|
6
|
+
import androidx.compose.ui.Modifier
|
|
7
|
+
import androidx.compose.ui.graphics.Color
|
|
8
|
+
import androidx.compose.ui.text.AnnotatedString
|
|
9
|
+
import androidx.compose.ui.text.TextLayoutResult
|
|
10
|
+
import androidx.compose.ui.text.TextStyle
|
|
11
|
+
import androidx.compose.ui.text.style.TextAlign
|
|
12
|
+
import androidx.compose.ui.text.style.TextDecoration
|
|
13
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
14
|
+
import androidx.compose.ui.unit.TextUnit
|
|
15
|
+
import androidx.compose.ui.unit.dp
|
|
16
|
+
import vn.momo.kits.application.ApplicationContext
|
|
17
|
+
import vn.momo.kits.application.MiniAppContext.Companion.isShowBaselineDebug
|
|
18
|
+
import vn.momo.kits.const.AppTheme
|
|
19
|
+
import vn.momo.kits.const.Colors
|
|
20
|
+
import vn.momo.kits.const.Typography
|
|
21
|
+
import vn.momo.kits.const.getFontFamily
|
|
22
|
+
import vn.momo.kits.const.scaleSize
|
|
23
|
+
import vn.momo.kits.modifier.conditional
|
|
24
|
+
import vn.momo.kits.modifier.setAutomationId
|
|
25
|
+
|
|
26
|
+
@Composable
|
|
27
|
+
fun Text(
|
|
28
|
+
text: String,
|
|
29
|
+
color: Color? = null,
|
|
30
|
+
style: TextStyle = Typography.bodyDefaultRegular,
|
|
31
|
+
textAlign: TextAlign? = TextAlign.Start,
|
|
32
|
+
modifier: Modifier = Modifier,
|
|
33
|
+
maxLines: Int = Int.MAX_VALUE,
|
|
34
|
+
overflow: TextOverflow = TextOverflow.Clip,
|
|
35
|
+
textDecoration: TextDecoration? = null,
|
|
36
|
+
onTextLayout: ((TextLayoutResult) -> Unit)? = null,
|
|
37
|
+
fontFamily: String? = null,
|
|
38
|
+
minLines: Int = 1,
|
|
39
|
+
letterSpacing: TextUnit = TextUnit.Unspecified,
|
|
40
|
+
softWrap: Boolean = true,
|
|
41
|
+
accessibilityId: String? = null
|
|
42
|
+
) {
|
|
43
|
+
Text(
|
|
44
|
+
text = AnnotatedString(text),
|
|
45
|
+
color = color,
|
|
46
|
+
style = style,
|
|
47
|
+
textAlign = textAlign,
|
|
48
|
+
modifier = modifier,
|
|
49
|
+
maxLines = maxLines,
|
|
50
|
+
overflow = overflow,
|
|
51
|
+
textDecoration = textDecoration,
|
|
52
|
+
onTextLayout = onTextLayout,
|
|
53
|
+
fontFamily = fontFamily,
|
|
54
|
+
minLines = minLines,
|
|
55
|
+
letterSpacing = letterSpacing,
|
|
56
|
+
softWrap = softWrap,
|
|
57
|
+
accessibilityId = accessibilityId
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@Composable
|
|
63
|
+
fun Text(
|
|
64
|
+
text: AnnotatedString,
|
|
65
|
+
color: Color? = null,
|
|
66
|
+
style: TextStyle = Typography.bodyDefaultRegular,
|
|
67
|
+
textAlign: TextAlign? = TextAlign.Start,
|
|
68
|
+
modifier: Modifier = Modifier,
|
|
69
|
+
maxLines: Int = Int.MAX_VALUE,
|
|
70
|
+
overflow: TextOverflow = TextOverflow.Clip,
|
|
71
|
+
textDecoration: TextDecoration? = null,
|
|
72
|
+
onTextLayout: ((TextLayoutResult) -> Unit)? = null,
|
|
73
|
+
fontFamily: String? = null,
|
|
74
|
+
minLines: Int = 1,
|
|
75
|
+
letterSpacing: TextUnit = TextUnit.Unspecified,
|
|
76
|
+
softWrap: Boolean = true,
|
|
77
|
+
accessibilityId: String? = null
|
|
78
|
+
) {
|
|
79
|
+
val application = ApplicationContext.current
|
|
80
|
+
// Cache theme access to avoid repeated lookups
|
|
81
|
+
val theme = AppTheme.current
|
|
82
|
+
|
|
83
|
+
// Call @Composable functions directly in composable context
|
|
84
|
+
val scaledFontSize = scaleSize(style.fontSize)
|
|
85
|
+
val scaledLineHeight = scaleSize(style.lineHeight)
|
|
86
|
+
val fontFamilyResult = getFontFamily(fontFamily ?: theme.font, style.fontWeight)
|
|
87
|
+
|
|
88
|
+
// Now memoize the results
|
|
89
|
+
val fontSize = remember(scaledFontSize) { scaledFontSize }
|
|
90
|
+
val lineHeight = remember(scaledLineHeight) { scaledLineHeight }
|
|
91
|
+
val font = remember(fontFamilyResult) { fontFamilyResult }
|
|
92
|
+
|
|
93
|
+
// Memoize color calculation
|
|
94
|
+
val textColor = remember(color, theme) {
|
|
95
|
+
color ?: theme.colors.text.default
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Memoize style copy operation
|
|
99
|
+
val optimizedStyle = remember(style) {
|
|
100
|
+
style.copy(
|
|
101
|
+
fontWeight = null,
|
|
102
|
+
lineHeight = if (lineHeight.value.isFinite() && lineHeight.value > 0) lineHeight else style.lineHeight
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Memoize automation ID
|
|
107
|
+
val automationId = remember(accessibilityId, text) {
|
|
108
|
+
accessibilityId ?: text
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// on/off baseline config value, default will be false
|
|
112
|
+
|
|
113
|
+
androidx.compose.material3.Text(
|
|
114
|
+
modifier = modifier.conditional(application.isShowBaselineDebug()){
|
|
115
|
+
border(1.dp, Colors.blue_03)
|
|
116
|
+
}.setAutomationId(automationId.toString()),
|
|
117
|
+
text = text,
|
|
118
|
+
color = textColor,
|
|
119
|
+
style = optimizedStyle,
|
|
120
|
+
textAlign = textAlign,
|
|
121
|
+
fontSize = fontSize,
|
|
122
|
+
fontFamily = font,
|
|
123
|
+
maxLines = maxLines,
|
|
124
|
+
softWrap = softWrap,
|
|
125
|
+
letterSpacing = letterSpacing,
|
|
126
|
+
minLines = minLines,
|
|
127
|
+
textDecoration = textDecoration,
|
|
128
|
+
onTextLayout = onTextLayout ?: {},
|
|
129
|
+
overflow = overflow
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|