feat: highlight overdue todos with red background and icon

This commit is contained in:
2026-02-12 21:34:22 +01:00
parent 5c589c4b93
commit 82bdbad451

View File

@@ -5,6 +5,13 @@ struct TodoRowView: View {
let onToggle: () -> Void let onToggle: () -> Void
var onTap: (() -> Void)? var onTap: (() -> Void)?
private var isOverdue: Bool {
!item.isCompleted && item.deadline != nil
&& item.deadline! < Calendar.current.startOfDay(
for: Calendar.current.date(byAdding: .day, value: 1, to: Date())!
)
}
var body: some View { var body: some View {
HStack { HStack {
Button(action: onToggle) { Button(action: onToggle) {
@@ -37,8 +44,15 @@ struct TodoRowView: View {
.font(.system(size: 8)) .font(.system(size: 8))
.foregroundStyle(priority.color) .foregroundStyle(priority.color)
} }
if isOverdue {
Image(systemName: "exclamationmark.circle.fill")
.font(.system(size: 14))
.foregroundStyle(.red)
} }
} }
.listRowBackground(isOverdue ? Color.red.opacity(0.08) : nil)
}
private func noteSnippet(_ text: String) -> String { private func noteSnippet(_ text: String) -> String {
if text.count > 50 { if text.count > 50 {