$ show ismai117/kottie
Kottie is a Compose Multiplatform library for rendering Lottie animations across Android, iOS, JVM, JS, and WebAssembly targets. It provides a unified API to load animations from URLs, files, or JSON strings and control playback via Compose's state management system. The library uses Kotlin Multiplatform's expect/actual pattern to abstract platform-specific Lottie implementations (Airbnb Lottie for native mobile, Skottie for web/Wasm) while offering idiomatic Compose interfaces. Sample applications demonstrate cross-platform usage, showcasing loading animations from local resources, remote URLs, and inline JSON with proper state handling for loading, success, and error conditions. The architecture separates concerns effectively: commonMain defines the API contracts (KottieCompositionSpec, RememberKottieComposition, AnimateKottieCompositionAsState, KottieAnimation), while platform-specific source sets implement the actuals using native Lottie runtimes. Key patterns include expect/actual for asynchronous resource loading with state management (RememberKottieComposition) and animation state hoisting (AnimateKottieCompositionAsState), both demonstrating reusable, non-boilerplate solutions for cross-platform resource-intensive components. The library integrates smoothly with Compose's lifecycle via LaunchedEffect and remember, ensuring proper disposal of animations. Maintenance is active with recent commits (2026-03-09) and CI/CD pipelines for building and code style checks. Technical drift is low due to modern Gradle version catalogs, up-to-date dependencies (e.g., Lottie-compose 6.7.1), and adherence to current Compose Multiplatform practices. The codebase avoids framework lock-in by isolating platform differences behind well-defined expect/actual interfaces, making the core patterns highly reusable for similar cross-platform resource loading scenarios.
The LLM identified 2 files worth highlighting for reuse:
Defines a cross-platform, state-aware resource loading function for Lottie compositions using Kotlin Multiplatform's expect/actual mechanism. Handles asynchronous loading, error states, and resource disposal, providing a reusable pattern for any async resource in Compose Multiplatform with minimal coupling (depends only on KottieCompositionSpec and KottieComposition).
Hoists animation state (playback status, current frame) as a Compose State via expect/actual, enabling UI control and observation of Lottie animations. Demonstrates a reusable pattern for cross-platform timed effects in Compose, separating animation logic from UI rendering while depending only on core Compose runtime and KottieAnimationState.