Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jvm desktop not draw #5

Closed
toffeantyri opened this issue Jun 5, 2024 · 3 comments
Closed

Jvm desktop not draw #5

toffeantyri opened this issue Jun 5, 2024 · 3 comments

Comments

@toffeantyri
Copy link

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
Copy link
Owner

alexzhirkevich commented Jun 5, 2024

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

@toffeantyri
Copy link
Author

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants