Skip to content

Commit

Permalink
[MOD/#1] 로그인 및 회원가입 버튼 onClick 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Apr 4, 2023
1 parent 26cb042 commit 35ed5c4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import javax.inject.Inject

@HiltViewModel
class LoginViewModel @Inject constructor() : ViewModel() {
private lateinit var savedUser: User

private val _loginState = MutableLiveData<UiState>()
val loginState: LiveData<UiState>
get() = _loginState

private lateinit var savedUser: User

val id = MutableLiveData("")
val pwd = MutableLiveData("")

Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_signup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down

0 comments on commit 35ed5c4

Please sign in to comment.