Skip to content

#336 replace Lottie#341

Merged
Kaaveh merged 2 commits into
kmpfrom
336-kmp-Replace-Lottie
May 7, 2026
Merged

#336 replace Lottie#341
Kaaveh merged 2 commits into
kmpfrom
336-kmp-Replace-Lottie

Conversation

@Kaaveh
Copy link
Copy Markdown
Owner

@Kaaveh Kaaveh commented May 7, 2026

Fix #336

@Kaaveh Kaaveh self-assigned this May 7, 2026
@Kaaveh Kaaveh added the kmp label May 7, 2026
@Kaaveh
Copy link
Copy Markdown
Owner Author

Kaaveh commented May 7, 2026

@claude

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Messages
📖 Thanks @Kaaveh!
📖 🎉 Code Cleanup!

Generated by 🚫 Danger Kotlin against 5339f2a

@Kaaveh Kaaveh merged commit bdc30b5 into kmp May 7, 2026
3 checks passed
@Kaaveh Kaaveh deleted the 336-kmp-Replace-Lottie branch May 7, 2026 04:52
@claude
Copy link
Copy Markdown

claude Bot commented May 7, 2026

Claude finished @Kaaveh's task in 1m 29s —— View job


Code Review: #336 Replace Lottie with Compottie

  • Read changed files and examine the diff
  • Analyze dependency changes
  • Review animation implementation
  • Provide comprehensive feedback

Summary

This PR replaces com.airbnb.android:lottie-compose with io.github.alexzhirkevich:compottie (v2.1.0) — a KMP-compatible port of Lottie for Compose Multiplatform. The migration aligns well with the project's KMP roadmap and the overall diff is a net reduction (-8 lines). Good direction overall.


Observations

EmptyStateAnimation.kt — blocking I/O inside composition

val composition by rememberLottieComposition {
    val json = context.resources.openRawResource(R.raw.empty_state_animation)
        .use { it.bufferedReader().readText() }
    LottieCompositionSpec.JsonString(json)
}

openRawResource(...).readText() is synchronous I/O. Whether this is safe depends on whether compottie dispatches the lambda on a background thread internally. If the library's rememberLottieComposition executes the block on the main thread before suspending, this will cause a brief frame drop on first composition. Worth verifying in the compottie source or docs. Fix this →


EmptyStateAnimation.kt — mismatched size + scale

modifier = Modifier
    .size(250.dp, 250.dp)
    .scale(0.5f, 0.5f)

.scale() only affects visual rendering, not layout bounds. The composable still reserves a 250×250dp slot while appearing at 125×125dp. This is likely a carry-over from before the migration. Using .size(125.dp, 125.dp) directly (or keeping 250dp without the scale) would be cleaner and avoid phantom reserved space. Fix this →


LottieAnimationComposable.kt — unnecessary suppression

@file:Suppress("LongParameterList", "ktlint")

5 parameters doesn't typically warrant LongParameterList suppression (default threshold is usually 6+). And ktlint is suppressed file-wide, which hides any real formatting issues rather than addressing them. Fix this →


build.gradle.ktsapi vs implementation

api(libs.compottie)

Exposing compottie as api is correct here since LottieComposition appears in the public signature of LottieAnimationComposable. This is intentional and fine.


EmptyStateAnimation.kt — hardcoded string

text = "Your favorite list is empty",

Pre-existing issue, but worth a mention: this string is not in strings.xml, making it un-translatable. Fix this →


Verdict

The migration is clean and the right call for the KMP roadmap. The most actionable item is clarifying the I/O threading behavior in rememberLottieComposition; the size+scale issue is a cosmetic clean-up worth addressing in a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Replace Lottie Android with KMP alternative

1 participant