Created
October 6, 2021 23:00
-
-
Save raamcosta/bf7deca3f08a6fe201c21e0055ccc018 to your computer and use it in GitHub Desktop.
UiText.kt
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 UiText { | |
class DynamicText(val text: String) : UiText() | |
class ResourceText(@StringRes val stringRes: Int) : UiText() | |
} | |
fun UiText.getString(context: Context) = when (this) { | |
is UiText.DynamicText -> text | |
is UiText.ResourceText -> context.getString(stringRes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment