Last active
November 28, 2023 19:24
-
-
Save ramonrabello/b7bac56fd5fe842b21cf34163f7bd7a6 to your computer and use it in GitHub Desktop.
LoginViewModel.kt - Accelerating the mobile legacy modernization: Migrate to Compose 10x faster using StackSpot AI
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
class LoginViewModel : ViewModel() { | |
// Estado inicial | |
private val _uiState = MutableStateFlow(LoginUiState()) | |
val uiState: StateFlow<LoginUiState> = _uiState | |
// Constantes para credenciais válidas | |
companion object { | |
const val VALID_EMAIL = "seu_email@example.com" | |
const val VALID_PASSWORD = "sua_senha" | |
} | |
// Função para validar as credenciais | |
fun validateCredentials(email: String, password: String) { | |
if (email == VALID_EMAIL && password == VALID_PASSWORD) { | |
_uiState.value = LoginUiState(email, password, true) | |
} else { | |
_uiState.value = LoginUiState(email, password, false, "Credenciais inválidas.") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment