diff --git a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt index a47a2e5..858e65f 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt @@ -12,12 +12,12 @@ import javax.inject.Inject @HiltViewModel class LoginViewModel @Inject constructor() : ViewModel() { + private lateinit var savedUser: User + private val _loginState = MutableLiveData() val loginState: LiveData get() = _loginState - private lateinit var savedUser: User - val id = MutableLiveData("") val pwd = MutableLiveData("") @@ -29,7 +29,10 @@ class LoginViewModel @Inject constructor() : ViewModel() { !id.value.isNullOrBlank() && id.value == savedUser.id && !pwd.value.isNullOrBlank() && pwd.value == savedUser.pwd fun login() { - if (!isValidInput()) _loginState.value = Failure(0) + if (!isValidInput()) { + _loginState.value = Failure(0) + return + } _loginState.value = Success } } diff --git a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt index e3a216f..4e6e410 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt @@ -32,7 +32,7 @@ class SignupViewModel @Inject constructor() : ViewModel() { _signupState.value = Failure(INVALID_ID_CODE) return } - if (!isValidPwd(id.value)) { + if (!isValidPwd(pwd.value)) { _signupState.value = Failure(INVALID_PWD_CODE) return } diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 733938c..025beec 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -80,6 +80,7 @@ android:id="@+id/btn_login_login" android:layout_width="match_parent" android:layout_height="wrap_content" + android:onClick="@{()->vm.login()}" android:layout_marginTop="40dp" android:paddingVertical="12dp" android:text="@string/login_login_btn" diff --git a/app/src/main/res/layout/activity_signup.xml b/app/src/main/res/layout/activity_signup.xml index f1e2d7a..49dace5 100644 --- a/app/src/main/res/layout/activity_signup.xml +++ b/app/src/main/res/layout/activity_signup.xml @@ -140,6 +140,7 @@ android:paddingVertical="16dp" android:text="@string/signup_signup_complete_btn" android:textSize="16sp" + android:onClick="@{()->vm.signup()}" android:textStyle="bold" app:layout_constraintTop_toBottomOf="@id/et_signup_mbti" />