I am implementing navigation in a Compose App using the guides:
So, instead of using string routes, I use objects as suggested. However, I am bit confused how to add navigation screens with route arguments. I know it's more a Kotlin question than Android / Compose.
I have written this:
@Serializable
sealed class NavigationScreen (
@StringRes val nameResourceId: Int,
@DrawableRes val iconResourceId: Int
) {
@Serializable
data object SignIn: NavigationScreen( R.string.sign_in, R.drawable.baseline_person_24)
@Serializable
data object Home: NavigationScreen( R.string.home, R.drawable.baseline_home_24)
@Serializable
data object Settings: NavigationScreen(R.string.settings, R.drawable.baseline_settings_24)
}
The above sealed class works well but doesn't hold route arguments. Is there a clean way to add them?