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] 번개 생성 개최 뷰 - 시간 / 날짜 뷰 구현 #43

Merged
merged 13 commits into from
Jan 6, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[feat] #38 핑글 개최 프로세스 - 시간/날짜 넘버피커 프래그먼트 구현
Dan2dani committed Jan 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b6311cf9b86ee836e27a9db9a62f2afd3dca39fc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import android.widget.NumberPicker
import org.sopt.pingle.R
import org.sopt.pingle.databinding.DialogDatePickerBinding
import org.sopt.pingle.util.base.BindingBottomSheetDialogFragment

class PlanDateDialogFragment(
private val onDialogClosed: (year: Int, month: Int, day: Int) -> Unit
) :
BindingBottomSheetDialogFragment<DialogDatePickerBinding>(R.layout.dialog_date_picker) {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
isCancelable = false
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

initLayout()
addListeners()
}

private fun initLayout() {
val yearPicker = binding.npDatePickerYear
yearPicker.apply {
wrapSelectorWheel = false // 순한 안되게 막기
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS // editText 설정 해제
minValue = YEAR_MIN
maxValue = YEAR_MAX
}

val hoursPicker = binding.npDatePickerMonth
hoursPicker.apply {
wrapSelectorWheel = false
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS
minValue = MONTH_MIN
maxValue = MONTH_MAX
}
val dayPicker = binding.npDatePickerDay
dayPicker.apply {
wrapSelectorWheel = false
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS
minValue = DAY_MIN
maxValue = DAY_MAX
}
}

private fun addListeners() {
binding.tvDatePickerDone.setOnClickListener {
onDialogClosed(
binding.npDatePickerYear.value,
binding.npDatePickerMonth.value,
binding.npDatePickerDay.value
)
dismiss()
}
}

companion object {
const val YEAR_MIN = 2024
const val YEAR_MAX = 2050
const val MONTH_MIN = 1
const val MONTH_MAX = 12
const val DAY_MIN = 1
const val DAY_MAX = 31
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import android.widget.NumberPicker
import org.sopt.pingle.R
import org.sopt.pingle.databinding.DialogTimePickerBinding
import org.sopt.pingle.util.base.BindingBottomSheetDialogFragment

class PlanTimeDialogFragment(
private val onDialogClosed: (String) -> Unit
) :
BindingBottomSheetDialogFragment<DialogTimePickerBinding>(R.layout.dialog_time_picker) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
isCancelable = false
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

initLayout()
addListeners()
}

private fun initLayout() {
val meridiemPicker = binding.npTimePickerMeridiem
meridiemPicker.apply {
wrapSelectorWheel = false // 순한 안되게 막기
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS // editText 설정 해제
minValue = 0
maxValue = 1
displayedValues = arrayOf("오전", "오후")
Dan2dani marked this conversation as resolved.
Show resolved Hide resolved
}

val hoursPicker = binding.npTimePickerHour
hoursPicker.apply {
wrapSelectorWheel = false // 순한 안되게 막기
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS // editText 설정 해제
minValue = HOUR_MIN
maxValue = HOUR_MAX
}
val minutesPicker = binding.npTimePickerMinute
minutesPicker.apply {
wrapSelectorWheel = false // 순한 안되게 막기
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS // editText 설정 해제
minValue = MINUTE_MIN
maxValue = MINUTE_MAX
setFormatter { value -> String.format("%02d", value) }
}
}

private fun addListeners() {
binding.tvTimePickerDone.setOnClickListener {
onDialogClosed("aaa")
// 시간 설정 후 editText에 띄우기
// with(binding) {
// val timeFormat =
// String.format("%02d:%02d:00", npTimePickerHour.value, npTimePickerMinute.value)
// onDialogClosed(timeFormat)
// Log.d(
// "aaa",
// String.format("%02d:%02d:00", npTimePickerHour.value, npTimePickerMinute.value)
// )
// }
dismiss()
}
}

companion object {
const val HOUR_MIN = 1
const val HOUR_MAX = 12
const val MINUTE_MIN = 0
const val MINUTE_MAX = 59
}
Comment on lines +75 to +80
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잘했어욤 ~

}