@@ -3,6 +3,10 @@ package com.threegap.bitnagil.presentation.emotion.model
33import android.os.Parcelable
44import com.threegap.bitnagil.designsystem.R
55import com.threegap.bitnagil.domain.emotion.model.Emotion
6+ import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getMessage
7+ import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getOfflineBackupImageResourceId
8+ import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getSymbolBackgroundColor
9+ import com.threegap.bitnagil.presentation.emotion.model.EmotionUiModel.Companion.getSymbolColor
610import kotlinx.parcelize.Parcelize
711
812@Parcelize
@@ -16,19 +20,7 @@ data class EmotionUiModel(
1620 val symbolColor : Long = 0xFF878A93 ,
1721) : Parcelable {
1822 companion object {
19- fun fromDomain (emotion : Emotion ) = EmotionUiModel (
20- emotionType = emotion.emotionType,
21- emotionMarbleName = emotion.emotionMarbleName,
22- image = EmotionImageUiModel .Url (
23- url = emotion.imageUrl,
24- offlineBackupImageResourceId = getOfflineBackupImageResourceId(emotion.emotionType),
25- ),
26- message = getMessage(emotion.emotionType),
27- symbolBackgroundColor = getSymbolBackgroundColor(emotion.emotionType),
28- symbolColor = getSymbolColor(emotion.emotionType),
29- )
30-
31- private fun getOfflineBackupImageResourceId (emotionType : String ): Int? {
23+ fun getOfflineBackupImageResourceId (emotionType : String ): Int? {
3224 return when (emotionType) {
3325 " CALM" -> R .drawable.calm
3426 " VITALITY" -> R .drawable.vitality
@@ -40,7 +32,7 @@ data class EmotionUiModel(
4032 }
4133 }
4234
43- private fun getMessage (emotionType : String ): String? {
35+ fun getMessage (emotionType : String ): String? {
4436 return when (emotionType) {
4537 " CALM" -> " 평온함은 마음이 고요하고 편안해\n 균형을 이루는 상태에요."
4638 " VITALITY" -> " 활기참은 생기가 가득 차\n 활발하고 적극적인 상태예요."
@@ -52,7 +44,7 @@ data class EmotionUiModel(
5244 }
5345 }
5446
55- private fun getSymbolBackgroundColor (emotionType : String ): Long {
47+ fun getSymbolBackgroundColor (emotionType : String ): Long {
5648 return when (emotionType) {
5749 " CALM" -> 0xFFEFECFF
5850 " VITALITY" -> 0xFFE9FAD0
@@ -64,7 +56,7 @@ data class EmotionUiModel(
6456 }
6557 }
6658
67- private fun getSymbolColor (emotionType : String ): Long {
59+ fun getSymbolColor (emotionType : String ): Long {
6860 return when (emotionType) {
6961 " CALM" -> 0xFF692BD0
7062 " VITALITY" -> 0xFF609F00
@@ -87,3 +79,16 @@ data class EmotionUiModel(
8779 )
8880 }
8981}
82+
83+ internal fun Emotion.toUiModel (): EmotionUiModel =
84+ EmotionUiModel (
85+ emotionType = this .emotionType,
86+ emotionMarbleName = this .emotionMarbleName,
87+ image = EmotionImageUiModel .Url (
88+ url = this .imageUrl,
89+ offlineBackupImageResourceId = getOfflineBackupImageResourceId(this .emotionType),
90+ ),
91+ message = getMessage(this .emotionType),
92+ symbolBackgroundColor = getSymbolBackgroundColor(this .emotionType),
93+ symbolColor = getSymbolColor(this .emotionType),
94+ )
0 commit comments