@momo-kits/native-kits 0.151.2-test.10 → 0.151.2-test.11

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.
@@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.padding
12
12
  import androidx.compose.foundation.layout.size
13
13
  import androidx.compose.foundation.shape.RoundedCornerShape
14
14
  import androidx.compose.runtime.Composable
15
- import androidx.compose.runtime.getValue
16
15
  import androidx.compose.runtime.remember
17
16
  import androidx.compose.ui.Alignment
18
17
  import androidx.compose.ui.Modifier
@@ -23,18 +22,12 @@ import androidx.compose.ui.text.TextStyle
23
22
  import androidx.compose.ui.text.style.TextOverflow
24
23
  import androidx.compose.ui.unit.Dp
25
24
  import androidx.compose.ui.unit.dp
26
- import io.github.alexzhirkevich.compottie.Compottie
27
- import io.github.alexzhirkevich.compottie.LottieCompositionSpec
28
- import io.github.alexzhirkevich.compottie.animateLottieCompositionAsState
29
- import io.github.alexzhirkevich.compottie.rememberLottieComposition
30
- import io.github.alexzhirkevich.compottie.rememberLottiePainter
31
25
  import vn.momo.kits.const.AppTheme
32
26
  import vn.momo.kits.const.Colors
33
27
  import vn.momo.kits.const.Radius
34
28
  import vn.momo.kits.const.Spacing
35
29
  import vn.momo.kits.const.Typography
36
30
  import vn.momo.kits.modifier.activeOpacityClickable
37
- import vn.momo.uikits.resources.Res
38
31
 
39
32
  enum class ButtonType {
40
33
  PRIMARY,
@@ -152,22 +145,9 @@ fun RenderLeading(
152
145
  ) {
153
146
  if (loading) {
154
147
  Box(Modifier.padding(end = marginRight)) {
155
- val composition by rememberLottieComposition {
156
- LottieCompositionSpec.JsonString(
157
- Res.readBytes("files/lottie_circle_loader.json").decodeToString()
158
- )
159
- }
160
-
161
- val progress by animateLottieCompositionAsState(
162
- composition = composition,
163
- iterations = Compottie.IterateForever
164
- )
165
-
166
- Image(
167
- source = rememberLottiePainter(
168
- composition = composition,
169
- progress = { progress }
170
- ),
148
+ LottieView(
149
+ path = "files/lottie_circle_loader.json",
150
+ tintColor = color,
171
151
  modifier = Modifier.size(iconSize),
172
152
  )
173
153
  }
@@ -0,0 +1,39 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.runtime.getValue
5
+ import androidx.compose.ui.Modifier
6
+ import androidx.compose.ui.graphics.Color
7
+ import androidx.compose.ui.graphics.ColorFilter
8
+ import io.github.alexzhirkevich.compottie.Compottie
9
+ import io.github.alexzhirkevich.compottie.LottieCompositionSpec
10
+ import io.github.alexzhirkevich.compottie.animateLottieCompositionAsState
11
+ import io.github.alexzhirkevich.compottie.rememberLottieComposition
12
+ import io.github.alexzhirkevich.compottie.rememberLottiePainter
13
+ import vn.momo.uikits.resources.Res
14
+
15
+ @Composable
16
+ fun LottieView(
17
+ path: String,
18
+ tintColor: Color? = null,
19
+ modifier: Modifier = Modifier) {
20
+ val composition by rememberLottieComposition {
21
+ LottieCompositionSpec.JsonString(
22
+ Res.readBytes(path).decodeToString()
23
+ )
24
+ }
25
+
26
+ val progress by animateLottieCompositionAsState(
27
+ composition = composition,
28
+ iterations = Compottie.IterateForever
29
+ )
30
+
31
+ Image(
32
+ source = rememberLottiePainter(
33
+ composition = composition,
34
+ progress = { progress }
35
+ ),
36
+ colorFilter = tintColor?.let { ColorFilter.tint(it) },
37
+ modifier = modifier,
38
+ )
39
+ }
@@ -44,7 +44,7 @@ public struct Button: View {
44
44
  SwiftUI.Button(action: action) {
45
45
  HStack {
46
46
  if loading {
47
- LottieView(name: "lottie_circle_loader", loopMode: .loop)
47
+ LottieView2(name: "lottie_circle_loader", loopMode: .loop)
48
48
  .frame(width: iconSize, height: iconSize)
49
49
  .colorMultiply(.white)
50
50
  } else if let iconLeft = iconLeft {
@@ -9,7 +9,7 @@
9
9
  import SwiftUI
10
10
  import Lottie
11
11
 
12
- struct LottieView: UIViewRepresentable {
12
+ struct LottieView2: UIViewRepresentable {
13
13
  var name: String = ""
14
14
  var url: String?
15
15
  var loopMode: LottieLoopMode = .playOnce
@@ -19,7 +19,7 @@ struct LottieView: UIViewRepresentable {
19
19
  // Add static cache for animations
20
20
  private static var animationCache = NSCache<NSString, LottieAnimation>()
21
21
 
22
- func makeUIView(context: UIViewRepresentableContext<LottieView>) -> UIView {
22
+ func makeUIView(context: UIViewRepresentableContext<LottieView2>) -> UIView {
23
23
  let view = UIView(frame: .zero)
24
24
 
25
25
  // Configure Lottie with optimized settings
@@ -82,5 +82,5 @@ struct LottieView: UIViewRepresentable {
82
82
  }
83
83
  }
84
84
 
85
- func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieView>) {}
85
+ func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieView2>) {}
86
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.151.2-test.10",
3
+ "version": "0.151.2-test.11",
4
4
  "private": false,
5
5
  "dependencies": {
6
6
  "@momo-platform/native-max-api": "1.0.18"