diff --git a/presentation/src/main/java/com/going/presentation/profile/participant/ParticipantProfileViewModel.kt b/presentation/src/main/java/com/going/presentation/profile/participant/ParticipantProfileViewModel.kt index 53ab17bb..ee30f872 100644 --- a/presentation/src/main/java/com/going/presentation/profile/participant/ParticipantProfileViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/profile/participant/ParticipantProfileViewModel.kt @@ -2,6 +2,7 @@ package com.going.presentation.profile.participant import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.going.domain.entity.ProfilePreferenceData import com.going.domain.entity.request.ParticipantProfileRequestModel import com.going.domain.entity.response.ParticipantProfileResponseModel import com.going.domain.repository.ProfileRepository @@ -36,4 +37,12 @@ class ParticipantProfileViewModel @Inject constructor( } } } + + fun setPreferenceData(styleA: Int, styleB: Int, styleC: Int, styleD: Int, styleE: Int) = listOf( + ProfilePreferenceData("01", "계획은 어느 정도로 세울까요?", "철저하게", "즉흥으로", styleA), + ProfilePreferenceData("02", "장소 선택의 기준은 무엇인가요?", "관광지", "로컬장소", styleB), + ProfilePreferenceData("03", "어느 식당을 갈까요?", "유명 맛집", "가까운 곳", styleC), + ProfilePreferenceData("04", "기억하고 싶은 순간에!", "사진필수", "눈에 담기", styleD), + ProfilePreferenceData("05", "하루 일정을 어떻게 채우나요?", "알차게", "여유롭게", styleE) + ) } \ No newline at end of file diff --git a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/ParticipantProfileTagFragment.kt b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/ParticipantProfileTagFragment.kt index 41ae8d6c..521a9378 100644 --- a/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/ParticipantProfileTagFragment.kt +++ b/presentation/src/main/java/com/going/presentation/profile/participant/profiletag/ParticipantProfileTagFragment.kt @@ -3,7 +3,6 @@ package com.going.presentation.profile.participant.profiletag import android.os.Bundle import android.view.View import androidx.core.view.isVisible -import androidx.fragment.app.activityViewModels import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -25,8 +24,6 @@ class ParticipantProfileTagFragment : ViewModelProvider(requireActivity())[ParticipantProfileViewModel::class.java] } - private val tagViewModel by activityViewModels() - private var _adapter: ParticipantProfileTagAdapter? = null private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) } @@ -36,14 +33,7 @@ class ParticipantProfileTagFragment : initAdapter() getPreferenceIndex() initItemDecoration() - } - - override fun onResume() { - super.onResume() - - participantViewModel.participantProfile.flowWithLifecycle(lifecycle).onEach { - getPreferenceIndex() - }.launchIn(lifecycleScope) + observePreferenceChange() } private fun initAdapter() { @@ -54,7 +44,7 @@ class ParticipantProfileTagFragment : private fun getPreferenceIndex() { participantViewModel.profileTmp.run { adapter.submitList( - tagViewModel.setPreferenceData( + participantViewModel.setPreferenceData( styleA, styleB, styleC, @@ -97,6 +87,12 @@ class ParticipantProfileTagFragment : binding.rvPreferenceTag.addItemDecoration(itemDeco) } + private fun observePreferenceChange() { + participantViewModel.participantProfile.flowWithLifecycle(lifecycle).onEach { + getPreferenceIndex() + }.launchIn(lifecycleScope) + } + fun scrollTop() = binding.nsvPreferenceTag.scrollTo(0, 0) }