Created
October 29, 2021 19:19
-
-
Save emedinaa/a78c95cf0d03e2319f1346aa9475edb9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 LogInFragment : Fragment() { | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
//TODO events | |
binding.buttonLogIn.setOnClickListener { | |
if(validForm()) { | |
showMessage() | |
} | |
} | |
} | |
//TODO validate form S. O. L. I. D | |
private fun validForm() :Boolean { | |
binding.textInputLayoutUsername.error = null | |
binding.textInputLayoutPassword.error = null | |
val username = binding.textInputLayoutUsername.editText?.text.toString().trim() | |
val password = binding.textInputLayoutPassword.editText?.text.toString().trim() | |
if(username.isEmpty()) { | |
binding.textInputLayoutUsername.error = "Ingresar username" | |
return false | |
} | |
if(!username.isValidEmail()) { | |
binding.textInputLayoutUsername.error = "Username campo inválido" | |
return false | |
} | |
if(password.isEmpty()) { | |
binding.textInputLayoutPassword.error = "Ingresar password" | |
return false | |
} | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment