|
1 | 1 | package com.threegap.bitnagil.presentation.recommendroutine.model |
2 | 2 |
|
3 | 3 | 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 |
4 | 9 | 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 |
5 | 13 | import com.threegap.bitnagil.domain.recommendroutine.model.RecommendRoutine |
6 | 14 | import kotlinx.parcelize.Parcelize |
7 | 15 |
|
8 | 16 | @Parcelize |
9 | 17 | 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 | +} |
17 | 30 |
|
18 | 31 | fun RecommendRoutine.toUiModel() = |
19 | 32 | RecommendRoutineUiModel( |
20 | 33 | id = this.id, |
21 | 34 | name = this.name, |
22 | | - description = this.description, |
23 | 35 | level = this.level, |
24 | | - executionTime = this.executionTime, |
| 36 | + recommendedRoutineType = this.recommendedRoutineType, |
25 | 37 | recommendSubRoutines = this.recommendSubRoutines.map { it.toUiModel() }, |
26 | 38 | ) |
| 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 | + } |
0 commit comments