Last active
July 14, 2021 20:15
-
-
Save mitchtabian/b9f4315ea57407c8f5a9086af9e7f914 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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