Skip to content

Commit

Permalink
[FEAT/#45] 마이투두 생성 버튼 활성화 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Jan 9, 2024
1 parent f6cdf0c commit 4982ff5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MyTodoCreateBottomSheet() :
binding.btnCreateTripFinish.setOnSingleClickListener {
viewModel.endDate.value =
binding.dpCreateTripDate.year.toString() + "." + (binding.dpCreateTripDate.month + 1).toString() + "." + binding.dpCreateTripDate.dayOfMonth.toString()
viewModel.checkIsFinishAvailable()
dismiss()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ class MyTodoCreateViewModel : ViewModel() {
val memo = MutableLiveData("")
val nowMemoLength = MutableLiveData(0)

val isFinishAvailable = MutableLiveData(false)

fun getMaxTodoLen() = MAX_TODO_LEN

fun getMaxMemoLen() = MAX_MEMO_LEN

fun checkTodoLength() {
fun checkIsFinishAvailable() {
nowTodoLength.value = getGraphemeLength(todo.value)
}

fun checkMemoLength() {
nowMemoLength.value = getGraphemeLength(memo.value)
isFinishAvailable.value =
todo.value?.isNotEmpty() == true && memo.value?.isNotEmpty() == true && endDate.value?.isNotEmpty() == true
}

fun isFinishAvailable() =
todo.value?.isNotEmpty() == true && memo.value?.isNotEmpty() == true && endDate.value?.isNotEmpty() == true


// 이모지 포함 글자 수 세는 함수
private fun getGraphemeLength(value: String?): Int {
BREAK_ITERATOR.setText(value)
Expand Down
4 changes: 2 additions & 2 deletions presentation/src/main/res/layout/activity_my_todo_create.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="6dp"
android:afterTextChanged="@{(text) -> vm.checkTodoLength()}"
android:background="@drawable/shape_rect_4_gray200_line"
android:hint="@string/my_todo_create_tv_todo_hint"
android:imeOptions="actionNext"
android:includeFontPadding="false"
android:inputType="text"
android:afterTextChanged="@{(text) -> vm.checkIsFinishAvailable()}"
android:maxLines="1"
android:paddingHorizontal="12dp"
android:paddingVertical="19dp"
Expand Down Expand Up @@ -234,7 +234,7 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="6dp"
android:afterTextChanged="@{(text) -> vm.checkMemoLength()}"
android:afterTextChanged="@{(text) -> vm.checkIsFinishAvailable()}"
android:background="@drawable/shape_rect_4_gray200_line"
android:gravity="top"
android:hint="@string/my_todo_create_tv_memo_hint"
Expand Down

0 comments on commit 4982ff5

Please sign in to comment.