commit | b27f6d32cc10580c95019df82a9b606b1c5e49f0 | [log] [tgz] |
---|---|---|
author | Gabriel Peal <gpeal@users.noreply.github.com> | Sat Oct 24 13:41:19 2020 -0700 |
committer | GitHub <noreply@github.com> | Sat Oct 24 13:41:19 2020 -0700 |
tree | 54a4272aaae1835b4879f5aa4800ca8e0051b65e | |
parent | 81b4e7873bd00312775a34c0ab9a2a3d2a641ae8 [diff] |
Initial implementation of Lottie Compose (#1652) This PR kicks off the work required to use Lottie with [Jetpack Compose](https://developer.android.com/jetpack/compose). The API here will almost certainly change over time but I feel confident that this is a solid starting point with which to begin further API discussions. The three primitives are: * LottieAnimation: the `@Composable` that does the rendering aka replacement for LottieDrawable or LottieAnimationView. * LottieAnimationSpec: a specification for where an animation should come from, whether it be from resources or the internet. * LottieAnimationState: the current animation state (playing, progress, repeatCount, etc) and the ability to control the animation(start(), stop(), etc). Its most basic usage is: ``` @Composable fun MyComposable() { val animationSpec = remember { LottieAnimationSpec.Url("https://...") } LottieAnimation(animationSpec) } ``` Or slightly more advanced: ``` @Composable fun MyComposable(loaded: Boolean) { val animationSpec = remember { LottieAnimationSpec.Url(animationData.file) } val animationState = rememberLottieAnimationState() onCommit(loaded) { if (loaded) animationState.play() } LottieAnimation(animationSpec, animationState) } ```
Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!
For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. They say a picture is worth 1,000 words so here are 13,000:
Lottie is maintained and improved on nights and weekends. If you use Lottie in your app, please consider sponsoring it to help ensure that we can continue to improve the project we love. Click the sponsor button above to learn more
Gradle is the only supported build configuration, so just add the dependency to your project build.gradle
file:
dependencies { implementation 'com.airbnb.android:lottie:$lottieVersion' }
The latest Lottie version is:
Lottie 2.8.0 and above only supports projects that have been migrated to androidx. For more information, read Google's migration guide.