Skip to content

Instantly share code, notes, and snippets.

@ramonrabello
Last active November 28, 2023 19:24
Show Gist options
  • Save ramonrabello/b7bac56fd5fe842b21cf34163f7bd7a6 to your computer and use it in GitHub Desktop.
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
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