English topic guide inspired by the original iOS Developer Notebook, expanded for both iOS and Android teams.
struct ProfileView: View {
@StateObject private var vm = ProfileViewModel()
var body: some View {
Group {
if vm.loading { ProgressView() }
else { Text(vm.user?.name ?? "-") }
}.task { await vm.load() }
}
}
@Composable
fun ProfileScreen(vm: ProfileVm = viewModel()) {
val state by vm.state.collectAsState()
when {
state.loading -> CircularProgressIndicator()
else -> Text(state.user?.name ?: "-")
}
}