Skip to content

Commit

Permalink
#135 [mod] 닉네임 버튼 활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
emjayMJkim committed Jan 31, 2024
1 parent f7724a4 commit f96bd67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BearNamingFragment :

setLottieFile()
setNicknameEditTextFilter()
initSetNickNameObserver()
initChangeFragment()
}

Expand Down Expand Up @@ -73,6 +74,12 @@ class BearNamingFragment :
})
}

private fun initSetNickNameObserver() {
viewModel.nickname.observe(viewLifecycleOwner) {
viewModel.checkIsNickNameValid()
}
}

private fun initChangeFragment() {
binding.btnBearSelection.setSingleOnClickListener {
activityViewModel.setBearNickname(viewModel.nickname.value ?: "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class BearNamingViewModel : ViewModel() {
(isInvalidInput.value == true) || (isLengthExceed.value == true)
}

fun checkIsNickNameValid() {
_isNickNameValid.value = !nickname.value.isNullOrBlank() && (isWarning.value == false)
}

companion object {
private const val MAXIMUM_LENGTH = 10
private const val NICKNAME_PATTERN =
Expand Down

0 comments on commit f96bd67

Please sign in to comment.