Skip to content

Commit

Permalink
viewModel 상호작용 위치 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hjh1161514 committed Oct 15, 2023
1 parent 5ef11ed commit de197b2
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.InsetDrawable
import android.os.Bundle
import android.util.Log
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
Expand All @@ -23,15 +24,14 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.official.core.lifecycle.viewLifeCycle
import org.sopt.official.core.lifecycle.viewLifeCycleScope
import org.sopt.official.databinding.DialogAttendanceCodeBinding
import org.sopt.official.feature.attendance.model.DialogState

class AttendanceCodeDialog : DialogFragment() {
private var _binding: DialogAttendanceCodeBinding? = null
private val binding: DialogAttendanceCodeBinding get() = requireNotNull(_binding)
private val viewModel: AttendanceViewModel by activityViewModels()
private lateinit var dialogTitle: String

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -66,15 +66,16 @@ class AttendanceCodeDialog : DialogFragment() {
}

fun setTitle(title: String): AttendanceCodeDialog {
viewModel.initDialogTitle(title)
dialogTitle = title
return this
}

private fun initTitle() {
viewModel.initDialogTitle(dialogTitle)
viewModel.title
.flowWithLifecycle(viewLifeCycle)
.flowWithLifecycle(viewLifecycleOwner.lifecycle)
.onEach { binding.tvAttendanceCodeDialogTitle.text = "${it.substring(0, 5)}하기" }
.launchIn(viewLifeCycleScope)
.launchIn(viewLifecycleOwner.lifecycleScope)
}

private fun initListener() {
Expand Down Expand Up @@ -193,7 +194,7 @@ class AttendanceCodeDialog : DialogFragment() {
}

override fun dismiss() {
viewModel.initDialogState()
viewModel.initDialogState()
super.dismiss()
}

Expand Down

0 comments on commit de197b2

Please sign in to comment.