Skip to content

Commit 7683598

Browse files
committed
ui: TodoDetailView의 시트를 TodoEditorView의 시트 형태로 변경
1 parent dde53d3 commit 7683598

2 files changed

Lines changed: 96 additions & 8 deletions

File tree

DevLog/UI/Home/TodoDetailView.swift

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,104 @@ struct TodoDetailView: View {
7070
@ViewBuilder
7171
private var sheetContent: some View {
7272
if let todo = viewModel.state.todo {
73-
TodoInfoSheetView(
74-
createdAt: todo.createdAt,
75-
completedAt: todo.completedAt,
76-
dueDate: todo.dueDate,
77-
tags: todo.tags
78-
) {
73+
TodoDetailInfoSheetView(todo: todo) {
7974
viewModel.send(.setShowInfo(false))
8075
}
8176
}
8277
}
8378
}
79+
80+
private struct TodoDetailInfoSheetView: View {
81+
let todo: Todo
82+
let onClose: () -> Void
83+
private let calendar = Calendar.current
84+
85+
var body: some View {
86+
NavigationStack {
87+
List {
88+
Section("옵션") {
89+
HStack {
90+
Text("카테고리")
91+
Spacer()
92+
Text(todo.kind.localizedName)
93+
.foregroundStyle(.secondary)
94+
}
95+
96+
statusRow(
97+
title: "완료",
98+
systemImage: todo.isCompleted ? "checkmark.circle.fill" : "circle",
99+
color: todo.isCompleted ? .green : .secondary
100+
)
101+
102+
statusRow(
103+
title: "중요 표시",
104+
systemImage: todo.isPinned ? "star.fill" : "star",
105+
color: todo.isPinned ? .orange : .secondary
106+
)
107+
108+
HStack {
109+
Text("마감일")
110+
111+
Spacer()
112+
113+
if let dueDate = todo.dueDate {
114+
Tag(dueDateText(for: dueDate), isEditing: false)
115+
.padding(.vertical, -4)
116+
} else {
117+
Text("없음")
118+
.foregroundStyle(.secondary)
119+
}
120+
}
121+
}
122+
123+
Section("태그") {
124+
if todo.tags.isEmpty {
125+
Text("태그 없음")
126+
.foregroundStyle(.secondary)
127+
.padding(.vertical, 4)
128+
} else {
129+
TagList(todo.tags)
130+
}
131+
}
132+
}
133+
.navigationTitle("세부 정보")
134+
.navigationBarTitleDisplayMode(.inline)
135+
.toolbar {
136+
ToolbarLeadingButton {
137+
onClose()
138+
}
139+
}
140+
}
141+
}
142+
143+
@ViewBuilder
144+
private func statusRow(
145+
title: String,
146+
systemImage: String,
147+
color: Color
148+
) -> some View {
149+
HStack {
150+
Text(title)
151+
152+
Spacer()
153+
154+
Image(systemName: systemImage)
155+
.foregroundStyle(color)
156+
}
157+
}
158+
159+
private func dueDateText(for dueDate: Date) -> String {
160+
let currentYear = calendar.component(.year, from: Date())
161+
let dueDateYear = calendar.component(.year, from: dueDate)
162+
163+
if currentYear == dueDateYear {
164+
return dueDate.formatted(
165+
.dateTime.month(.defaultDigits).day(.defaultDigits)
166+
)
167+
}
168+
169+
return dueDate.formatted(
170+
.dateTime.year(.twoDigits).month(.defaultDigits).day(.defaultDigits)
171+
)
172+
}
173+
}

DevLog/UI/Home/TodoEditorView.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ private struct TodoEditorInfoSheetView: View {
272272
HStack {
273273
Text("마감일")
274274
.foregroundStyle(.primary)
275-
276275
Spacer()
277-
278276
if let dueDate = viewModel.state.dueDate {
279277
Tag(dueDateText(for: dueDate), isEditing: true) {
280278
viewModel.send(.setDueDate(nil))

0 commit comments

Comments
 (0)