@momo-kits/native-kits 0.162.1-beta.1-debug → 0.162.1-beta.2-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/compose/build.gradle.kts +1 -1
- package/compose/build.gradle.kts.backup +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +1 -1
- package/gradle.properties +1 -1
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Deprecated.kt +0 -107
package/compose/build.gradle.kts
CHANGED
|
@@ -6,7 +6,7 @@ import androidx.compose.runtime.*
|
|
|
6
6
|
import androidx.compose.ui.Modifier
|
|
7
7
|
import androidx.compose.ui.unit.Dp
|
|
8
8
|
import vn.momo.kits.const.*
|
|
9
|
-
import vn.momo.kits.
|
|
9
|
+
import vn.momo.kits.modifier.DeprecatedModifier
|
|
10
10
|
import vn.momo.kits.platform.getStatusBarHeight
|
|
11
11
|
|
|
12
12
|
@Deprecated("Use IMaxApi instead", ReplaceWith("IMaxApi"))
|
|
@@ -101,7 +101,7 @@ fun ApplicationContainer(
|
|
|
101
101
|
AppConfig provides config,
|
|
102
102
|
AppLanguage provides language,
|
|
103
103
|
) {
|
|
104
|
-
Box(Modifier.wrapContentSize().then(
|
|
104
|
+
Box(Modifier.wrapContentSize().then(DeprecatedModifier())) {
|
|
105
105
|
content()
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -29,7 +29,7 @@ import vn.momo.kits.const.AppTheme
|
|
|
29
29
|
import vn.momo.kits.const.Colors
|
|
30
30
|
import vn.momo.kits.const.Spacing
|
|
31
31
|
import vn.momo.kits.modifier.conditional
|
|
32
|
-
import vn.momo.kits.
|
|
32
|
+
import vn.momo.kits.modifier.DeprecatedModifier
|
|
33
33
|
import vn.momo.kits.modifier.shadow
|
|
34
34
|
import vn.momo.kits.navigation.component.SnackBar
|
|
35
35
|
import vn.momo.kits.platform.supportsImePadding
|
|
@@ -111,7 +111,7 @@ fun Screen(
|
|
|
111
111
|
.background(backgroundColor ?: AppTheme.current.colors.background.default)
|
|
112
112
|
.conditional(useAvoidKeyboard && supportsImePadding()) {
|
|
113
113
|
imePadding()
|
|
114
|
-
}.then(
|
|
114
|
+
}.then(DeprecatedModifier())
|
|
115
115
|
) {
|
|
116
116
|
val footerHeightPx = remember { mutableStateOf(0) }
|
|
117
117
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
package vn.momo.kits.modifier
|
|
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.runtime.Composable
|
|
10
|
+
import androidx.compose.runtime.getValue
|
|
11
|
+
import androidx.compose.ui.Modifier
|
|
12
|
+
import androidx.compose.ui.draw.drawWithContent
|
|
13
|
+
import androidx.compose.ui.geometry.Offset
|
|
14
|
+
import androidx.compose.ui.graphics.Color
|
|
15
|
+
import androidx.compose.ui.graphics.drawscope.clipRect
|
|
16
|
+
import androidx.compose.ui.text.TextStyle
|
|
17
|
+
import androidx.compose.ui.text.drawText
|
|
18
|
+
import androidx.compose.ui.text.font.FontWeight
|
|
19
|
+
import androidx.compose.ui.text.rememberTextMeasurer
|
|
20
|
+
import androidx.compose.ui.unit.sp
|
|
21
|
+
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
22
|
+
import vn.momo.kits.const.Colors
|
|
23
|
+
|
|
24
|
+
@Suppress("ExperimentalAnnotationRetention")
|
|
25
|
+
@RequiresOptIn(
|
|
26
|
+
message = "This is internal API of native-kits, become internal in next sprint",
|
|
27
|
+
level = RequiresOptIn.Level.WARNING,
|
|
28
|
+
)
|
|
29
|
+
@Retention(AnnotationRetention.BINARY)
|
|
30
|
+
@Target(
|
|
31
|
+
AnnotationTarget.CLASS,
|
|
32
|
+
AnnotationTarget.FUNCTION,
|
|
33
|
+
AnnotationTarget.PROPERTY,
|
|
34
|
+
)
|
|
35
|
+
annotation class InternalApi
|
|
36
|
+
|
|
37
|
+
@Composable
|
|
38
|
+
fun DeprecatedModifier(text: String = "Deprecated component"): Modifier = debugMarker(
|
|
39
|
+
label = text,
|
|
40
|
+
background = Colors.red_04.copy(alpha = 0.7f),
|
|
41
|
+
textColor = Colors.red_01,
|
|
42
|
+
animationLabel = "deprecatedMarquee",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
@Composable
|
|
46
|
+
private fun debugMarker(
|
|
47
|
+
label: String,
|
|
48
|
+
background: Color,
|
|
49
|
+
textColor: Color,
|
|
50
|
+
animationLabel: String,
|
|
51
|
+
): Modifier {
|
|
52
|
+
if (!IsShowBaseLineDebug) return Modifier
|
|
53
|
+
|
|
54
|
+
val textMeasurer = rememberTextMeasurer()
|
|
55
|
+
val marquee = rememberInfiniteTransition(label = animationLabel)
|
|
56
|
+
val progress by marquee.animateFloat(
|
|
57
|
+
initialValue = 0f,
|
|
58
|
+
targetValue = 1f,
|
|
59
|
+
animationSpec = infiniteRepeatable(
|
|
60
|
+
animation = tween(durationMillis = 4000, easing = LinearEasing),
|
|
61
|
+
repeatMode = RepeatMode.Restart,
|
|
62
|
+
),
|
|
63
|
+
label = "${animationLabel}Progress",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
return Modifier.drawWithContent {
|
|
67
|
+
drawContent()
|
|
68
|
+
drawRect(color = background)
|
|
69
|
+
|
|
70
|
+
if (size.width <= 0f || size.height <= 0f) return@drawWithContent
|
|
71
|
+
|
|
72
|
+
val fontPx = (size.width * 0.1f).coerceIn(12.sp.toPx(), 20.sp.toPx())
|
|
73
|
+
val style = TextStyle(
|
|
74
|
+
color = textColor,
|
|
75
|
+
fontSize = fontPx.toSp(),
|
|
76
|
+
fontWeight = FontWeight.Bold,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
val intrinsic = textMeasurer.measure(
|
|
80
|
+
text = label,
|
|
81
|
+
style = style,
|
|
82
|
+
maxLines = 1,
|
|
83
|
+
softWrap = false,
|
|
84
|
+
)
|
|
85
|
+
val textW = intrinsic.size.width
|
|
86
|
+
val textH = intrinsic.size.height
|
|
87
|
+
val y = (size.height - textH) / 2f
|
|
88
|
+
|
|
89
|
+
if (textW <= size.width) {
|
|
90
|
+
drawText(
|
|
91
|
+
textLayoutResult = intrinsic,
|
|
92
|
+
topLeft = Offset((size.width - textW) / 2f, y),
|
|
93
|
+
)
|
|
94
|
+
} else {
|
|
95
|
+
clipRect(right = size.width, bottom = size.height) {
|
|
96
|
+
val gap = textW * 0.5f
|
|
97
|
+
val travel = textW + gap
|
|
98
|
+
val x = -progress * travel
|
|
99
|
+
drawText(textLayoutResult = intrinsic, topLeft = Offset(x, y))
|
|
100
|
+
drawText(textLayoutResult = intrinsic, topLeft = Offset(x + travel, y))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
package/gradle.properties
CHANGED
package/package.json
CHANGED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.utils
|
|
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.runtime.Composable
|
|
10
|
-
import androidx.compose.runtime.getValue
|
|
11
|
-
import androidx.compose.ui.Modifier
|
|
12
|
-
import androidx.compose.ui.draw.drawWithContent
|
|
13
|
-
import androidx.compose.ui.geometry.Offset
|
|
14
|
-
import androidx.compose.ui.graphics.Color
|
|
15
|
-
import androidx.compose.ui.graphics.drawscope.clipRect
|
|
16
|
-
import androidx.compose.ui.text.TextStyle
|
|
17
|
-
import androidx.compose.ui.text.drawText
|
|
18
|
-
import androidx.compose.ui.text.font.FontWeight
|
|
19
|
-
import androidx.compose.ui.text.rememberTextMeasurer
|
|
20
|
-
import androidx.compose.ui.unit.sp
|
|
21
|
-
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
22
|
-
import vn.momo.kits.const.Colors
|
|
23
|
-
|
|
24
|
-
object Deprecated {
|
|
25
|
-
|
|
26
|
-
@Suppress("ExperimentalAnnotationRetention")
|
|
27
|
-
@RequiresOptIn(
|
|
28
|
-
message = "This is internal API of native-kits, become internal in next sprint",
|
|
29
|
-
level = RequiresOptIn.Level.WARNING,
|
|
30
|
-
)
|
|
31
|
-
@Retention(AnnotationRetention.BINARY)
|
|
32
|
-
@Target(
|
|
33
|
-
AnnotationTarget.CLASS,
|
|
34
|
-
AnnotationTarget.FUNCTION,
|
|
35
|
-
AnnotationTarget.PROPERTY,
|
|
36
|
-
)
|
|
37
|
-
annotation class InternalApi
|
|
38
|
-
|
|
39
|
-
@Composable
|
|
40
|
-
fun deprecatedModifier(text: String = "Deprecated component"): Modifier = debugMarker(
|
|
41
|
-
label = text,
|
|
42
|
-
background = Colors.red_04.copy(alpha = 0.7f),
|
|
43
|
-
textColor = Colors.red_01,
|
|
44
|
-
animationLabel = "deprecatedMarquee",
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
@Composable
|
|
48
|
-
private fun debugMarker(
|
|
49
|
-
label: String,
|
|
50
|
-
background: Color,
|
|
51
|
-
textColor: Color,
|
|
52
|
-
animationLabel: String,
|
|
53
|
-
): Modifier {
|
|
54
|
-
if (!IsShowBaseLineDebug) return Modifier
|
|
55
|
-
|
|
56
|
-
val textMeasurer = rememberTextMeasurer()
|
|
57
|
-
val marquee = rememberInfiniteTransition(label = animationLabel)
|
|
58
|
-
val progress by marquee.animateFloat(
|
|
59
|
-
initialValue = 0f,
|
|
60
|
-
targetValue = 1f,
|
|
61
|
-
animationSpec = infiniteRepeatable(
|
|
62
|
-
animation = tween(durationMillis = 4000, easing = LinearEasing),
|
|
63
|
-
repeatMode = RepeatMode.Restart,
|
|
64
|
-
),
|
|
65
|
-
label = "${animationLabel}Progress",
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
return Modifier.drawWithContent {
|
|
69
|
-
drawContent()
|
|
70
|
-
drawRect(color = background)
|
|
71
|
-
|
|
72
|
-
if (size.width <= 0f || size.height <= 0f) return@drawWithContent
|
|
73
|
-
|
|
74
|
-
val fontPx = (size.width * 0.1f).coerceIn(12.sp.toPx(), 20.sp.toPx())
|
|
75
|
-
val style = TextStyle(
|
|
76
|
-
color = textColor,
|
|
77
|
-
fontSize = fontPx.toSp(),
|
|
78
|
-
fontWeight = FontWeight.Bold,
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
val intrinsic = textMeasurer.measure(
|
|
82
|
-
text = label,
|
|
83
|
-
style = style,
|
|
84
|
-
maxLines = 1,
|
|
85
|
-
softWrap = false,
|
|
86
|
-
)
|
|
87
|
-
val textW = intrinsic.size.width
|
|
88
|
-
val textH = intrinsic.size.height
|
|
89
|
-
val y = (size.height - textH) / 2f
|
|
90
|
-
|
|
91
|
-
if (textW <= size.width) {
|
|
92
|
-
drawText(
|
|
93
|
-
textLayoutResult = intrinsic,
|
|
94
|
-
topLeft = Offset((size.width - textW) / 2f, y),
|
|
95
|
-
)
|
|
96
|
-
} else {
|
|
97
|
-
clipRect(right = size.width, bottom = size.height) {
|
|
98
|
-
val gap = textW * 0.5f
|
|
99
|
-
val travel = textW + gap
|
|
100
|
-
val x = -progress * travel
|
|
101
|
-
drawText(textLayoutResult = intrinsic, topLeft = Offset(x, y))
|
|
102
|
-
drawText(textLayoutResult = intrinsic, topLeft = Offset(x + travel, y))
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|