Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions DevLog/Presentation/ViewModel/TodayViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class TodayViewModel: Store {
let items: [TodayTodoItem]
}

struct SectionBuckets {
struct SectionCollection {
var focused: [TodayTodoItem] = []
var overdue: [TodayTodoItem] = []
var dueSoon: [TodayTodoItem] = []
Expand Down Expand Up @@ -301,39 +301,39 @@ private extension TodayViewModel {

func groupedSectionItems(
from items: [TodayTodoItem]
) -> SectionBuckets {
) -> SectionCollection {
let startOfToday = calendar.startOfDay(for: Date())
guard let windowEnd = calendar.date(byAdding: .day, value: upcomingWindowDays, to: startOfToday) else {
return SectionBuckets(
return SectionCollection(
focused: items.filter(\.isPinned),
unscheduled: items.filter { !$0.isPinned && $0.dueDate == nil }
)
}

var buckets = SectionBuckets()
var collection = SectionCollection()

for item in items {
if item.isPinned {
buckets.focused.append(item)
collection.focused.append(item)
continue
}

guard let dueDate = item.dueDate else {
buckets.unscheduled.append(item)
collection.unscheduled.append(item)
continue
}

let dueDay = calendar.startOfDay(for: dueDate)
if dueDay < startOfToday {
buckets.overdue.append(item)
collection.overdue.append(item)
} else if dueDay <= windowEnd {
buckets.dueSoon.append(item)
collection.dueSoon.append(item)
} else {
buckets.later.append(item)
collection.later.append(item)
}
}

return buckets
return collection
}

func isOverdue(_ item: TodayTodoItem) -> Bool {
Expand Down
5 changes: 3 additions & 2 deletions DevLog/UI/Today/TodayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@ struct TodayView: View {
Image(systemName: item.isPinned ? "star.slash" : "star.fill")
}
.tint(.orange)

}
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
Button {
viewModel.send(.completeTodo(item))
} label: {
Image(systemName: "checkmark")
Label("완료", systemImage: "checkmark")
}
.tint(.green)
}
Expand Down