CMP-Unit-Converter

Introduction: A Compose Multiplatform unit converter
More: Author   ReportBugs   
Tags:

This repo contains a real-world example of a Compose Multiplatform app. CMP Unit Converter runs on Android, iOS, and the Desktop. As its name suggests, you can convert between various units and scales. While this may provide some value, the main goal of the app and the accompanying series on dev.to is to show how to use Compose Multiplatform and a couple of other multiplatform libraries while focusing on platform integration.

Among others, these libraries are used:

Unlike many other samples, this one has a strong focus on platform integration. For example, on the Desktop, you can access the settings, the About dialog, and all top-level destinations from the menu bar. On Android and iOS, a top app bar is used. The app supports dark and light mode on all platforms. Database and configuration files are stored in the preferred locations.

Noteworthy

This project uses the new recommended Compose Multiplatform project structure: a shared multiplatform library module (:shared) consumed by separate app modules for Android (:composeApp) and desktop (:desktopApp), rather than a single module combining the app and shared code. The Android build uses AGP 9 with the new Android KMP library plugin in :shared and built-in Kotlin support in the app module (no separate Kotlin Android plugin). The iOS app lives in the iosApp/ Xcode project and consumes the same shared framework.

A note about icons

The official Android Compose documentation on Material icons recommends against adding material-icons-extended as a direct dependency (it is very large and can significantly increase build time) and instead suggests copying only the icons you need or using Google Font Icons (e.g. as SVG or Android vector drawable). This app follows that approach: the icons in use are stored as vector drawables in shared/src/commonMain/composeResources/drawable/ and referenced via AppIcons. Those icon assets are from the Material Design Icons project (Apache License 2.0).

What's up next?

  • Regularly updating dependencies
  • Exploring deeper Navigation 3 patterns (more routes, back stack–driven state, and adaptive layouts) as the library evolves

Run and build from the command line

Android (build & install debug):

./gradlew :composeApp:installDebug

Desktop (run the app):

./gradlew :desktopApp:run

iOS (build for a simulator):

xcodebuild -project iosApp/iosApp.xcodeproj -scheme iosApp -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 16e'
Apps
About Me
GitHub: Trinea
Facebook: Dev Tools