Skip to content

Commit

Permalink
#86 refactor : DatePicker 함수 -> Class 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
plashdof committed Nov 26, 2023
1 parent ec01c24 commit 065763c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.avengers.nibobnebob.presentation.customview


import androidx.fragment.app.FragmentManager
import com.avengers.nibobnebob.presentation.ui.toDateString
import com.google.android.material.datepicker.MaterialDatePicker

class CalendarDatePicker(
private val onSelectDateListener: (String) -> Unit
) {
private val datePicker = MaterialDatePicker.Builder.datePicker()
.setTitleText("생일을 고르세요")
.setSelection(MaterialDatePicker.todayInUtcMilliseconds())
.build()

init{
datePicker.addOnPositiveButtonClickListener {
onSelectDateListener(it.toDateString())
}
}

fun show(fragmentManager: FragmentManager){
datePicker.show(fragmentManager,"")
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import androidx.navigation.fragment.navArgs
import com.avengers.nibobnebob.R
import com.avengers.nibobnebob.databinding.FragmentDetailSignupBinding
import com.avengers.nibobnebob.presentation.base.BaseFragment
import com.avengers.nibobnebob.presentation.customview.CalendarDatePicker
import com.avengers.nibobnebob.presentation.ui.intro.IntroViewModel
import com.avengers.nibobnebob.presentation.customview.showCalendarDatePicker
import com.google.android.material.textfield.MaterialAutoCompleteTextView
import dagger.hilt.android.AndroidEntryPoint

Expand Down Expand Up @@ -62,9 +62,9 @@ class DetailSignupFragment :

private fun setDateBtnListener() {
binding.tilBirth.setEndIconOnClickListener {
showCalendarDatePicker(parentFragmentManager) {
CalendarDatePicker{
viewModel.setBirth(it)
}
}.show(parentFragmentManager)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import androidx.navigation.Navigation
import com.avengers.nibobnebob.R
import com.avengers.nibobnebob.databinding.FragmentEditProfileBinding
import com.avengers.nibobnebob.presentation.base.BaseFragment
import com.avengers.nibobnebob.presentation.customview.CalendarDatePicker
import com.avengers.nibobnebob.presentation.ui.main.MainViewModel
import com.avengers.nibobnebob.presentation.ui.main.mypage.share.MyPageSharedUiEvent
import com.avengers.nibobnebob.presentation.ui.main.mypage.share.MyPageSharedViewModel
import com.avengers.nibobnebob.presentation.customview.showCalendarDatePicker
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest

Expand Down Expand Up @@ -76,9 +76,9 @@ class EditProfileFragment :

private fun setDateBtnListener() {
binding.tilBirth.setEndIconOnClickListener {
showCalendarDatePicker(parentFragmentManager) {
CalendarDatePicker{
viewModel.setBirth(it)
}
}.show(parentFragmentManager)
}
}

Expand Down

This file was deleted.

0 comments on commit 065763c

Please sign in to comment.