Skip to content

#122 [fix] 데일리 루틴 삭제 후 초기화 시키기 #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class DailyRoutineFragment :
if (isDeleteView) {
binding.tvDailyRoutineEdit.setSingleOnClickListener {
viewModel.setDeleteView(false)
resetRadioButtons()
}
clickEditRadioBtn()
}
Expand Down Expand Up @@ -200,7 +201,8 @@ class DailyRoutineFragment :
}

private fun changeBtnSelectState(button: View, itemId: Int) {
button.setSingleOnClickListener {
button.setOnClickListener {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈 줄 삭제해주세요!

it.isSelected = !it.isSelected
viewModel.setEditRoutineIdArray(itemId)
setDeleteRoutineBtnContent()
Expand All @@ -221,6 +223,7 @@ class DailyRoutineFragment :
binding.btnDailyRoutineDelete.text = deleteBtnContent
}


private fun initSetRoutineDelete() {
binding.btnDailyRoutineDelete.setSingleOnClickListener {
BindingBottomSheet.Builder().build(
Expand All @@ -236,20 +239,34 @@ class DailyRoutineFragment :
doBtnColor = R.drawable.shape_red_fill_12_rect,
backBtnAction = {},
doBtnAction = {
val arraySize = viewModel.editRoutineIdArray.size
viewModel.deleteDailyRoutine()
viewModel.isDailyRoutineDelete.observe(viewLifecycleOwner) {
snackBar(
binding.root.rootView,
"데일리 루틴을 ${viewModel.editRoutineIdArray.size}개 삭제했어요"
"데일리 루틴을 ${arraySize}개 삭제했어요"
)
viewModel.setDeleteView(false)
viewModel.getDailyRoutine()

resetRadioButtons()
}
}
).show(parentFragmentManager, BOTTOM_SHEET_TAG)
}
}

private fun resetRadioButtons() {
with(binding) {
btnDailyRoutineRadioFirst.isSelected = false
btnDailyRoutineRadioSecond.isSelected = false
btnDailyRoutineRadioThird.isSelected = false
}
viewModel.clearEditRoutineIdArray()
setDeleteRoutineBtnContent()
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 한 줄 삭제해주세요!


private fun startDailyRoutineCompleteActivity() {
val intentToCompleteActivity =
Intent(requireActivity(), DailyRoutineCompleteActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class DailyRoutineViewModel @Inject constructor(
get() = _isDeleteView

val editRoutineIdArray = ArrayList<Int>()
// val editRoutineIdArray : MutableLiveData<List<Int>> = MutableLiveData()

private val _isEditBtnEnabled: MutableLiveData<Boolean> = MutableLiveData()
val isEditBtnEnabled: LiveData<Boolean>
Expand Down Expand Up @@ -120,11 +121,16 @@ class DailyRoutineViewModel @Inject constructor(
}
}

fun clearEditRoutineIdArray() {
editRoutineIdArray.clear()
}

fun setEditBtnEnabled(enabled: Boolean) {
_isEditBtnEnabled.value = enabled
}

private val _userDaily: LiveData<UserDailyRoutine> = MutableLiveData()
val userDaily: LiveData<UserDailyRoutine>
get() = _userDaily

}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_daily_routine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
android:layout_marginTop="8dp"
android:background="@drawable/shape_gray200_line_20_rect"
android:clickable="true"
android:visibility="@{viewModel.dailyRoutineListResponse.size() == 3 ? View.GONE : View.VISIBLE}"
android:visibility="@{viewModel.dailyRoutineListResponse.size() == 3 || viewModel.isDeleteView() ? View.GONE : View.VISIBLE}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cl_daily_routine_third">
Expand Down