@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.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.162.2-lottie.1-debug"
43
+ version = "0.162.2-lottie.2-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.162.2-beta.20'
3
+ spec.version = '0.162.2-lottie.1'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -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, restartKey, modifier)
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
- // key(restartKey) replays from frame 0; restartOnPlay = false makes isPlaying resume.
118
- key(restartKey) {
119
- LottieAnimation(
120
- composition = composition,
121
- iterations = iterations,
122
- isPlaying = isPlaying,
123
- restartOnPlay = false,
124
- dynamicProperties = if (tintColor != null) dynamicProperties else null,
125
- modifier = modifier
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
- // key(restartKey) recreates the animation state so a new key replays from frame 0;
55
- // restartOnPlay = false makes isPlaying resume from the current frame instead.
56
- val lottieState = key(restartKey) {
57
- animateLottieCompositionAsState(
58
- composition = composition,
59
- iterations = iterations,
60
- isPlaying = isPlaying,
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
- // isPlaying pauses/resumes from the current frame; assign a new restartKey to replay from frame 0.
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, restartKey, modifier)
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
- // Pause / resume from the current frame.
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
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.162.2-lottie.1
21
+ version=0.162.2-lottie.2
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.2-lottie.1-debug",
3
+ "version": "0.162.2-lottie.2-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},