← All courses

Theming & Architecture

🗓 May 31, 2026 ⏱ 1 min read

Theming

@Composable
fun AppTheme(content: @Composable () -> Unit) {
    val colors = lightColorScheme(
        primary = Color(0xFF7C3AED),
        secondary = Color(0xFFA855F7)
    )
    MaterialTheme(colorScheme = colors, content = content)
}

Now use MaterialTheme.colorScheme.primary and MaterialTheme.typography everywhere for consistent styling.

Connecting a ViewModel

@Composable
fun UserScreen(vm: UserViewModel = viewModel()) {
    val state by vm.state.collectAsStateWithLifecycle()
    when (state) {
        is UiState.Loading -> CircularProgressIndicator()
        is UiState.Success -> UserList((state as UiState.Success).users)
        is UiState.Error   -> Text("Something went wrong")
    }
}
Architecture: Compose (UI) observes a ViewModel that exposes a single state object — the same MVVM pattern used across modern Android.