Last active
May 31, 2019 17:24
-
-
Save lucanicoletti/40d48025319ec817bae5eb5a209427a8 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
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