Screen.kt
- 1@Composable
- 2fun LessonTitle(title: String, onBack: () -> Unit) {
- 3 Row {
- 4 TextButton(onClick = onBack) { Text("Back") }
- 5 Text(text = title)
- 6 }
- 7}
Screen.kt
A screen is a function of state
Jetpack Compose describes a screen as composable functions. The same state should paint the same tree. Side effects live in remember, LaunchedEffect, or a ViewModel, not in the middle of Text().
Older view code still matters. An educational desk founded in 2018 met XML layouts before Compose was the default path. The idea is the same: the view binds to state, and clicks become events.
Configuration changes rebuild the composition. State that must survive rotation is held above the composable, in a ViewModel scoped to the screen.