Skip to content

Instantly share code, notes, and snippets.

@alibahaaa
Created June 25, 2022 20:17
Show Gist options
  • Save alibahaaa/77d93fe51638ccb04a00c605c2b22818 to your computer and use it in GitHub Desktop.
Save alibahaaa/77d93fe51638ccb04a00c605c2b22818 to your computer and use it in GitHub Desktop.
@Composable
fun HomeScreen(
navController: NavController,
viewModel: MainViewModel = viewModel()
) {
val uiState = viewModel
.uiState
.collectAsState()
.value
when (uiState) {
State.Error -> ErrorBody()
State.Idle -> viewModel.sendIntent(Intent.FetchOrigamiData)
State.Loading -> LoadingBody()
is State.Origami -> HomeScreenBody(
navController = navController,
data = uiState.origami
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment