Skip to content

Commit dc7494d

Browse files
committed
Feat: RoutineDetailsCard 컴포넌트 아이콘 분기 추가
- 추천 카테고리에 따른 아이콘과 배경색을 가지도록 구현
1 parent 5b2dcce commit dc7494d

3 files changed

Lines changed: 35 additions & 7 deletions

File tree

domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RecommendedRoutineType.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ enum class RecommendedRoutineType {
88
REST,
99
GROW,
1010
OUTING_REPORT,
11-
UNKNOWN,
1211
;
1312

1413
companion object {
15-
fun fromString(categoryName: String?): RecommendedRoutineType =
16-
RecommendedRoutineType.entries.find { it.name == categoryName } ?: UNKNOWN
14+
fun fromString(categoryName: String?): RecommendedRoutineType? =
15+
RecommendedRoutineType.entries.find { it.name == categoryName }
1716
}
1817
}

presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/component/template/RoutineDetailsCard.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import com.threegap.bitnagil.designsystem.component.atom.BitnagilIconButton
2323
import com.threegap.bitnagil.domain.routine.model.DayOfWeek
2424
import com.threegap.bitnagil.domain.routine.model.DayOfWeek.Companion.formatRepeatDays
2525
import com.threegap.bitnagil.presentation.routinelist.model.RoutineUiModel
26+
import com.threegap.bitnagil.presentation.routinelist.model.getColor
27+
import com.threegap.bitnagil.presentation.routinelist.model.getIcon
2628

2729
@Composable
2830
fun RoutineDetailsCard(
@@ -46,11 +48,11 @@ fun RoutineDetailsCard(
4648
verticalAlignment = Alignment.CenterVertically,
4749
) {
4850
BitnagilIcon(
49-
id = R.drawable.ic_check_circle_orange,
51+
id = if (routine.recommendedRoutineType != null) routine.recommendedRoutineType.getIcon() else R.drawable.ic_shine,
5052
tint = null,
5153
modifier = Modifier
5254
.background(
53-
color = BitnagilTheme.colors.orange25,
55+
color = if (routine.recommendedRoutineType != null) routine.recommendedRoutineType.getColor() else BitnagilTheme.colors.yellow10,
5456
shape = RoundedCornerShape(4.dp),
5557
)
5658
.padding(4.dp),
@@ -146,7 +148,7 @@ private fun RoutineDetailsCardPreview() {
146148
routineId = "1",
147149
routineName = "야무진 루틴",
148150
repeatDay = listOf(DayOfWeek.MONDAY, DayOfWeek.TUESDAY),
149-
executionTime = "12:00:00",
151+
executionTime = "00:00:00",
150152
routineDate = "2025-08-15",
151153
subRoutineNames = listOf("어쩌구", "저쩌구", "얼씨구"),
152154
recommendedRoutineType = null,

presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/model/RoutineUiModel.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.threegap.bitnagil.presentation.routinelist.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
48
import com.threegap.bitnagil.domain.routine.model.DayOfWeek
59
import com.threegap.bitnagil.domain.routine.model.RecommendedRoutineType
610
import com.threegap.bitnagil.domain.routine.model.Routine
@@ -22,8 +26,31 @@ fun Routine.toUiModel(): RoutineUiModel =
2226
routineId = this.routineId,
2327
routineName = this.routineName,
2428
repeatDay = this.repeatDay,
25-
executionTime = this.executionTime,
29+
executionTime = this.formattedExecutionTime,
2630
routineDate = this.routineDate,
2731
subRoutineNames = this.subRoutineNames,
2832
recommendedRoutineType = this.recommendedRoutineType,
2933
)
34+
35+
fun RecommendedRoutineType.getIcon(): Int =
36+
when (this) {
37+
RecommendedRoutineType.OUTING -> R.drawable.ic_outside
38+
RecommendedRoutineType.WAKE_UP -> R.drawable.ic_wakeup
39+
RecommendedRoutineType.CONNECT -> R.drawable.ic_connect
40+
RecommendedRoutineType.REST -> R.drawable.ic_rest
41+
RecommendedRoutineType.GROW -> R.drawable.ic_grow
42+
RecommendedRoutineType.PERSONALIZED -> R.drawable.ic_shine
43+
RecommendedRoutineType.OUTING_REPORT -> R.drawable.ic_shine
44+
}
45+
46+
@Composable
47+
fun RecommendedRoutineType.getColor(): Color =
48+
when (this) {
49+
RecommendedRoutineType.OUTING -> BitnagilTheme.colors.skyBlue10
50+
RecommendedRoutineType.WAKE_UP -> BitnagilTheme.colors.orange25
51+
RecommendedRoutineType.CONNECT -> BitnagilTheme.colors.purple10
52+
RecommendedRoutineType.REST -> BitnagilTheme.colors.green10
53+
RecommendedRoutineType.GROW -> BitnagilTheme.colors.pink10
54+
RecommendedRoutineType.PERSONALIZED -> BitnagilTheme.colors.yellow10
55+
RecommendedRoutineType.OUTING_REPORT -> BitnagilTheme.colors.yellow10
56+
}

0 commit comments

Comments
 (0)