feat: highlight overdue todos with red background and icon
This commit is contained in:
@@ -5,6 +5,13 @@ struct TodoRowView: View {
|
||||
let onToggle: () -> 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 {
|
||||
HStack {
|
||||
Button(action: onToggle) {
|
||||
@@ -37,8 +44,15 @@ struct TodoRowView: View {
|
||||
.font(.system(size: 8))
|
||||
.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 {
|
||||
if text.count > 50 {
|
||||
|
||||
Reference in New Issue
Block a user