Skip to content

Commit

Permalink
#15 [add] password error 시 password editText 밑줄 색상 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
stellar-halo committed Dec 5, 2023
1 parent de925ea commit 4561cb2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SignUpActivity : BindingActivity<ActivitySignUpBinding>(R.layout.activity_
}
viewModel.password.observe(this) { _ ->
viewModel.updateIsMeetCriteria()
viewModel.isPasswordRegexMatch()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SignUpViewModel @Inject constructor(
val password: MutableLiveData<String> = MutableLiveData()
val nickname: MutableLiveData<String> = MutableLiveData()
val mbti: MutableLiveData<String> = MutableLiveData()
private val _isPasswordMeetCriteria: MutableLiveData<Boolean> = MutableLiveData(false)
val isPasswordMeetCriteria: LiveData<Boolean> = _isPasswordMeetCriteria
private val _isMeetCriteria: MutableLiveData<Boolean> = MutableLiveData(false)
val isMeetCriteria: LiveData<Boolean> = _isMeetCriteria
private val _signUpState = MutableLiveData<Boolean>()
Expand Down Expand Up @@ -59,8 +61,10 @@ class SignUpViewModel @Inject constructor(
return id.value?.let { ID_REGEX.matcher(it).find() } ?: false
}

private fun isPasswordRegexMatch(): Boolean {
return password.value?.let { PASSWORD_REGEX.matcher(it).find() } ?: false
fun isPasswordRegexMatch(): Boolean {
val pwRegexMatch = password.value?.let { PASSWORD_REGEX.matcher(it).find() } ?: false
_isPasswordMeetCriteria.value = pwRegexMatch
return pwRegexMatch
}

companion object {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="@{vm.isPasswordMeetCriteria == true? @color/black : @color/red}"
android:hint="@string/password_hint"
android:inputType="textPassword"
android:text="@={vm.password}"
Expand Down Expand Up @@ -120,10 +121,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:textColor="@color/white"
android:clickable="@{vm.isMeetCriteria == true ? true : false}"
android:backgroundTint="@{vm.isMeetCriteria == true ? @color/baby_blue : @color/gray}"
android:clickable="@{vm.isMeetCriteria == true ? true : false}"
android:text="@string/sign_up_btn"
android:textColor="@color/white"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="red">#FFD1180B</color>
<color name="gray">#FFD3D3D3</color>
<color name="baby_blue">#FFA1CAF1</color>
</resources>

0 comments on commit 4561cb2

Please sign in to comment.