Skip to content

Commit

Permalink
build : 학사일정의 datepicker을 bottomsheet 형태로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
huiwoo-jo committed Sep 20, 2024
1 parent 53cb663 commit 3929280
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import android.view.ViewGroup
import android.view.WindowManager
import android.widget.NumberPicker
import androidx.fragment.app.DialogFragment
import com.dongyang.android.youdongknowme.R
import com.dongyang.android.youdongknowme.databinding.DialogDatepickerBinding
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.threeten.bp.LocalDate

class DatePickerDialog(
val year: Int,
val month: Int,
private val dateSelectedListener: ScheduleFragment,
) : DialogFragment() {
) : BottomSheetDialogFragment() {

private var _binding: DialogDatepickerBinding? = null
private val binding get() = _binding!!
Expand Down Expand Up @@ -85,29 +88,7 @@ class DatePickerDialog(
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {

val dialog = super.onCreateDialog(savedInstanceState)

dialog.window?.let { window ->
window.setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
}

return dialog
}

override fun onStart() {

super.onStart()

dialog?.window?.let { window ->
val layoutParams = window.attributes
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
window.attributes = layoutParams
}
return BottomSheetDialog(requireContext(), R.style.CustomBottomSheetDialogTheme)
}

override fun onDestroyView() {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/bg_white_radius_20dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="20dp" />
<solid android:color="@color/white" />
</shape>
5 changes: 1 addition & 4 deletions app/src/main/res/layout/dialog_datepicker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@drawable/bg_stroke_gray300_radius_2dp"
android:backgroundTint="@color/white">
android:layout_margin="20dp">

<NumberPicker
android:id="@+id/numberpicker_dialog_datepicker_year"
Expand Down Expand Up @@ -46,5 +44,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/numberpicker_dialog_datepicker_year" />

</androidx.constraintlayout.widget.ConstraintLayout>
8 changes: 8 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@
<item name="android:fontFamily">@font/pretendard_medium</item>
<item name="android:textSize">@dimen/font_size_12</item>
</style>

<style name="CustomBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/CustomBottomSheetCornerStyle</item>
</style>

<style name="CustomBottomSheetCornerStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/bg_white_radius_20dp</item>
</style>
</resources>

0 comments on commit 3929280

Please sign in to comment.