ActivityScreen
Base class for a NavEase screen.
K is the specific key this screen handles, so Content receives it already typed — no casting and no argument-extraction helpers.
sealed class AppScreens : NavEaseRoot {
data object Home : AppScreens()
data class Detail(val id: String) : AppScreens()
}
@AutoRegister
class DetailScreen : ActivityScreen<AppScreens.Detail>() {
@Composable
override fun Content(navKey: AppScreens.Detail, navEaseController: NavEaseController) {
Text(navKey.id) // typed
}
}Content copied to clipboard
Subclasses must extend ActivityScreen<K> directly and expose a no-argument constructor: KSP reads K from the direct supertype and generates ScreenClass(). Put shared behaviour in a composable you call from Content, not in an intermediate base class.
A fresh instance is created per host, so a screen may hold composition-scoped state without leaking it into another host.
Type Parameters
K
The key type this screen handles, e.g. AppScreens.Detail.