Skip to content

Commit 8d12ab7

Browse files
committed
Refactor: RoutineItem 파라미터 변경
- 기존 RoutineUiModel에서 사용하는 프로퍼티만을 전달하도록 변경
1 parent 02db0f7 commit 8d12ab7

2 files changed

Lines changed: 37 additions & 77 deletions

File tree

presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/block/RoutineItem.kt

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import com.threegap.bitnagil.designsystem.BitnagilTheme
1919
import com.threegap.bitnagil.designsystem.R
2020
import com.threegap.bitnagil.designsystem.component.atom.BitnagilIcon
2121
import com.threegap.bitnagil.designsystem.modifier.clickableWithoutRipple
22-
import com.threegap.bitnagil.presentation.home.model.RoutineUiModel
2322

2423
@Composable
2524
fun RoutineItem(
26-
routine: RoutineUiModel,
25+
name: String,
26+
isCompleted: Boolean,
27+
subRoutineNames: List<String>,
28+
subRoutineIsCompleted: List<Boolean>,
2729
onRoutineToggle: () -> Unit,
2830
onSubRoutineToggle: (Int) -> Unit,
2931
modifier: Modifier = Modifier,
@@ -48,31 +50,31 @@ fun RoutineItem(
4850
verticalAlignment = Alignment.CenterVertically,
4951
) {
5052
Text(
51-
text = routine.name,
53+
text = name,
5254
style = BitnagilTheme.typography.body1SemiBold,
5355
color = BitnagilTheme.colors.coolGray10,
5456
modifier = Modifier.weight(1f),
5557
)
5658

5759
BitnagilIcon(
58-
id = if (routine.isCompleted) R.drawable.ic_check_circle else R.drawable.ic_check_default,
60+
id = if (isCompleted) R.drawable.ic_check_circle else R.drawable.ic_check_default,
5961
tint = null,
6062
modifier = Modifier
6163
.padding(start = 10.dp)
6264
.size(28.dp),
6365
)
6466
}
6567

66-
if (routine.subRoutineNames.isNotEmpty()) {
68+
if (subRoutineNames.isNotEmpty()) {
6769
HorizontalDivider(
6870
thickness = 1.dp,
6971
color = BitnagilTheme.colors.coolGray97,
7072
modifier = Modifier.padding(vertical = 10.dp),
7173
)
7274

7375
SubRoutinesItem(
74-
subRoutineNames = routine.subRoutineNames,
75-
subRoutineCompleteYn = routine.subRoutineIsCompleted,
76+
subRoutineNames = subRoutineNames,
77+
subRoutineCompleteYn = subRoutineIsCompleted,
7678
onSubRoutineToggle = { index -> onSubRoutineToggle(index) },
7779
)
7880
}
@@ -83,17 +85,10 @@ fun RoutineItem(
8385
@Composable
8486
private fun RoutineItemPreview() {
8587
RoutineItem(
86-
routine = RoutineUiModel(
87-
id = "uuid1",
88-
name = "개운하게 일어나기",
89-
repeatDays = emptyList(),
90-
executionTime = "20:30:00",
91-
routineDate = "2025-08-15",
92-
isCompleted = false,
93-
subRoutineNames = listOf("물 마시기", "스트레칭하기", "심호흡하기"),
94-
subRoutineIsCompleted = listOf(true, false, true),
95-
recommendedRoutineType = null,
96-
),
88+
name = "개운하게 일어나기",
89+
isCompleted = false,
90+
subRoutineNames = listOf("물 마시기", "스트레칭하기", "심호흡하기"),
91+
subRoutineIsCompleted = listOf(true, false, true),
9792
onRoutineToggle = { },
9893
onSubRoutineToggle = { _ -> },
9994
)
@@ -103,17 +98,10 @@ private fun RoutineItemPreview() {
10398
@Composable
10499
private fun NoneSubRoutineRoutineItemPreview() {
105100
RoutineItem(
106-
routine = RoutineUiModel(
107-
id = "uuid1",
108-
name = "개운하게 일어나기",
109-
repeatDays = emptyList(),
110-
executionTime = "20:30:00",
111-
routineDate = "2025-08-15",
112-
isCompleted = false,
113-
subRoutineNames = emptyList(),
114-
subRoutineIsCompleted = emptyList(),
115-
recommendedRoutineType = null,
116-
),
101+
name = "개운하게 일어나기",
102+
isCompleted = false,
103+
subRoutineNames = emptyList(),
104+
subRoutineIsCompleted = emptyList(),
117105
onRoutineToggle = {},
118106
onSubRoutineToggle = { _ -> },
119107
)

presentation/src/main/java/com/threegap/bitnagil/presentation/home/component/template/RoutineSection.kt

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.compose.ui.Modifier
1010
import androidx.compose.ui.tooling.preview.Preview
1111
import androidx.compose.ui.unit.dp
1212
import com.threegap.bitnagil.designsystem.BitnagilTheme
13+
import com.threegap.bitnagil.domain.routine.model.DayOfWeek
1314
import com.threegap.bitnagil.presentation.home.component.block.RoutineItem
1415
import com.threegap.bitnagil.presentation.home.model.RoutineUiModel
1516
import com.threegap.bitnagil.presentation.home.util.formatExecutionTime24Hour
@@ -33,7 +34,10 @@ fun RoutineSection(
3334
)
3435

3536
RoutineItem(
36-
routine = routine,
37+
name = routine.name,
38+
isCompleted = routine.isCompleted,
39+
subRoutineNames = routine.subRoutineNames,
40+
subRoutineIsCompleted = routine.subRoutineIsCompleted,
3741
onRoutineToggle = onRoutineToggle,
3842
onSubRoutineToggle = onSubRoutineToggle,
3943
modifier = Modifier.fillMaxWidth(),
@@ -44,51 +48,19 @@ fun RoutineSection(
4448
@Preview(showBackground = true)
4549
@Composable
4650
private fun RoutineSectionPreview() {
47-
// RoutineSection(
48-
// routine = RoutineUiModel(
49-
// routineId = "uuid1",
50-
// routineName = "개운하게 일어나기",
51-
// executionTime = "20:30:00",
52-
// routineCompletionId = 1,
53-
// isCompleted = false,
54-
// isModified = false,
55-
// subRoutines = listOf(
56-
// SubRoutineUiModel(
57-
// subRoutineId = "uuid1",
58-
// historySeq = 1,
59-
// subRoutineName = "물 마시기",
60-
// sortOrder = 1,
61-
// routineCompletionId = 1,
62-
// isCompleted = false,
63-
// isModified = false,
64-
// routineType = RoutineType.SUB_ROUTINE,
65-
// ),
66-
// SubRoutineUiModel(
67-
// subRoutineId = "uuid2",
68-
// historySeq = 1,
69-
// subRoutineName = "스트레칭하기",
70-
// sortOrder = 1,
71-
// routineCompletionId = 1,
72-
// isCompleted = false,
73-
// isModified = false,
74-
// routineType = RoutineType.SUB_ROUTINE,
75-
// ),
76-
// SubRoutineUiModel(
77-
// subRoutineId = "uuid3",
78-
// historySeq = 1,
79-
// subRoutineName = "심호흡하기",
80-
// sortOrder = 1,
81-
// routineCompletionId = 1,
82-
// isCompleted = false,
83-
// isModified = false,
84-
// routineType = RoutineType.SUB_ROUTINE,
85-
// ),
86-
// ),
87-
// historySeq = 1,
88-
// repeatDay = listOf(),
89-
// routineType = RoutineType.ROUTINE,
90-
// ),
91-
// onRoutineToggle = {},
92-
// onSubRoutineToggle = { _, _ -> },
93-
// )
51+
RoutineSection(
52+
routine = RoutineUiModel(
53+
id = "1",
54+
name = "개운하게 일어나기",
55+
repeatDays = listOf(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY),
56+
executionTime = "08:00",
57+
routineDate = "2023-10-27",
58+
isCompleted = false,
59+
subRoutineNames = listOf("Make bed", "Brush teeth", "Meditate"),
60+
subRoutineIsCompleted = listOf(true, false, false),
61+
recommendedRoutineType = null
62+
),
63+
onRoutineToggle = {},
64+
onSubRoutineToggle = {}
65+
)
9466
}

0 commit comments

Comments
 (0)