Last active
September 30, 2023 10:50
-
-
Save lopspower/b84f95ae6e61f87718d324510332409d to your computer and use it in GitHub Desktop.
ViewModel Kotlin Android Studio Template
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
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end | |
import com.mstv.presentation.scenes.base.view.ContentState | |
import com.mstv.presentation.scenes.base.view.LoadingState | |
data class ${NAME}(val loadingState: LoadingState = LoadingState.NONE, | |
val contentState: ContentState = ContentState.NONE, | |
val data: ${DataType}? = null, | |
val errorMessage: String? = null, | |
val snackMessage: String? = null) { | |
companion object { | |
fun createLoading() = ${NAME}(loadingState = LoadingState.LOADING, contentState = ContentState.CONTENT) | |
fun createRetryLoading() = ${NAME}(loadingState = LoadingState.RETRY, contentState = ContentState.ERROR) | |
fun createData(data: ${DataType}) = ${NAME}(contentState = ContentState.CONTENT, data = data) | |
fun createError(error: String) = ${NAME}(contentState = ContentState.ERROR, errorMessage = error) | |
fun createSnack(snackMessage: String) = ${NAME}(contentState = ContentState.CONTENT, snackMessage = snackMessage) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment