StaticScreen
A marker interface that indicates that this Screen only ever has static content and does not require a presenter to compute or manage its state. This is useful for UIs that either have no state or can derive their state solely from static inputs or the Screen key itself.
Stateless UI
data object ProfileScreen : StaticScreen
@Composable
fun Profile(modifier: Modifier = Modifier) {
Text("Jane", modifier = modifier)
}
val circuit = Circuit.Builder()
.addUi<ProfileScreen> { _, modifier -> Profile(modifier) }
.build()
Content copied to clipboard
Static UI
data object ProfileScreen : StaticScreen
@Composable
fun Profile(name: String, modifier: Modifier = Modifier) {
Text(name, modifier = modifier)
}
val circuit = Circuit.Builder()
.addUi<ProfileScreen> { _, modifier ->
// The UI's input is handled in the factory in this case
Profile("Jane", modifier)
}
.build()
Content copied to clipboard
Static UI w/ Screen data
data class ProfileScreen(val name: String) : StaticScreen
@Composable
fun Profile(name: String, modifier: Modifier = Modifier) {
Text(name, modifier = modifier)
}
val circuit = Circuit.Builder()
.addUi<ProfileScreen> { screen, modifier ->
Profile(screen.name, modifier)
}
.build()
Content copied to clipboard
Static UI w/ Screen input + code gen
data class ProfileScreen(val name: String) : StaticScreen
@CircuitInject(ProfileScreen::class, AppScope::class)
@Composable
fun Profile(screen: ProfileScreen, modifier: Modifier = Modifier) {
Text(screen.name, modifier = modifier)
}
Content copied to clipboard