android5-1 Exercise 3: Three Previews ================================== Imports: import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.layout.Column import androidx.compose.material3.Button import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.tooling.preview.Preview @Composable fun NotesScreen(state: NotesUiState, onRetry: () -> Unit) { when (state) { NotesUiState.Loading -> Text("Loading...") is NotesUiState.Success -> LazyColumn { items(state.notes) { note -> Text(note) } } is NotesUiState.Error -> Column { Text(state.message) Button(onClick = onRetry) { Text("Try again") } } } } @Preview(showBackground = true) @Composable fun NotesScreenSuccessPreview() { ComposeHelloTheme { NotesScreen(state = NotesUiState.Success(listOf("Buy milk", "Call Ada")), onRetry = { }) } } @Preview(showBackground = true) @Composable fun NotesScreenErrorPreview() { ComposeHelloTheme { NotesScreen(state = NotesUiState.Error("No connection"), onRetry = { }) } } Add a third preview: @Preview(showBackground = true) @Composable fun NotesScreenLoadingPreview() { ComposeHelloTheme { NotesScreen(state = NotesUiState.Loading, onRetry = { }) } } Expected: three previews in the pane without running the app, each showing its own state. Code unrun; the sealed interface from the chapter is also needed.