This is a demo project to showcase using Ballast navigation in a typesafe way using KSP. The app is a basic Kotlin Multiplatform app using a template generated from KMM-Template for Android and iOS. It includes shared business logic and data handling, and a shared UI implementation using Compose Multiplatform.
Declare screens using a sealed interface/class
@Routes
sealed interface Screen{
@InitialRoute
data object ListScreen: Screen
data class DetailScreen(val objectId: Int): Screen
data class Settings(val count: Double): Screen
}Build and have:
val coroutineScope = rememberCoroutineScope()
val controller = rememberController(coroutineScope)
Destination(
controller,
onNavigate = {
when(it){
is Screen.DetailScreen -> DetailScreen(it.objectId)
is Screen.ListScreen -> ListScreen()
is Screen.Settings -> TODO()
}
}
)The data displayed by the app is from The Metropolitan Museum of Art Collection API.
The app uses the following multiplatform dependencies in its implementation:
- Compose Multiplatform for UI
- Ktor for networking
- kotlinx.serialization for JSON handling
- Kamel for image loading
- Koin for dependency injection
- Ballast Nav Ext for navigation based on Ballast
This is experimental and not ready for production