Skip to content

Commit 0d18c1c

Browse files
committed
Refactor: 추천루틴 타입 추가
1 parent 4215a8d commit 0d18c1c

5 files changed

Lines changed: 55 additions & 13 deletions

File tree

data/src/main/java/com/threegap/bitnagil/data/recommendroutine/model/response/RecommendedRoutineDto.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.threegap.bitnagil.data.recommendroutine.model.response
22

3+
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory
34
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel
45
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutine
56
import kotlinx.serialization.SerialName
@@ -17,6 +18,8 @@ data class RecommendedRoutineDto(
1718
val recommendedRoutineLevel: String,
1819
@SerialName("executionTime")
1920
val executionTime: String,
21+
@SerialName("recommendedRoutineType")
22+
val recommendedRoutineType: String,
2023
@SerialName("recommendedSubRoutineSearchResult")
2124
val recommendedSubRoutineSearchResult: List<RecommendedSubRoutineDto>,
2225
)
@@ -28,5 +31,6 @@ fun RecommendedRoutineDto.toDomain(): RecommendRoutine =
2831
description = recommendedRoutineDescription,
2932
level = RecommendLevel.fromString(recommendedRoutineLevel),
3033
executionTime = executionTime,
34+
recommendedRoutineType = RecommendCategory.fromString(recommendedRoutineType),
3135
recommendSubRoutines = recommendedSubRoutineSearchResult.map { it.toDomain() },
3236
)

domain/src/main/java/com/threegap/bitnagil/domain/recommendroutine/model/RecommendRoutine.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ data class RecommendRoutine(
66
val description: String,
77
val level: RecommendLevel,
88
val executionTime: String,
9+
val recommendedRoutineType: RecommendCategory,
910
val recommendSubRoutines: List<RecommendSubRoutine>,
1011
)

presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendRoutineState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ data class RecommendRoutineState(
1515
val selectedRecommendLevel: RecommendLevel? = null,
1616
val emotionMarbleType: EmotionMarbleType? = null,
1717
) : MviState {
18-
val isDefaultCategory: Boolean
19-
get() = selectedCategory == RecommendCategory.PERSONALIZED
18+
val shouldShowEmotionButton: Boolean
19+
get() = selectedCategory == RecommendCategory.PERSONALIZED && emotionMarbleType == null
2020
}
Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,63 @@
11
package com.threegap.bitnagil.presentation.recommendroutine.model
22

33
import android.os.Parcelable
4+
import androidx.compose.runtime.Composable
5+
import androidx.compose.ui.graphics.Color
6+
import com.threegap.bitnagil.designsystem.BitnagilTheme
7+
import com.threegap.bitnagil.designsystem.R
8+
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendCategory
49
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel
10+
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel.LEVEL1
11+
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel.LEVEL2
12+
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendLevel.LEVEL3
513
import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutine
614
import kotlinx.parcelize.Parcelize
715

816
@Parcelize
917
data class RecommendRoutineUiModel(
10-
val id: Int,
11-
val name: String,
12-
val description: String,
13-
val level: RecommendLevel,
14-
val executionTime: String,
15-
val recommendSubRoutines: List<RecommendSubRoutineUiModel>,
16-
) : Parcelable
18+
val id: Int = 0,
19+
val name: String = "",
20+
val level: RecommendLevel? = null,
21+
val recommendedRoutineType: RecommendCategory? = null,
22+
val recommendSubRoutines: List<RecommendSubRoutineUiModel> = emptyList(),
23+
) : Parcelable {
24+
val icon: Int
25+
get() = recommendedRoutineType?.getIcon() ?: R.drawable.ic_shine
26+
27+
val color: Color
28+
@Composable get() = recommendedRoutineType?.getColor() ?: BitnagilTheme.colors.yellow10
29+
}
1730

1831
fun RecommendRoutine.toUiModel() =
1932
RecommendRoutineUiModel(
2033
id = this.id,
2134
name = this.name,
22-
description = this.description,
2335
level = this.level,
24-
executionTime = this.executionTime,
36+
recommendedRoutineType = this.recommendedRoutineType,
2537
recommendSubRoutines = this.recommendSubRoutines.map { it.toUiModel() },
2638
)
39+
40+
private fun RecommendCategory.getIcon(): Int =
41+
when (this) {
42+
RecommendCategory.OUTING -> R.drawable.ic_outside
43+
RecommendCategory.WAKE_UP -> R.drawable.ic_wakeup
44+
RecommendCategory.CONNECT -> R.drawable.ic_connect
45+
RecommendCategory.REST -> R.drawable.ic_rest
46+
RecommendCategory.GROW -> R.drawable.ic_grow
47+
RecommendCategory.PERSONALIZED -> R.drawable.ic_shine
48+
RecommendCategory.OUTING_REPORT -> R.drawable.ic_shine
49+
RecommendCategory.UNKNOWN -> R.drawable.ic_shine
50+
}
51+
52+
@Composable
53+
private fun RecommendCategory.getColor(): Color =
54+
when (this) {
55+
RecommendCategory.OUTING -> BitnagilTheme.colors.skyBlue10
56+
RecommendCategory.WAKE_UP -> BitnagilTheme.colors.orange25
57+
RecommendCategory.CONNECT -> BitnagilTheme.colors.purple10
58+
RecommendCategory.REST -> BitnagilTheme.colors.green10
59+
RecommendCategory.GROW -> BitnagilTheme.colors.pink10
60+
RecommendCategory.PERSONALIZED -> BitnagilTheme.colors.yellow10
61+
RecommendCategory.OUTING_REPORT -> BitnagilTheme.colors.yellow10
62+
RecommendCategory.UNKNOWN -> BitnagilTheme.colors.yellow10
63+
}

presentation/src/main/java/com/threegap/bitnagil/presentation/recommendroutine/model/RecommendSubRoutineUiModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import kotlinx.parcelize.Parcelize
66

77
@Parcelize
88
data class RecommendSubRoutineUiModel(
9-
val id: Int,
10-
val name: String,
9+
val id: Int = 0,
10+
val name: String = "",
1111
) : Parcelable
1212

1313
fun RecommendSubRoutine.toUiModel() =

0 commit comments

Comments
 (0)