-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/온보딩 팝업창 #44
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
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "feature/\uC628\uBCF4\uB529-\uD31D\uC5C5\uCC3D"
Feature/온보딩 팝업창 #44
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ import android.os.Build | |||||||||||||||||||||||||||||||||||||||||||||||||||
| import android.os.Bundle | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import android.util.Log | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import android.view.LayoutInflater | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import umc.onairmate.R | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import android.view.View | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import android.view.ViewGroup | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import android.widget.LinearLayout | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -73,11 +74,13 @@ class ChatRoomParticipantsFragment : Fragment() { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| adapter = ChatRoomParticipantRVAdapter( object : ParticipantItemClickListener { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 팝업 - 신고 클릭 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| override fun clickReport(data: ParticipantData) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| val text = data.nickname+"님을 신고하시겠습니까?" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| val textList = listOf(text,"예","아니오") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| showPopup(text =textList, left = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, right = {} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // val text = data.nickname+"님을 신고하시겠습니까?" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // val textList = listOf(text,"예","아니오") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // showPopup(text =textList, left = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // }, right = {} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| showReportPopup() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 팝업 - 추천하기 클릭 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -164,11 +167,12 @@ class ChatRoomParticipantsFragment : Fragment() { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 클릭 리스너 연결 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| popupBinding.tvReport.setOnClickListener { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| val text = data.nickname+"님을 신고하시겠습니까?" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| val textList = listOf(text,"예","아니오") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| showPopup(text =textList, left = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, right = {} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // val text = data.nickname+"님을 신고하시겠습니까?" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // val textList = listOf(text,"예","아니오") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // showPopup(text =textList, left = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Toast.makeText(requireContext(),"신고 접수 되었습니다", Toast.LENGTH_SHORT).show() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // }, right = {} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| showReportPopup() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| popupWindow.dismiss() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
169
to
176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 팝업 메뉴의 신고도 동일하게 ReportDialogFragment로 연결 필요. - showReportPopup()
+ showReportDialog(data)📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| popupBinding.tvRecommend.setOnClickListener { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -190,4 +194,16 @@ class ChatRoomParticipantsFragment : Fragment() { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| popupWindow.showAsDropDown(anchorView, offsetX, offsetY) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| //방장쪽에도 함수 있다함. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| private fun showReportPopup(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| val dialogView = LayoutInflater.from(requireContext()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .inflate(R.layout.dialog_report, null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| val dialog = android.app.AlertDialog.Builder(requireContext()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .setView(dialogView) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .create() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| dialog.show() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+197
to
+208
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion AlertDialog로의 단순 inflate(showReportPopup)는 제거하고 ReportDialogFragment를 사용하세요. 아래처럼 교체를 제안드립니다. (현재 ReportDialogFragment의 생성자 패턴을 그대로 사용한 최소 변경안) - //방장쪽에도 함수 있다함.
- private fun showReportPopup(){
- val dialogView = LayoutInflater.from(requireContext())
- .inflate(R.layout.dialog_report, null)
-
- val dialog = android.app.AlertDialog.Builder(requireContext())
- .setView(dialogView)
- .create()
-
- dialog.show()
- }
+ private fun showReportDialog(target: ParticipantData) {
+ ReportDialogFragment(
+ participant = target,
+ onSubmit = { reasons, extra ->
+ // TODO: 서버 신고 API 연동 (예: viewModel.reportUser)
+ Toast.makeText(
+ requireContext(),
+ "${target.nickname}님 신고 접수(${reasons.joinToString()})",
+ Toast.LENGTH_SHORT
+ ).show()
+ }
+ ).show(parentFragmentManager, "ReportDialog")
+ }참고: ReportDialogFragment의 생성자 주입은 프로세스 재시작 시 크래시 위험이 있어, newInstance(arguments) 방식으로의 리팩터도 아래 코멘트에서 제안드립니다. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package umc.onairmate.ui.chat_room.drawer.participants | ||
|
|
||
| import android.app.Dialog | ||
| import android.content.res.Resources | ||
| import android.os.Bundle | ||
| import androidx.fragment.app.DialogFragment | ||
| import umc.onairmate.data.model.entity.ParticipantData | ||
| import umc.onairmate.databinding.DialogReportBinding | ||
|
|
||
| class ReportDialogFragment( | ||
| private val participant: ParticipantData, | ||
| private val onSubmit: (reasons: List<String>, extraReason: String) -> Unit | ||
| ) : DialogFragment() { | ||
|
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fragment에 생성자로 인자/콜백을 주입하면 프로세스 재시작 시 복원에 실패해 크래시 납니다. newInstance(ARG) + setter/FragmentResult로 전환하세요. 아래와 같이 최소 변경으로 전환을 제안드립니다. -class ReportDialogFragment(
- private val participant: ParticipantData,
- private val onSubmit: (reasons: List<String>, extraReason: String) -> Unit
-) : DialogFragment() {
+class ReportDialogFragment : DialogFragment() {
- private var _binding: DialogReportBinding? = null
+ private var _binding: DialogReportBinding? = null
private val binding get() = _binding!!
+ private lateinit var participant: ParticipantData
+ private var onSubmit: ((reasons: List<String>, extraReason: String) -> Unit)? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ participant = requireArguments().getParcelable(ARG_PARTICIPANT)!!
+ }
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
// layoutInflater 사용
_binding = DialogReportBinding.inflate(layoutInflater)
@@
- onSubmit(reasons, extraReason)
+ onSubmit?.invoke(reasons, extraReason)
dismiss()
}
@@
- return dialog
+ return dialog
}
@@
}
-private fun Int.dpToPx(): Int {
- return (this * Resources.getSystem().displayMetrics.density).toInt()
-}
+companion object {
+ private const val ARG_PARTICIPANT = "arg_participant"
+ fun newInstance(participant: ParticipantData) = ReportDialogFragment().apply {
+ arguments = Bundle().apply { putParcelable(ARG_PARTICIPANT, participant) }
+ }
+}
+
+fun setOnSubmitListener(listener: (List<String>, String) -> Unit) {
+ this.onSubmit = listener
+}이후 호출부에서는: ReportDialogFragment.newInstance(target).apply {
setOnSubmitListener { reasons, extra -> /* ... */ }
}.show(parentFragmentManager, "ReportDialog")Also applies to: 15-17, 41-43 🤖 Prompt for AI Agents |
||
|
|
||
| private var _binding: DialogReportBinding? = null | ||
| private val binding get() = _binding!! | ||
|
|
||
| override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
| // layoutInflater 사용 | ||
| _binding = DialogReportBinding.inflate(layoutInflater) | ||
|
|
||
| // 타이틀 세팅 | ||
| binding.tvTitle.text = "[${participant.nickname}]의 신고 사유" | ||
|
|
||
| // 닫기 버튼 | ||
| binding.btnClose.setOnClickListener { | ||
| dismiss() | ||
| } | ||
|
|
||
| // 제출 버튼 | ||
| binding.btnSubmit.setOnClickListener { | ||
| val reasons = mutableListOf<String>() | ||
| if (binding.cbSpam.isChecked) reasons.add("스팸, 도배") | ||
| if (binding.cbSpoiler.isChecked) reasons.add("스포성 채팅") | ||
| if (binding.cbAbuse.isChecked) reasons.add("욕설") | ||
| if (binding.cbHate.isChecked) reasons.add("혐오 발언") | ||
| if (binding.cbNickname.isChecked) reasons.add("부적절한 닉네임 사용") | ||
|
|
||
| val extraReason = binding.etDetail.text.toString() | ||
|
|
||
| onSubmit(reasons, extraReason) | ||
| dismiss() | ||
| } | ||
|
|
||
| // Dialog 직접 생성 | ||
| val dialog = Dialog(requireContext()) | ||
| dialog.setContentView(binding.root) | ||
| dialog.window?.setBackgroundDrawableResource(android.R.color.transparent) | ||
| dialog.setCanceledOnTouchOutside(true) | ||
|
|
||
| // 다이얼로그 크기 고정 (피그마에서 요구한 크기) | ||
| dialog.window?.setLayout(320.dpToPx(), 494.dpToPx()) // dp → px 변환 필요 | ||
|
|
||
| return dialog | ||
| } | ||
|
|
||
| override fun onDestroyView() { | ||
| super.onDestroyView() | ||
| _binding = null | ||
| } | ||
| } | ||
|
|
||
| private fun Int.dpToPx(): Int { | ||
| return (this * Resources.getSystem().displayMetrics.density).toInt() | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
신고 클릭 시 AlertDialog로 레이아웃만 띄워 로직이 전혀 연결되지 않습니다. ReportDialogFragment를 사용해 데이터와 콜백을 연결하세요.
현재 showReportPopup()은 닉네임 타이틀/제출 액션/닫기 등이 동작하지 않습니다.
아래의 showReportDialog 구현 제안을 참고해 주세요.
🤖 Prompt for AI Agents