Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created basic Lottie animation on compose screen.
- Loading branch information
canerkaseler
committed
Jun 24, 2023
1 parent
9f262e9
commit 0f4b4d9
Showing
2 changed files
with
46 additions
and
20 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
app/src/main/java/com/canerkaseler/composelottie/ComposeLottieScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.canerkaseler.composelottie | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.airbnb.lottie.compose.LottieAnimation | ||
import com.airbnb.lottie.compose.LottieCompositionSpec | ||
import com.airbnb.lottie.compose.LottieConstants | ||
import com.airbnb.lottie.compose.rememberLottieComposition | ||
|
||
@Composable | ||
fun ComposeLottieScreen() { | ||
Box(modifier = Modifier | ||
.fillMaxSize() | ||
.background(color = Color.White) | ||
){ | ||
ComposeLottieAnimation(modifier = Modifier.align(alignment = Alignment.Center)) | ||
} | ||
} | ||
|
||
@Composable | ||
fun ComposeLottieAnimation(modifier: Modifier) { | ||
|
||
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.anim_loading_success_failed)) | ||
|
||
LottieAnimation( | ||
modifier = modifier, | ||
composition = composition, | ||
iterations = LottieConstants.IterateForever, | ||
) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun MainScreenPreview() { | ||
ComposeLottieScreen() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters