Skip to content
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

feat: 강아지 이름 연결 및 이상증상 전체선택 로직 수정 #130

Merged
merged 5 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -96,6 +96,7 @@ class SupplementFragment : Fragment() {
navController = findNavController()

fragmentSupplementBinding.run {
textViewSupplementDogName.text = supplementViewModel.dogName.value
textViewSupplementAdd.setOnClickListener {
navController.navigate(R.id.action_supplement_to_supplementAdd)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SupplementViewModel
var supplementCode = MutableLiveData<Int?>()
var supplementDeleteCode = MutableLiveData<Int?>()
var routineIsClicked = MutableLiveData<Boolean>()
var dogName = MutableLiveData<String>()

init {
intakeTimeList.value = mutableListOf()
Expand All @@ -67,6 +68,7 @@ class SupplementViewModel
supplementPercentage.value = 0.0
supplementIdListAllCheck.value = false
supplementAddImg.value = null
getDogName()
}

fun getSupplements(date: Date) {
Expand Down Expand Up @@ -314,4 +316,10 @@ class SupplementViewModel

supplementIdListAllCheck.value = isChecked
}

fun getDogName() {
viewModelScope.launch {
dogName.value = DogPreferences(GlobalApplication.applicationContext()).dogName.first()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class SymptomEditFragment : Fragment(), SymptomBottomSheetDialogFragment.OnDateS
}

fragmentSymptomEditBinding.run {
toolbarSymptomEditTitle.text = "${symptomViewModel.dogName.value}님의 이상증상"

buttonSymptomEditDate.setOnClickListener {
showCalendarBottomSheet(parentFragmentManager, this@SymptomEditFragment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class SymptomFragment : Fragment() {
val factory = SymptomViewModelFactory(SymptomRepository())
symptomViewModel = ViewModelProvider(this, factory)[SymptomViewModel::class.java]

val dogName = "김대박"

navController = findNavController()

toolbarViewModel.run {
Expand All @@ -60,7 +58,7 @@ class SymptomFragment : Fragment() {


fragmentSymptomBinding.run {
textViewSymptomDogName.text = dogName
textViewSymptomDogName.text = symptomViewModel.dogName.value
textViewSymptomAdd.setOnClickListener {
navController.navigate(R.id.action_symptom_to_symptomAdd)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class SymptomInfoFragment : Fragment() {
showFailSnackbar()
}
}

dogName.observe(viewLifecycleOwner) {
fragmentSymptomInfoBinding.toolbarSymptominfo.title = "${it}님의 이상증상"
}
}
fragmentSymptomInfoBinding.run {
val symptomData = arguments?.getParcelable<Symptom>("symptomData")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class SymptomListEditFragment : Fragment() {

navController = findNavController()

// TODO : 강아지 이름 연결 필요
val dogName = "김대박"

symptomViewModel.symptomList.value =
arguments?.getParcelableArrayList<Parcelable>("symptomList") as MutableList<Symptom>
Log.d("증상 리스트", symptomViewModel.symptomList.value.toString())
Expand All @@ -53,16 +50,14 @@ class SymptomListEditFragment : Fragment() {
symptomIdList.observe(viewLifecycleOwner) {
Log.d("이상증상 변화", it.toString())
fragmentSymptomListEditBinding.run {
if (it.isNotEmpty() && it.size == symptomList.value!!.size) {
imageViewSymptomListEditDeleteAllCheck.isSelected = true
}
imageViewSymptomListEditDeleteAllCheck.isSelected = it.isNotEmpty() && it.size == symptomList.value!!.size
recyclerViewSymptomListEdit.run {
adapter = SymptomListEditRecyclerViewAdapter(symptomViewModel)
layoutManager = LinearLayoutManager(context)
}
}
}
symptomViewModel.deleteSymptomCode.observe(viewLifecycleOwner) { code ->
deleteSymptomCode.observe(viewLifecycleOwner) { code ->
if (code == 200) {
CustomSnackBar.make(
requireView(),
Expand All @@ -72,22 +67,27 @@ class SymptomListEditFragment : Fragment() {
navController.popBackStack()
}
}

dogName.observe(viewLifecycleOwner) {
fragmentSymptomListEditBinding.toolbarSymptomListEdit.run {
title = "${it}님의 이상증상"
}
}
}

fragmentSymptomListEditBinding.run {
toolbarSymptomListEdit.run {
setNavigationOnClickListener {
navController.popBackStack()
}
}

if (symptomViewModel.symptomList.value.isNullOrEmpty()) {
scrollViewSymptomListEdit.visibility = View.GONE
layoutSymptomListEditButton.visibility = View.GONE
layoutSymptomListEditNoData.visibility = View.VISIBLE
}

toolbarSymptomListEdit.run {
title = "${dogName}님의 이상증상"
setNavigationOnClickListener {
navController.navigate(R.id.action_symptomListEdit_to_symptom)
}
}

if (symptomViewModel.symptomIdListAllCheck.value!!) {
imageViewSymptomListEditDeleteAllCheck.isSelected = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SymptomViewModel
var patchSymptomIsSuccess = MutableLiveData<Boolean?>()
var symptomIdList = MutableLiveData<MutableList<Int>>()
var symptomIdListAllCheck = MutableLiveData<Boolean>()
var dogName = MutableLiveData<String>()

init {
symptomList.value = mutableListOf()
Expand All @@ -50,6 +51,7 @@ class SymptomViewModel
textViewNoDataVisibility.value = false
symptomIdListAllCheck.value = false
patchSymptomIsSuccess.value = null
getDogName()
}

fun getSymptomList(date: Date) {
Expand Down Expand Up @@ -136,4 +138,10 @@ class SymptomViewModel
symptomDateText.value = date.toString()
}
}

fun getDogName() {
viewModelScope.launch {
dogName.value = DogPreferences(GlobalApplication.applicationContext()).dogName.first()
}
}
}