@momo-kits/native-kits 0.162.2-lottie.1-debug → 0.162.2-lottie.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/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +10 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +7 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +1 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +2 -10
- package/gradle.properties +1 -1
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -9,7 +9,6 @@ import android.os.Build
|
|
|
9
9
|
import androidx.compose.foundation.layout.Box
|
|
10
10
|
import androidx.compose.runtime.Composable
|
|
11
11
|
import androidx.compose.runtime.getValue
|
|
12
|
-
import androidx.compose.runtime.key
|
|
13
12
|
import androidx.compose.ui.Modifier
|
|
14
13
|
import androidx.compose.ui.graphics.Color
|
|
15
14
|
import androidx.compose.ui.graphics.NativePaint
|
|
@@ -80,12 +79,11 @@ actual fun LottieAnimation(
|
|
|
80
79
|
placedAsOverlay: Boolean,
|
|
81
80
|
iterations: Int,
|
|
82
81
|
isPlaying: Boolean,
|
|
83
|
-
restartKey: Any?,
|
|
84
82
|
modifier: Modifier,
|
|
85
83
|
useCompose: Boolean
|
|
86
84
|
) {
|
|
87
85
|
if (useCompose) {
|
|
88
|
-
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying,
|
|
86
|
+
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, modifier)
|
|
89
87
|
return
|
|
90
88
|
}
|
|
91
89
|
|
|
@@ -114,17 +112,15 @@ actual fun LottieAnimation(
|
|
|
114
112
|
)
|
|
115
113
|
|
|
116
114
|
// LottieConstants.IterateForever == Int.MAX_VALUE == LottieIterateForever sentinel.
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
)
|
|
127
|
-
}
|
|
115
|
+
// restartOnPlay = false makes isPlaying resume from the current frame.
|
|
116
|
+
LottieAnimation(
|
|
117
|
+
composition = composition,
|
|
118
|
+
iterations = iterations,
|
|
119
|
+
isPlaying = isPlaying,
|
|
120
|
+
restartOnPlay = false,
|
|
121
|
+
dynamicProperties = if (tintColor != null) dynamicProperties else null,
|
|
122
|
+
modifier = modifier
|
|
123
|
+
)
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
actual fun NativePaint.setColor(color: Color){
|
|
@@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Box
|
|
|
6
6
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
7
7
|
import androidx.compose.runtime.Composable
|
|
8
8
|
import androidx.compose.runtime.getValue
|
|
9
|
-
import androidx.compose.runtime.key
|
|
10
9
|
import androidx.compose.ui.Modifier
|
|
11
10
|
import androidx.compose.ui.graphics.Color
|
|
12
11
|
import io.github.alexzhirkevich.compottie.ExperimentalCompottieApi
|
|
@@ -25,7 +24,6 @@ internal fun ComposeLottieAnimation(
|
|
|
25
24
|
bgColor: Color?,
|
|
26
25
|
iterations: Int,
|
|
27
26
|
isPlaying: Boolean,
|
|
28
|
-
restartKey: Any?,
|
|
29
27
|
modifier: Modifier,
|
|
30
28
|
) {
|
|
31
29
|
val json = readJson(path)
|
|
@@ -51,16 +49,13 @@ internal fun ComposeLottieAnimation(
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
// Our sentinel LottieIterateForever == Compottie.IterateForever (both Int.MAX_VALUE).
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
restartOnPlay = false,
|
|
62
|
-
)
|
|
63
|
-
}
|
|
52
|
+
// restartOnPlay = false makes isPlaying resume from the current frame.
|
|
53
|
+
val lottieState = animateLottieCompositionAsState(
|
|
54
|
+
composition = composition,
|
|
55
|
+
iterations = iterations,
|
|
56
|
+
isPlaying = isPlaying,
|
|
57
|
+
restartOnPlay = false,
|
|
58
|
+
)
|
|
64
59
|
|
|
65
60
|
Box(modifier.background(bgColor ?: Color.Transparent)) {
|
|
66
61
|
Image(
|
|
@@ -53,9 +53,8 @@ expect fun LottieAnimation(
|
|
|
53
53
|
bgColor: Color? = null,
|
|
54
54
|
placedAsOverlay: Boolean = false,
|
|
55
55
|
iterations: Int = LottieIterateForever,
|
|
56
|
-
//
|
|
56
|
+
// Pauses/resumes from the current frame; auto-plays when true (the default).
|
|
57
57
|
isPlaying: Boolean = true,
|
|
58
|
-
restartKey: Any? = null,
|
|
59
58
|
modifier: Modifier = Modifier,
|
|
60
59
|
useCompose: Boolean = false
|
|
61
60
|
)
|
|
@@ -98,12 +98,11 @@ actual fun LottieAnimation(
|
|
|
98
98
|
placedAsOverlay: Boolean,
|
|
99
99
|
iterations: Int,
|
|
100
100
|
isPlaying: Boolean,
|
|
101
|
-
restartKey: Any?,
|
|
102
101
|
modifier: Modifier,
|
|
103
102
|
useCompose: Boolean
|
|
104
103
|
) {
|
|
105
104
|
if (useCompose) {
|
|
106
|
-
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying,
|
|
105
|
+
ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, modifier)
|
|
107
106
|
return
|
|
108
107
|
}
|
|
109
108
|
|
|
@@ -118,19 +117,12 @@ actual fun LottieAnimation(
|
|
|
118
117
|
animation = CompatibleAnimation(name = "compose-resources/composeResources/vn.momo.compose.resources/".plus(path), subdirectory = null, NSBundle.mainBundle)
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
//
|
|
120
|
+
// Auto-play on attach; pause / resume from the current frame as isPlaying changes.
|
|
122
121
|
LaunchedEffect(animationView.value, isPlaying) {
|
|
123
122
|
val view = animationView.value ?: return@LaunchedEffect
|
|
124
123
|
if (isPlaying) view.play() else view.pause()
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
// Replay from frame 0 whenever restartKey changes (and on first attach).
|
|
128
|
-
LaunchedEffect(animationView.value, restartKey) {
|
|
129
|
-
val view = animationView.value ?: return@LaunchedEffect
|
|
130
|
-
view.stop()
|
|
131
|
-
if (isPlaying) view.play()
|
|
132
|
-
}
|
|
133
|
-
|
|
134
126
|
when (val value = animation) {
|
|
135
127
|
null -> {
|
|
136
128
|
Box(modifier)
|
package/gradle.properties
CHANGED