Created
October 25, 2022 20:15
-
-
Save mcatta/c35bab2e846d57f4e1539820cc9994db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun RepoInfoScreen( | |
githubViewModel: GithubViewModel | |
) { | |
val uiState by githubViewModel.rememberState() | |
Column( | |
modifier = Modifier | |
.fillMaxSize() | |
.padding(16.dp) | |
) { | |
when (uiState) { | |
is GithubState.ContentState -> { | |
Column { | |
val contentState = (uiState as GithubState.ContentState) | |
Row( | |
modifier = Modifier | |
.fillMaxWidth() | |
.padding(bottom = 16.dp), | |
verticalAlignment = Alignment.CenterVertically, | |
) { | |
TextField(placeholder = { | |
Text(text = "Owner") | |
}, value = contentState.owner, onValueChange = { | |
githubViewModel.dispatch(GithubAction.TypeOwner(it)) | |
}) | |
Button( | |
modifier = Modifier.padding(start = 16.dp), | |
onClick = { githubViewModel.dispatch(GithubAction.Confirm) }, | |
content = { Text(text = "OK") } | |
) | |
} | |
LazyColumn { | |
items(contentState.repositories) | |
} | |
} | |
} | |
is GithubState.Error -> Column { | |
Text(text = "FAIL") | |
Button(onClick = { githubViewModel.dispatch(GithubAction.RetryLoadingAction) }) { | |
Text(text = "Retry") | |
} | |
} | |
is GithubState.Load -> { | |
Text(text = "Loading stuff") | |
} | |
null -> Unit | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment