EquinoxProfileViewModel

open class EquinoxProfileViewModel(    val snackbarHostState: SnackbarHostState,     val requester: EquinoxRequester,     val localUser: EquinoxLocalUser) : EquinoxViewModel

The EquinoxProfileViewModel class is the support class used to change the user account settings or preferences

Author

N7ghtm4r3 - Tecknobit

Parameters

snackbarHostState

The host to launch the snackbar messages

requester

The instance to manage the requests with the backend

localUser

The user of the current logged-in session, used to make the requests to the backend

See also

Constructors

Link copied to clipboard
constructor(snackbarHostState: SnackbarHostState, requester: EquinoxRequester, localUser: EquinoxLocalUser)

Properties

Link copied to clipboard
lateinit var email: MutableState<String>

email the email of the user

Link copied to clipboard

language the language of the user

Link copied to clipboard
Link copied to clipboard

newEmail the value of the new email to set

Link copied to clipboard

newEmailError whether the newEmail field is not valid

Link copied to clipboard

newPassword the value of the new password to set

Link copied to clipboard

newPasswordError whether the newPassword field is not valid

Link copied to clipboard

password the password of the user

Link copied to clipboard

profilePic the profile picture of the user

Link copied to clipboard
Link copied to clipboard
private val retriever: Retriever

retriever the manager used to fetch the data from the backend

Link copied to clipboard
Link copied to clipboard

theme the theme of the user

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
open override fun canRetrieverStart(): Boolean

Method used to get whether the viewModelScope can start, so if there aren't other jobs that routine is already executing

Link copied to clipboard
open fun changeEmail(onSuccess: () -> Unit? = null, onFailure: (JsonObject) -> Unit = { showSnackbarMessage(it) })

Method used to execute the email change

Link copied to clipboard
open fun changeLanguage(onSuccess: () -> Unit? = null, onFailure: (JsonObject) -> Unit = { showSnackbarMessage(it) })

Method used to execute the language change

Link copied to clipboard
open fun changePassword(onSuccess: () -> Unit? = null, onFailure: (JsonObject) -> Unit = { showSnackbarMessage(it) })

Method used to execute the password change

Link copied to clipboard
open fun changeProfilePic(profilePicName: String, profilePicBytes: ByteArray, onFailure: (JsonObject) -> Unit = { showSnackbarMessage(it) })

Method used to execute the profile pic change, look how to integrate

Link copied to clipboard
open fun changeTheme(onChange: () -> Unit? = null)

Method used to execute the theme change

Link copied to clipboard
open fun clearSession(onClear: () -> Unit? = null)

Method used to clear the current localUser session

Link copied to clipboard
open override fun continueToRetrieve(currentContext: KClass<*>): Boolean

Method used to suspend the current viewModelScope to execute other requests to the backend, the isRefreshing instance will be set as false to allow the restart of the routine after executing the other requests

Link copied to clipboard
open fun deleteAccount(onDelete: () -> Unit? = null, onFailure: (JsonObject) -> Unit = { showSnackbarMessage(it) })

Method used to execute the account deletion

Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
protected expect open fun onCleared()
Link copied to clipboard
open override fun restartRetriever()

Method used to restart the current viewModelScope after other requests has been executed, the isRefreshing instance will be set as true to deny the restart of the routine after executing the other requests

Link copied to clipboard
open fun restartRetrieverIf(condition: Boolean)

Method used to conditionally restart the current retrieverScope after other requests has been executed, the isRefreshing instance will be set as true to deny the restart of the routine after executing the other requests

Link copied to clipboard
open override fun retrieve(currentContext: KClass<*>, routine: suspend () -> Unit, repeatRoutine: Boolean, refreshDelay: Long)

Method used to execute the refresh routine designed

Link copied to clipboard
open fun setActiveContext(currentContext: KClass<*>)

Method used to set the current active context where the retrieverScope is executing

Link copied to clipboard
fun showSnackbarMessage(    message: String,     actionLabel: String? = null,     onDismiss: () -> Unit? = null,     onActionPerformed: () -> Unit? = null,     withDismissAction: Boolean = false,     duration: SnackbarDuration = if (actionLabel == null) SnackbarDuration.Short else SnackbarDuration.Indefinite)
fun showSnackbarMessage(    response: JsonObject,     actionLabel: String? = null,     onDismiss: () -> Unit? = null,     onActionPerformed: () -> Unit? = null,     withDismissAction: Boolean = false,     duration: SnackbarDuration = if (actionLabel == null) SnackbarDuration.Short else SnackbarDuration.Indefinite)
fun showSnackbarMessage(    message: StringResource,     actionLabel: StringResource? = null,     onDismiss: () -> Unit? = null,     onActionPerformed: () -> Unit? = null,     withDismissAction: Boolean = false,     duration: SnackbarDuration = if (actionLabel == null) SnackbarDuration.Short else SnackbarDuration.Indefinite)

Method used to display a response message with a snackbar

Link copied to clipboard
open override fun suspendRetriever()

Method used to suspend the current viewModelScope to execute other requests to the backend, the isRefreshing instance will be set as false to allow the restart of the routine after executing the other requests

Link copied to clipboard
open fun suspendRetrieverIf(condition: Boolean)

Method used to conditionally suspend the current retrieverScope to execute other requests to the backend, the isRefreshing instance will be set as false to allow the restart of the routine after executing the other requests