Merge remote-tracking branch 'origin/master' into gpeal/compose-dynamic-gradients
diff --git a/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieDynamicProperties.kt b/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieDynamicProperties.kt
index c6333a1..3bec245 100644
--- a/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieDynamicProperties.kt
+++ b/lottie-compose/src/main/java/com/airbnb/lottie/compose/LottieDynamicProperties.kt
@@ -96,7 +96,8 @@
private val floatProperties: List<LottieDynamicProperty<Float>>,
private val scaleProperties: List<LottieDynamicProperty<ScaleXY>>,
private val colorFilterProperties: List<LottieDynamicProperty<ColorFilter>>,
- private val intArrayProperties: List<LottieDynamicProperty<IntArray>>,
+ // Java doesn't have reified types. All LottieProperty arrays are Integer[].
+ private val intArrayProperties: List<LottieDynamicProperty<Array<*>>>,
private val typefaceProperties: List<LottieDynamicProperty<Typeface>>,
private val bitmapProperties: List<LottieDynamicProperty<Bitmap>>,
) {
@@ -107,7 +108,7 @@
properties.filter { it.property is Float } as List<LottieDynamicProperty<Float>>,
properties.filter { it.property is ScaleXY } as List<LottieDynamicProperty<ScaleXY>>,
properties.filter { it.property is ColorFilter } as List<LottieDynamicProperty<ColorFilter>>,
- properties.filter { it.property is IntArray } as List<LottieDynamicProperty<IntArray>>,
+ properties.filter { it.property is Array<*> } as List<LottieDynamicProperty<Array<*>>>,
properties.filter { it.property is Typeface } as List<LottieDynamicProperty<Typeface>>,
properties.filter { it.property is Bitmap } as List<LottieDynamicProperty<Bitmap>>,
)
@@ -157,7 +158,7 @@
drawable.addValueCallback(p.keyPath, p.property, null as LottieValueCallback<ColorFilter>?)
}
intArrayProperties.forEach { p ->
- drawable.addValueCallback(p.keyPath, p.property, null as LottieValueCallback<IntArray>?)
+ drawable.addValueCallback(p.keyPath, p.property, null as LottieValueCallback<Array<*>>?)
}
typefaceProperties.forEach { p ->
drawable.addValueCallback(p.keyPath, p.property, null as LottieValueCallback<Typeface>?)
diff --git a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/ComposeDynamicPropertiesTestCase.kt b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/ComposeDynamicPropertiesTestCase.kt
new file mode 100644
index 0000000..6356baf
--- /dev/null
+++ b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/ComposeDynamicPropertiesTestCase.kt
@@ -0,0 +1,38 @@
+package com.airbnb.lottie.snapshots.tests
+
+import android.graphics.Color
+import androidx.compose.ui.platform.ComposeView
+import com.airbnb.lottie.LottieCompositionFactory
+import com.airbnb.lottie.LottieProperty
+import com.airbnb.lottie.compose.LottieAnimation
+import com.airbnb.lottie.compose.rememberLottieDynamicProperties
+import com.airbnb.lottie.compose.rememberLottieDynamicProperty
+import com.airbnb.lottie.snapshots.SnapshotTestCase
+import com.airbnb.lottie.snapshots.SnapshotTestCaseContext
+import com.airbnb.lottie.snapshots.snapshotComposable
+import com.airbnb.lottie.snapshots.snapshotComposition
+
+class ComposeDynamicPropertiesTestCase : SnapshotTestCase {
+ override suspend fun SnapshotTestCaseContext.run() {
+ val composition = LottieCompositionFactory.fromAssetSync(context, "Tests/DynamicGradient.json").value!!
+ snapshotComposable("Compose Dynamic Gradient") {
+ val dynamicProperties = rememberLottieDynamicProperties(
+ rememberLottieDynamicProperty(
+ LottieProperty.GRADIENT_COLOR,
+ arrayOf(Color.YELLOW, Color.GREEN),
+ "Linear",
+ "Rectangle",
+ "Gradient Fill"
+ ),
+ rememberLottieDynamicProperty(
+ LottieProperty.GRADIENT_COLOR,
+ arrayOf(Color.YELLOW, Color.GREEN),
+ "Radial",
+ "Rectangle",
+ "Gradient Fill"
+ )
+ )
+ LottieAnimation(composition, 0f, dynamicProperties = dynamicProperties)
+ }
+ }
+}
\ No newline at end of file