From 35ed5c413096013ca81d56dac1fe70ee93ba3cb6 Mon Sep 17 00:00:00 2001 From: b1urrrr Date: Wed, 5 Apr 2023 03:06:19 +0900 Subject: [PATCH] =?UTF-8?q?[MOD/#1]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=B0=8F=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20onClick=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/go/sopt/presentation/login/LoginViewModel.kt | 9 ++++++--- .../go/sopt/presentation/signup/SignupViewModel.kt | 2 +- app/src/main/res/layout/activity_login.xml | 1 + app/src/main/res/layout/activity_signup.xml | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) 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" />