Skip to content

Instantly share code, notes, and snippets.

@hieuwu
Created August 1, 2023 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hieuwu/fb9998adc0cca6fba17e68e9bd2d3834 to your computer and use it in GitHub Desktop.
Save hieuwu/fb9998adc0cca6fba17e68e9bd2d3834 to your computer and use it in GitHub Desktop.
@HiltViewModel
class SignInViewModel @Inject constructor(
private val authenticationRepository: AuthenticationRepository
) : ViewModel() {
private val _email = MutableStateFlow("")
val email: Flow<String> = _email
private val _password = MutableStateFlow("")
val password = _password
fun onEmailChange(email: String) {
_email.value = email
}
fun onPasswordChange(password: String) {
_password.value = password
}
fun onLogin() {
viewModelScope.launch {
authenticationRepository.signIn(
email = _email.value,
password = _password.value
)
}
}
fun onGoogleSignIn() {
viewModelScope.launch {
authenticationRepository.signInWithGoogle()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment