Skip to content

Commit 38e6f65

Browse files
committed
Feat: RoutineDetailsCard 컴포넌트 기능 추가
- 삭제된 루틴일경우 수정버튼 제거 - 기간 표시 - 텍스트 간격 조정
1 parent b86184d commit 38e6f65

4 files changed

Lines changed: 46 additions & 14 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum class DayOfWeek {
3535
}
3636

3737
fun List<DayOfWeek>.formatRepeatDays(): String {
38-
if (this.isEmpty()) return "반복 없음"
38+
if (this.isEmpty()) return "x"
3939
return this.sortedBy { it.ordinal }
4040
.joinToString(", ") { it.toKoreanShort() }
4141
}

presentation/src/main/java/com/threegap/bitnagil/presentation/home/util/LocalDateExtension.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ private val koreanLocale = Locale.KOREAN
1111
private val monthYearFormatter = DateTimeFormatter.ofPattern("yyyy년 M월", koreanLocale)
1212
private val executionTimeFormatter12 = DateTimeFormatter.ofPattern("a h:mm", koreanLocale)
1313
private val executionTimeFormatter24 = DateTimeFormatter.ofPattern("HH:mm", koreanLocale)
14+
private val shortDateFormatter = DateTimeFormatter.ofPattern("yy.MM.dd")
1415

1516
fun LocalDate.getCurrentWeekDays(): List<LocalDate> =
1617
(0..6).map { this.with(DayOfWeek.MONDAY).plusDays(it.toLong()) }
@@ -47,3 +48,11 @@ fun String.formatExecutionTime12Hour(): String =
4748
} catch (e: Exception) {
4849
"시간 미정"
4950
}
51+
52+
fun String.toShortDateFormat(): String =
53+
try {
54+
val date = LocalDate.parse(this)
55+
date.format(shortDateFormatter)
56+
} catch (e: Exception) {
57+
this
58+
}

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.compose.material3.Text
1414
import androidx.compose.runtime.Composable
1515
import androidx.compose.ui.Alignment
1616
import androidx.compose.ui.Modifier
17+
import androidx.compose.ui.text.style.LineHeightStyle
1718
import androidx.compose.ui.tooling.preview.Preview
1819
import androidx.compose.ui.unit.dp
1920
import com.threegap.bitnagil.designsystem.BitnagilTheme
@@ -33,6 +34,13 @@ fun RoutineDetailsCard(
3334
onDeleteClick: () -> Unit,
3435
modifier: Modifier = Modifier,
3536
) {
37+
val infoTextStyle = BitnagilTheme.typography.body2Medium.copy(
38+
lineHeightStyle = LineHeightStyle(
39+
alignment = LineHeightStyle.Alignment.Center,
40+
trim = LineHeightStyle.Trim.None,
41+
),
42+
)
43+
3644
Column(
3745
modifier = modifier
3846
.background(
@@ -67,12 +75,14 @@ fun RoutineDetailsCard(
6775

6876
Spacer(modifier = Modifier.weight(1f))
6977

70-
BitnagilIconButton(
71-
id = R.drawable.ic_edit,
72-
onClick = onEditClick,
73-
tint = null,
74-
paddingValues = PaddingValues(12.dp),
75-
)
78+
if (!routine.routineDeletedYn) {
79+
BitnagilIconButton(
80+
id = R.drawable.ic_edit,
81+
onClick = onEditClick,
82+
tint = null,
83+
paddingValues = PaddingValues(12.dp),
84+
)
85+
}
7686

7787
BitnagilIconButton(
7888
id = R.drawable.ic_trash,
@@ -97,14 +107,14 @@ fun RoutineDetailsCard(
97107
Text(
98108
text = "세부 루틴",
99109
color = BitnagilTheme.colors.coolGray40,
100-
style = BitnagilTheme.typography.body2Medium,
110+
style = infoTextStyle,
101111
)
102112

103113
routine.subRoutineNames.forEach { name ->
104114
Text(
105115
text = "$name",
106116
color = BitnagilTheme.colors.coolGray40,
107-
style = BitnagilTheme.typography.body2Medium,
117+
style = infoTextStyle,
108118
)
109119
}
110120
}
@@ -124,17 +134,17 @@ fun RoutineDetailsCard(
124134
Text(
125135
text = "반복: ${routine.repeatDay.formatRepeatDays()}",
126136
color = BitnagilTheme.colors.coolGray40,
127-
style = BitnagilTheme.typography.body2Medium,
137+
style = infoTextStyle,
128138
)
129139
Text(
130-
text = "기간: ",
140+
text = "기간: ${routine.formattedDateRange}",
131141
color = BitnagilTheme.colors.coolGray40,
132-
style = BitnagilTheme.typography.body2Medium,
142+
style = infoTextStyle,
133143
)
134144
Text(
135145
text = "시간: ${routine.executionTime}",
136146
color = BitnagilTheme.colors.coolGray40,
137-
style = BitnagilTheme.typography.body2Medium,
147+
style = infoTextStyle,
138148
)
139149
}
140150
}
@@ -150,6 +160,9 @@ private fun RoutineDetailsCardPreview() {
150160
repeatDay = listOf(DayOfWeek.MONDAY, DayOfWeek.TUESDAY),
151161
executionTime = "00:00:00",
152162
routineDate = "2025-08-15",
163+
startDate = "2025-08-15",
164+
endDate = "2025-08-25",
165+
routineDeletedYn = false,
153166
subRoutineNames = listOf("어쩌구", "저쩌구", "얼씨구"),
154167
recommendedRoutineType = null,
155168
),

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.threegap.bitnagil.domain.routine.model.DayOfWeek
99
import com.threegap.bitnagil.domain.routine.model.RecommendedRoutineType
1010
import com.threegap.bitnagil.domain.routine.model.Routine
1111
import com.threegap.bitnagil.presentation.home.util.formatExecutionTime12Hour
12+
import com.threegap.bitnagil.presentation.home.util.toShortDateFormat
1213
import kotlinx.parcelize.Parcelize
1314

1415
@Parcelize
@@ -18,9 +19,15 @@ data class RoutineUiModel(
1819
val repeatDay: List<DayOfWeek>,
1920
val executionTime: String,
2021
val routineDate: String,
22+
val startDate: String,
23+
val endDate: String,
24+
val routineDeletedYn: Boolean,
2125
val subRoutineNames: List<String>,
2226
val recommendedRoutineType: RecommendedRoutineType?,
23-
) : Parcelable
27+
) : Parcelable {
28+
val formattedDateRange: String
29+
get() = "${startDate.toShortDateFormat()} - ${endDate.toShortDateFormat()}"
30+
}
2431

2532
fun Routine.toUiModel(): RoutineUiModel =
2633
RoutineUiModel(
@@ -29,6 +36,9 @@ fun Routine.toUiModel(): RoutineUiModel =
2936
repeatDay = this.repeatDay,
3037
executionTime = this.executionTime.formatExecutionTime12Hour(),
3138
routineDate = this.routineDate,
39+
startDate = this.startDate,
40+
endDate = this.endDate,
41+
routineDeletedYn = this.routineDeletedYn,
3242
subRoutineNames = this.subRoutineNames,
3343
recommendedRoutineType = this.recommendedRoutineType,
3444
)

0 commit comments

Comments
 (0)