From e479f7f27bfb8f7868a5045996d3e44824b8574c Mon Sep 17 00:00:00 2001 From: ss99x2002 Date: Tue, 11 Jul 2023 23:21:05 +0900 Subject: [PATCH] =?UTF-8?q?[Feat/#47]=20dialog=20post=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=9E=84=EC=8B=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/qna/ConfirmAnswerDialogFragment.kt | 12 +++++++++--- .../qna/ConfirmAnswerDialogFragmentViewModel.kt | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragmentViewModel.kt diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt b/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt index 127ba849..1f0dc490 100644 --- a/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt +++ b/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragment.kt @@ -10,6 +10,7 @@ import android.view.View import android.view.ViewGroup import android.view.WindowManager import androidx.fragment.app.DialogFragment +import androidx.fragment.app.viewModels import com.sopt.umbba_android.R import com.sopt.umbba_android.databinding.FragmentConfirmAnswerDialogBinding import timber.log.Timber @@ -17,6 +18,7 @@ import timber.log.Timber class ConfirmAnswerDialogFragment : DialogFragment() { private var _binding: FragmentConfirmAnswerDialogBinding? = null + private val confirmAnswerDialogViewModel by viewModels() private val binding get() = requireNotNull(_binding) { "ConfirmAnswerDialogFragment is null" } override fun onCreateView( @@ -30,12 +32,16 @@ class ConfirmAnswerDialogFragment : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) setBackgroundDesign() - setBtnClickEvent() setPreviewAnswer() + setBtnClickEvent() } private fun setPreviewAnswer() { - binding.tvAnswer.text = arguments?.getString("ConfirmAnswerText") + with(binding) { + tvAnswer.text = arguments?.getString("answer") + tvTitle.text = arguments?.getString("title") + tvTopic.text = arguments?.getString("topic") + } } private fun setBackgroundDesign() { @@ -49,7 +55,7 @@ class ConfirmAnswerDialogFragment : DialogFragment() { } btnConfirm.setOnClickListener { dismiss() - //TODO(답변 내용 POST API 연결 부분) + confirmAnswerDialogViewModel.postAnswer(tvAnswer.text.toString()) } } } diff --git a/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragmentViewModel.kt b/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragmentViewModel.kt new file mode 100644 index 00000000..f243e7ba --- /dev/null +++ b/app/src/main/java/com/sopt/umbba_android/presentation/qna/ConfirmAnswerDialogFragmentViewModel.kt @@ -0,0 +1,9 @@ +package com.sopt.umbba_android.presentation.qna + +import androidx.lifecycle.ViewModel + +class ConfirmAnswerDialogFragmentViewModel : ViewModel() { + fun postAnswer(answer: String) { + //TODO(post Repo로 가는 함수 가보자고.) + } +} \ No newline at end of file