Skip to content

Instantly share code, notes, and snippets.

@lucanicoletti
Last active May 31, 2019 17:24
Show Gist options
  • Save lucanicoletti/40d48025319ec817bae5eb5a209427a8 to your computer and use it in GitHub Desktop.
Save lucanicoletti/40d48025319ec817bae5eb5a209427a8 to your computer and use it in GitHub Desktop.
sealed class MVIJetpackComposeViewState {
@Composable
abstract fun buildUI()
object Loading : MyViewState() {
@Composable
override fun buildUI() {
// Loading which is not provided yet
}
}
class Error(private val reason: String, private val retry: () -> Unit) : MyViewState() {
@Composable
override fun buildUI() {
Padding(padding = 16.dp) {
Column {
Text(text = reason, style = +themeTextStyle { body1 })
TransparentButton(text = "Retry", onClick = {
retry()
})
}
}
}
}
class Success(private val body: String) : MyViewState() {
@Composable
override fun buildUI() {
Padding(padding = 16.dp) {
Text(text = body, style = +themeTextStyle { body1 })
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment