Skip to content

Commit

Permalink
Update Compose API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Peal committed May 30, 2022
1 parent 3a429d8 commit d048379
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 19 deletions.
15 changes: 15 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# 5.2.0
### Bugs Fixed
* De-dupe gradient stops. On pre-Oreo devices, if you had color and opacity stops in the same place and used hardware acceleration, you may have seen artifacts at the stop positions as of 5.1.1 [#20814](https://github.com/airbnb/lottie-android/pull/2081)

# 5.1.1
### New Features
* Added support for gradient opacity stops at different points than color stops ([#2062](https://github.com/airbnb/lottie-android/pull/2062))
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG_COMPOSE.md
@@ -1,3 +1,6 @@
# 5.2.0
* [BREAKING CHANGE] LottieAnimation now takes progress as a `() -> Float` rather than a `Float`. This allows Lottie to redraw without triggering a recomposition every time progress updates. For more information, refer to the Compose [phase docs](https://developer.android.com/jetpack/compose/phases). The existing API will exist as deprecated for one more release but will then be removed. [#2078](https://github.com/airbnb/lottie-android/pull/2078).

# 5.1.1
* Add support for completable animations in tests ([#2051](https://github.com/airbnb/lottie-android/pull/2051))

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Expand Up @@ -2,13 +2,13 @@ import org.ajoberstar.grgit.Grgit

buildscript {
ext {
coroutinesVersion = '1.5.2'
coroutinesVersion = '1.6.2'
coreVersion = '1.6.0'
appcompatVersion = '1.3.1'
activityVersion = '1.3.1'
lifecycleVersion = '2.3.1'
composeVersion = '1.0.3'
kotlinVersion = '1.5.30'
composeVersion = '1.1.1'
kotlinVersion = '1.6.10'
daggerVersion = '2.38.1'
awsVersion = '2.8.3'
mockitoVersion = '3.12.4'
Expand Down
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition

Expand All @@ -21,7 +22,7 @@ class ComposeIssueReproActivity : AppCompatActivity() {
@Composable
fun Content() {
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.heart))
val progress by animateLottieCompositionAsState(composition)
val progress by animateLottieCompositionAsState(composition, iterations = LottieConstants.IterateForever)
LottieAnimation(composition, { progress })
}
}
Expand Up @@ -32,7 +32,7 @@ import kotlin.math.roundToInt
*
* @param composition The composition that will be rendered. To generate a [LottieComposition], you can use
* [rememberLottieComposition].
* @param progressProvider A provider for the progress (between 0 and 1) that should be rendered. If you want to render a
* @param progress A provider for the progress (between 0 and 1) that should be rendered. If you want to render a
* specific frame, you can use [LottieComposition.getFrameForProgress]. In most cases, you will want
* to use one of the overloaded LottieAnimation composables that drives the animation for you.
* The overloads that have isPlaying as a parameter instead of progress will drive the
Expand Down Expand Up @@ -69,7 +69,7 @@ import kotlin.math.roundToInt
@Composable
fun LottieAnimation(
composition: LottieComposition?,
progressProvider: () -> Float,
progress: () -> Float,
modifier: Modifier = Modifier,
outlineMasksAndMattes: Boolean = false,
applyOpacityToLayers: Boolean = false,
Expand Down Expand Up @@ -114,7 +114,7 @@ fun LottieAnimation(
drawable.isApplyingOpacityToLayersEnabled = applyOpacityToLayers
drawable.maintainOriginalImageBounds = maintainOriginalImageBounds
drawable.clipToCompositionBounds = clipToCompositionBounds
drawable.progress = progressProvider()
drawable.progress = progress()
drawable.setBounds(0, 0, composition.bounds.width(), composition.bounds.height())
drawable.draw(canvas.nativeCanvas, matrix)
}
Expand All @@ -127,6 +127,7 @@ fun LottieAnimation(
* @see LottieAnimation
*/
@Composable
@Deprecated("Pass progress as a lambda instead of a float. This overload will be removed in the next release.")
fun LottieAnimation(
composition: LottieComposition?,
@FloatRange(from = 0.0, to = 1.0) progress: Float,
Expand Down Expand Up @@ -192,18 +193,18 @@ fun LottieAnimation(
iterations,
)
LottieAnimation(
composition,
{ progress },
modifier,
outlineMasksAndMattes,
applyOpacityToLayers,
enableMergePaths,
renderMode,
maintainOriginalImageBounds,
dynamicProperties,
alignment,
contentScale,
clipToCompositionBounds,
composition = composition,
progress = { progress },
modifier = modifier,
outlineMasksAndMattes = outlineMasksAndMattes,
applyOpacityToLayers = applyOpacityToLayers,
enableMergePaths = enableMergePaths,
renderMode = renderMode,
maintainOriginalImageBounds = maintainOriginalImageBounds,
dynamicProperties = dynamicProperties,
alignment = alignment,
contentScale = contentScale,
clipToCompositionBounds = clipToCompositionBounds,
)
}

Expand Down

0 comments on commit d048379

Please sign in to comment.