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

fix: 캘린더 bottom sheet 및 bottom navigation 관련 버그 수정 #125

Merged
merged 4 commits into from
Jan 19, 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
@@ -1,11 +1,14 @@
package com.project.meongcare

import android.app.Dialog
import android.graphics.Typeface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.archit.calendardaterangepicker.customviews.CalendarListener
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.FragmentCalendarBottomSheetBinding
import com.project.meongcare.onboarding.model.data.local.DateSubmitListener
Expand All @@ -22,6 +25,19 @@ class CalendarBottomSheetFragment : BottomSheetDialogFragment() {
private var dateSubmitListener: DateSubmitListener? = null
private var currentDate: String? = null

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 onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -33,6 +49,11 @@ class CalendarBottomSheetFragment : BottomSheetDialogFragment() {
fragmentCalendarBottomSheetBinding.run {
val calendarTypeface = Typeface.createFromAsset(mainActivity.assets, "pretendard_regular.otf")
calendarBottomSheet.setFonts(calendarTypeface)
val currentMonth = Calendar.getInstance()
val pastMonth = Calendar.getInstance()
pastMonth.add(Calendar.MONTH, -282)
calendarBottomSheet.setVisibleMonthRange(pastMonth, currentMonth)
calendarBottomSheet.setCurrentMonth(currentMonth)

calendarBottomSheet.setCalendarListener(
object : CalendarListener {
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/com/project/meongcare/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,21 @@ class MainActivity : AppCompatActivity() {

true
}
setOnItemReselectedListener { menuItem ->
if (menuItem.itemId == R.id.menuMainBottomNavHome) {
fragmentContainerView.findNavController().navigate(R.id.homeFragment)
} else {
includeMedicalRecordDialog.root.visibility = View.VISIBLE
}
}
}

includeMedicalRecordDialog.run {
constraintlayoutBg.setOnClickListener {
includeMedicalRecordDialog.root.visibility = View.GONE
bottomNavigationViewMain.selectedItemId = R.id.menuMainBottomNavHome
includeMedicalRecordDialog.root.visibility = View.VISIBLE
}
buttonOk.setOnClickListener {
includeMedicalRecordDialog.root.visibility = View.GONE
bottomNavigationViewMain.selectedItemId = R.id.menuMainBottomNavHome
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class PetEditFragment : Fragment(), PhotoMenuListener, DateSubmitListener {
checkboxPeteditNeuterStatus.isChecked = !isCbxChecked
}

imageviewPeteditBirthdayCalender.setOnClickListener {
edittextPeteditSelectBirthday.setOnClickListener {
val calendarBottomSheet = CalendarBottomSheetFragment()
calendarBottomSheet.setDateSubmitListener(this@PetEditFragment)
calendarBottomSheet.setStyle(DialogFragment.STYLE_NORMAL, R.style.RoundCornerCalendarDialogTheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class DogAddOnBoardingFragment : Fragment(), PhotoMenuListener, DateSubmitListen
}

// 날짜 등록
imageviewPetaddBirthdayCalender.setOnClickListener {
textviewPetaddSelectBirthday.setOnClickListener {
val calendarBottomSheet = CalendarBottomSheetFragment()
calendarBottomSheet.setDateSubmitListener(this@DogAddOnBoardingFragment)
calendarBottomSheet.setStyle(DialogFragment.STYLE_NORMAL, R.style.RoundCornerCalendarDialogTheme)
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/fragment_calendar_bottom_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
custom:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
custom:behavior_hideable="true"
custom:behavior_peekHeight="0dp"
tools:context=".CalendarBottomSheetFragment">

<ImageView
Expand Down