Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2022-1557 Common validation #41

Merged
merged 6 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
P2022-1557 Common validation
  • Loading branch information
AdrianPat committed Mar 23, 2022
commit bed5903da780d56ec205318a1cb4e8be7d9e8c90
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import com.intive.patronage22.intivi.*
import com.intive.patronage22.intivi.databinding.FragmentSignInBinding

class SignInFragment : Fragment() {

private var loginEmail: EditText? = null
private var loginPassword: EditText? = null

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val bind = FragmentSignInBinding.inflate(layoutInflater)

upperToLowerCase(bind.editTextLoginEmail)
loginEmail = bind.editTextLoginEmail
loginPassword = bind.editTextLoginPassword
val emailValidMess: String = getString(R.string.emailValidMessage)
val passwordValidMess: String = getString(R.string.passwordValidMessage)

upperToLowerCase(loginEmail!!)

fun isValid() = isLoginFormValid(
bind.editTextLoginEmail,
bind.editTextLoginPassword,
getString(R.string.emailValidMessage),
getString(R.string.passwordValidMessage)
)
fun isValid() = isLoginFormValid(loginEmail!!, loginPassword!!,
emailValidMess, passwordValidMess)

bind.signInButton.setOnClickListener {
if (isValid()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,33 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import com.intive.patronage22.intivi.*
import com.intive.patronage22.intivi.databinding.FragmentSignUpBinding

class SignUpFragment : Fragment() {

private var registerEmail: EditText? = null
private var registerPassword: EditText? = null
private var registerRepeatPassword: EditText? = null

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val bind = FragmentSignUpBinding.inflate(layoutInflater)

upperToLowerCase(bind.editTextRegisterEmail)
registerEmail = bind.editTextRegisterEmail
registerPassword = bind.editTextRegisterPassword
registerRepeatPassword = bind.editTextRegisterRepeatPassword
val emailValidMess: String = getString(R.string.emailValidMessage)
val passwordValidMess: String = getString(R.string.passwordValidMessage)
val repeatPassValidMess: String = getString(R.string.repeatPassValidMessage)

upperToLowerCase(registerEmail!!)

fun isValid() = isRegisterFormValid(
bind.editTextRegisterEmail,
bind.editTextRegisterPassword,
bind.editTextRegisterRepeatPassword,
getString(R.string.emailValidMessage),
getString(R.string.passwordValidMessage),
getString(R.string.repeatPassValidMessage)
)
fun isValid() = isRegisterFormValid(registerEmail!!, registerPassword!!, registerRepeatPassword!!,
emailValidMess, passwordValidMess, repeatPassValidMess)

bind.signUpButton.setOnClickListener {
if (isValid()) {
Expand Down