Compose Multiplatform: A ready-made Template for your next App
Setting up a Compose Multiplatform project can be time-consuming and sometimes a non-trivial task, especially when ensuring all components work seamlessly across iOS and Android. Compose Multiplatform simplifies this process by sharing not only the business and data logic but also the views, enabling developers to write consistent, reusable UI code. To make this even easier, I’ve created a Compose Multiplatform Template, now available on GitHub: DGuerrero/compose-multiplatform-template.
This template is designed to get you up and running quickly with a solid foundation for building cross-platform apps. It includes the dependencies to most common libraries and is implemented with a basic clean architecture structure, using shared view models and database.
Project Highlights
The Compose Multiplatform Template has following features:
1. Bottom Bar Navigation
The app includes a bottom bar navigation pattern with three screens. Screen1 displays a list with example “lorem ipsum” data and images fetched via a REST API. Screen2 and Screen3 are empty and ready for you to add any content.
The navigation between screens is performed via Compose Navigation and again shared between both platforms.
2. Clean Architecture
- Views: Built with Jetpack Compose, ensuring a modern declarative UI for both platforms.
- View Model: Shared between both platforms and implemented with Android Jetpack.
- Repository: Combines a REST API and local repository for data management.
- Local Cache: Powered by SqlDelight, enabling a robust and platform-agnostic local database solution.
Key Libraries
- Koin: Manages dependency injection to keep the codebase modular and testable.
- Ktor: Handles remote network requests.
- SqlDelight: Provides a multi-platform database for local caching, with type-safe queries and shared schemas.
- Coil: Loads and caches images efficiently, ensuring smooth and performant image rendering across platforms.
Future Roadmap
This template is a work in progress, here’s what’s next on my agenda:
- Unit and UI Tests: No surprises here, UI test using Espresso and JUnit for Unit Testing,
- Platform-Specific Features: Add examples of handling iOS and Android-specific features within the shared codebase.
- iOS look & feel: Experiment with Compose Cupertino (or similar) to get a more Apple platform specific UI.
How to Get Started
- Clone the repository from GitHub: compose-multiplatform-template.
- Open the project in Android Studio, select the compose App configuration and run the Android app.
- When the Android finishes, select the iOSApp configuration and run as well.
- Modify the project naming for your specific project and start adding features!
Summary
This Compose Multiplatform Template is designed to save you time and streamline your development workflow, making it an ideal starting point for your next project. Whether you’re working on a prototype or a production app, this template has you covered.
Check out the GitHub repository, and I’d love to hear your thoughts and contributions!
If you find this project helpful, don’t forget to star the repo and share it with your network. 🚀