From 01e3f2d6b72c0566f39d345c97579c6849b8a37d Mon Sep 17 00:00:00 2001 From: emjayMJkim Date: Mon, 24 Jun 2024 19:18:51 +0900 Subject: [PATCH] =?UTF-8?q?#178=20[mod]=20theme=20Data=20class=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/entity/response/ThemeListResponse.kt | 12 +-- .../com/sopetit/softie/domain/entity/Theme.kt | 4 +- .../DailyRoutineAddThemeAdapter.kt | 7 +- .../themechoice/ChoiceThemeAdapter.kt | 6 +- .../themechoice/ChoiceThemeFragment.kt | 2 +- .../themechoice/ChoiceThemeViewModel.kt | 40 +++++---- .../layout/item_onboarding_choice_theme.xml | 87 +++++++++++-------- 7 files changed, 89 insertions(+), 69 deletions(-) diff --git a/app/src/main/java/com/sopetit/softie/data/entity/response/ThemeListResponse.kt b/app/src/main/java/com/sopetit/softie/data/entity/response/ThemeListResponse.kt index 77e3792e..92b78758 100644 --- a/app/src/main/java/com/sopetit/softie/data/entity/response/ThemeListResponse.kt +++ b/app/src/main/java/com/sopetit/softie/data/entity/response/ThemeListResponse.kt @@ -15,18 +15,18 @@ data class ThemeListResponse( val themeId: Int, @SerialName("name") val name: String, - @SerialName("iconImageUrl") - val iconImageUrl: String, - @SerialName("backgroundImageUrl") - val backgroundImageUrl: String + @SerialName("modifier") + val modifier: String, + @SerialName("description") + val description: String ) fun toTheme() = themes.map { Theme( themeId = it.themeId, name = it.name, - iconImageUrl = it.iconImageUrl, - backgroundImageUrl = it.backgroundImageUrl + modifier = it.modifier, + description = it.description ) } } diff --git a/app/src/main/java/com/sopetit/softie/domain/entity/Theme.kt b/app/src/main/java/com/sopetit/softie/domain/entity/Theme.kt index 9bc731a9..23ee838e 100644 --- a/app/src/main/java/com/sopetit/softie/domain/entity/Theme.kt +++ b/app/src/main/java/com/sopetit/softie/domain/entity/Theme.kt @@ -2,7 +2,7 @@ package com.sopetit.softie.domain.entity data class Theme( val themeId: Int, + val modifier: String, val name: String, - val iconImageUrl: String, - val backgroundImageUrl: String + val description: String ) diff --git a/app/src/main/java/com/sopetit/softie/ui/dailyroutine/dailyroutineadd/DailyRoutineAddThemeAdapter.kt b/app/src/main/java/com/sopetit/softie/ui/dailyroutine/dailyroutineadd/DailyRoutineAddThemeAdapter.kt index 15b00084..c61c2a85 100644 --- a/app/src/main/java/com/sopetit/softie/ui/dailyroutine/dailyroutineadd/DailyRoutineAddThemeAdapter.kt +++ b/app/src/main/java/com/sopetit/softie/ui/dailyroutine/dailyroutineadd/DailyRoutineAddThemeAdapter.kt @@ -9,7 +9,6 @@ import com.sopetit.softie.R import com.sopetit.softie.databinding.ItemDailyRoutineAddThemeBinding import com.sopetit.softie.domain.entity.Theme import com.sopetit.softie.util.ItemDiffCallback -import com.sopetit.softie.util.binding.BindingAdapter.setCoilImage import com.sopetit.softie.util.setSingleOnClickListener class DailyRoutineAddThemeAdapter : @@ -38,7 +37,7 @@ class DailyRoutineAddThemeAdapter : RecyclerView.ViewHolder(binding.root) { fun onBind(data: Theme) { binding.tvDailyRoutineAddThemeName.text = data.name - binding.ivDailyRoutineAddThemeIcon.setCoilImage(data.iconImageUrl) +// binding.ivDailyRoutineAddThemeIcon.setCoilImage(data.iconImageUrl) if (selectedPosition == absoluteAdapterPosition) { changeThemeBackground(binding, true) changeThemeTextColor(binding, true) @@ -57,7 +56,7 @@ class DailyRoutineAddThemeAdapter : selectedPosition = absoluteAdapterPosition } clickedThemeId = data.themeId - clickedThemeIcon = data.iconImageUrl +// clickedThemeIcon = data.iconImageUrl } } } @@ -113,7 +112,7 @@ class DailyRoutineAddThemeAdapter : } override fun onBindViewHolder(holder: DailyThemeViewHolder, position: Int) { - if (clickedThemeIcon == null) clickedThemeIcon = currentList[0].iconImageUrl +// if (clickedThemeIcon == null) clickedThemeIcon = currentList[0].iconImageUrl holder.onBind(currentList[position]) } } diff --git a/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeAdapter.kt b/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeAdapter.kt index 6711e492..728185c3 100644 --- a/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeAdapter.kt +++ b/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeAdapter.kt @@ -9,7 +9,6 @@ import com.sopetit.softie.databinding.ItemOnboardingChoiceThemeBinding import com.sopetit.softie.domain.entity.Theme import com.sopetit.softie.ui.onboarding.OnboardingActivity.Companion.MAXIMUM_THEME_SELECTION import com.sopetit.softie.util.ItemDiffCallback -import com.sopetit.softie.util.binding.BindingAdapter.setCoilImage import com.sopetit.softie.util.toast class ChoiceThemeAdapter : @@ -26,8 +25,9 @@ class ChoiceThemeAdapter : inner class ChoiceThemeViewHolder(private val binding: ItemOnboardingChoiceThemeBinding) : RecyclerView.ViewHolder(binding.root) { fun onBind(data: Theme) { - binding.tvThemeName.text = data.name - binding.ivThemeIcon.setCoilImage(data.iconImageUrl) + binding.item = data + // TODO 이미지 관련 재작업 예정 (동일 icon 재사용 위해 이전 pr 머지 후 작업) +// binding.ivThemeIcon.setCoilImage(data.iconImageUrl) binding.root.setOnClickListener { themeSelection(binding, data) onItemClickListener?.let { it(data) } diff --git a/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeFragment.kt b/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeFragment.kt index 5eda0789..492ed43e 100644 --- a/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeFragment.kt +++ b/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeFragment.kt @@ -37,7 +37,7 @@ class ChoiceThemeFragment : private fun initMakeThemeAdapter() { _choiceThemeAdapter = ChoiceThemeAdapter() - themeViewModel.getThemeList() +// themeViewModel.getThemeList() binding.rvOnboardingChoiceTheme.apply { layoutManager = GridLayoutManager(requireContext(), 3) adapter = choiceThemeAdapter diff --git a/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeViewModel.kt b/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeViewModel.kt index 83d271b5..37ec3738 100644 --- a/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeViewModel.kt +++ b/app/src/main/java/com/sopetit/softie/ui/onboarding/themechoice/ChoiceThemeViewModel.kt @@ -3,13 +3,10 @@ package com.sopetit.softie.ui.onboarding.themechoice import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope import com.sopetit.softie.domain.entity.Theme import com.sopetit.softie.domain.usecase.dailyroutine.GetThemeListUseCase import com.sopetit.softie.domain.usecase.doll.GetDollUseCase import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.launch -import timber.log.Timber import javax.inject.Inject @HiltViewModel @@ -18,7 +15,19 @@ class ChoiceThemeViewModel @Inject constructor( private val getThemeListUseCase: GetThemeListUseCase ) : ViewModel() { - private val _themeList = MutableLiveData>() + // private val _themeList = MutableLiveData>() + private val _themeList: MutableLiveData> = + MutableLiveData( + listOf( + Theme(1, "", "좋은 관계 만들기", ""), + Theme(2, "", "마음 챙기기", ""), + Theme(3, "", "통통한 통장 만들기", ""), + Theme(4, "", "산뜻한 일상 만들기", ""), + Theme(5, "", "한 걸음 성장하기", ""), + Theme(6, "", "건강한 몸 만들기", ""), + Theme(7, "", "나와 친해지기", ""), + ) + ) val themeList: LiveData> get() = _themeList @@ -26,17 +35,18 @@ class ChoiceThemeViewModel @Inject constructor( val themeBtnEnabled: LiveData get() = _themeBtnEnabled - fun getThemeList() { - viewModelScope.launch { - getThemeListUseCase.invoke() - .onSuccess { response -> - _themeList.value = response - Timber.d("서버 통신 성공 -> $response") - }.onFailure { - Timber.e("서버 통신 실패 -> ${it.message}") - } - } - } + // TODO 서버 연결 시 재작업 예정 +// fun getThemeList() { +// viewModelScope.launch { +// getThemeListUseCase.invoke() +// .onSuccess { response -> +// _themeList.value = response +// Timber.d("서버 통신 성공 -> $response") +// }.onFailure { +// Timber.e("서버 통신 실패 -> ${it.message}") +// } +// } +// } fun setThemeBtnEnabled(boolean: Boolean) { _themeBtnEnabled.value = boolean diff --git a/app/src/main/res/layout/item_onboarding_choice_theme.xml b/app/src/main/res/layout/item_onboarding_choice_theme.xml index 21e929f2..ff715078 100644 --- a/app/src/main/res/layout/item_onboarding_choice_theme.xml +++ b/app/src/main/res/layout/item_onboarding_choice_theme.xml @@ -1,41 +1,52 @@ - - - - - - - + + + + + + + + - - + android:paddingHorizontal="10dp"> + + + + + + + + +