alexzhirkevich / compottie

Compose Multiplatform Adobe After Effects Bodymovin (Lottie) animations rendering engine
https://alexzhirkevich.github.io/compottie
MIT License
202 stars 5 forks source link

Jvm desktop not draw #5

Closed toffeantyri closed 3 months ago

toffeantyri commented 3 months ago

Android: lottie animation drawing is success.

Jvm : not work. Empty screen( no animation, no image


Composable
actual fun LoadingCardGeneralView(
    modifier: Modifier,
    bottomElement: @Composable (() -> Unit)?
) {
    val animationBites = remember {
        mutableStateOf(ByteArray(0))
    }

    LaunchedEffect(Unit) {
        withContext(Dispatchers.IO) {
            animationBites.value = Res.readBytes("files/loading.json")
        }
    }

    val jsonString = remember(animationBites.value) {
        mutableStateOf(animationBites.value.decodeToString())
    }

    val composition by rememberLottieComposition(
        LottieCompositionSpec.JsonString(jsonString.value)
    )

    val progress = animateLottieCompositionAsState(
        composition = composition,
        iterations = LottieConstants.IterateForever
    )

    val painter = rememberLottiePainter(composition, progress.value)

    Column(modifier = modifier) {
        Box(
            modifier = Modifier
                .fillMaxWidth()
                .ignoreHorizontalParentPadding(44.dp)
                .offset(y = (-63).dp)
                .wrapContentHeight(),
            contentAlignment = Alignment.TopCenter
        ) {
            Image(painter, contentDescription = null)
            //LottieAnimation(composition, progress = { progress.value })
        }
        if (bottomElement != null) {
            Column(modifier = Modifier.fillMaxWidth().offset(y = (-118).dp)) {
                bottomElement()
            }
        }
    }

}
alexzhirkevich commented 3 months ago

Not all the lottie features have multiplatform support. Are there embedded images in the animation? Can you provide your animation?

toffeantyri commented 3 months ago

Not all the lottie features have multiplatform support. Are there embedded images in the animation? Can you provide your animation?

yes, json has embedded images: data:image/png;base64

alexzhirkevich commented 3 months ago

Then it is duplicate of #1. It will be fixed soon with a new renderer. If you want you can clone standalone branch and test your animation in the sample app