-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from meongCare/feature/nutrition
feat: 이상증상 리스트 편집 기능, 데이터 없을 시 이벤트 추가
- Loading branch information
Showing
18 changed files
with
445 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/main/java/com/project/meongcare/symptom/view/SymptomBottomSheetDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.project.meongcare.symptom.view | ||
|
||
import android.app.Dialog | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import com.project.meongcare.databinding.BottomsheetSymptomAddDateBinding | ||
import java.time.LocalDate | ||
|
||
class SymptomBottomSheetDialogFragment : BottomSheetDialogFragment() { | ||
lateinit var fragmentSymptomBottomSheetBinding: BottomsheetSymptomAddDateBinding | ||
|
||
interface OnDateSelectedListener { | ||
fun onDateSelected(date: LocalDate) | ||
} | ||
|
||
var onDateSelectedListener: OnDateSelectedListener? = null | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle?, | ||
): View { | ||
fragmentSymptomBottomSheetBinding = BottomsheetSymptomAddDateBinding.inflate(inflater, container, false) | ||
|
||
fragmentSymptomBottomSheetBinding.buttonBottomsheetSymptomAddDateComplete.setOnClickListener { | ||
val datePicker = fragmentSymptomBottomSheetBinding.datepickerBottomsheetSymptomAddDate | ||
val selectedDate = | ||
LocalDate.of(datePicker.year, datePicker.month + 1, datePicker.dayOfMonth) | ||
onDateSelectedListener?.onDateSelected(selectedDate) | ||
dismiss() | ||
} | ||
|
||
return fragmentSymptomBottomSheetBinding.root | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog | ||
val peekHeightInPixels = 0 | ||
|
||
val behavior = dialog.behavior | ||
if (behavior != null) { | ||
behavior.peekHeight = peekHeightInPixels | ||
behavior.state = BottomSheetBehavior.STATE_EXPANDED | ||
} | ||
|
||
return dialog | ||
} | ||
|
||
override fun onViewCreated( | ||
view: View, | ||
savedInstanceState: Bundle?, | ||
) { | ||
super.onViewCreated(view, savedInstanceState) | ||
removeDatePickerHeader() | ||
} | ||
|
||
fun removeDatePickerHeader() { | ||
fragmentSymptomBottomSheetBinding.run { | ||
val datePickerHeaderId = | ||
fragmentSymptomBottomSheetBinding.datepickerBottomsheetSymptomAddDate.getChildAt(0) | ||
.resources.getIdentifier("date_picker_header", "id", "android") | ||
fragmentSymptomBottomSheetBinding.root.findViewById<View>(datePickerHeaderId).visibility = | ||
View.GONE | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.