Skip to content

Instantly share code, notes, and snippets.

@mitchtabian
Last active July 14, 2021 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchtabian/b9f4315ea57407c8f5a9086af9e7f914 to your computer and use it in GitHub Desktop.
Save mitchtabian/b9f4315ea57407c8f5a9086af9e7f914 to your computer and use it in GitHub Desktop.
sealed class ProgressBarState{
object Loading: ProgressBarState()
object None: ProgressBarState()
}
sealed class DataState<T> {
data class Response<T>(
val uiComponent: UIComponent
): DataState<T>()
data class Data<T>(
val data: T? = null
): DataState<T>()
data class Loading<T>(
val state: ProgressBarState = ProgressBarState.None
): DataState<T>()
}
sealed class UIComponent{
data class Dialog(
val title: String,
val description: String,
val positiveAction: PositiveAction? = null, // <-- But how is this useful inside a use-case?
val negativeAction: NegativeAction? = null, // same
): UIComponent()
data class Toast(
val text: String,
val duration: Int = LENGTH_LONG
)
data class Snackbar(
val text: String,
val duration: Int = com.google.android.material.snackbar.Snackbar.LENGTH_LONG
)
data class None(
val message: String,
)
}
data class PositiveAction(
val buttonText: String,
val onClick: () -> Unit,
)
data class NegativeAction(
val buttonText: String,
val onClick: () -> Unit,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment