Progress bar: red when overdue, orange when 2-3 days from deadline

Fixes #13

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-02-11 23:41:20 +01:00
parent 4761e2e5c8
commit 3a72a75e5c
2 changed files with 35 additions and 3 deletions
@@ -418,6 +418,22 @@ struct MonthlyCheckInCard: View {
return last.adding(months: 1) return last.adding(months: 1)
} }
private var isOverdue: Bool {
guard let next = nextCheckInDate else { return false }
return Date() > next
}
private var daysUntilDeadline: Int? {
guard let next = nextCheckInDate else { return nil }
return Calendar.current.dateComponents([.day], from: Date().startOfDay, to: next.startOfDay).day
}
private var progressBarTint: Color {
if isOverdue { return .red }
if let days = daysUntilDeadline, days <= 3 { return .orange }
return .appSecondary
}
private var reminderDate: Date? { private var reminderDate: Date? {
guard let nextCheckInDate else { return nil } guard let nextCheckInDate else { return nil }
let settings = AppSettings.getOrCreate(in: CoreDataStack.shared.viewContext) let settings = AppSettings.getOrCreate(in: CoreDataStack.shared.viewContext)
@@ -475,12 +491,12 @@ struct MonthlyCheckInCard: View {
} }
ProgressView(value: checkInProgress) ProgressView(value: checkInProgress)
.tint(.appSecondary) .tint(progressBarTint)
if let nextDate = nextCheckInDate { if let nextDate = nextCheckInDate {
Text("Next check-in: \(nextDate.mediumDateString)") Text("Next check-in: \(nextDate.mediumDateString)")
.font(.caption) .font(.caption)
.foregroundColor(.secondary) .foregroundColor(isOverdue ? .red : .secondary)
} }
NavigationLink( NavigationLink(
@@ -58,6 +58,22 @@ struct MonthlyCheckInView: View {
return last.adding(months: checkInIntervalMonths) return last.adding(months: checkInIntervalMonths)
} }
private var isOverdue: Bool {
guard let next = nextCheckInDate else { return false }
return Date() > next
}
private var daysUntilDeadline: Int? {
guard let next = nextCheckInDate else { return nil }
return Calendar.current.dateComponents([.day], from: Date().startOfDay, to: next.startOfDay).day
}
private var progressBarTint: Color {
if isOverdue { return .red }
if let days = daysUntilDeadline, days <= 3 { return .orange }
return .appSecondary
}
private var canAddNewCheckIn: Bool { private var canAddNewCheckIn: Bool {
true true
} }
@@ -171,7 +187,7 @@ struct MonthlyCheckInView: View {
VStack(alignment: .leading, spacing: 6) { VStack(alignment: .leading, spacing: 6) {
ProgressView(value: checkInProgress) ProgressView(value: checkInProgress)
.tint(.appSecondary) .tint(progressBarTint)
if let nextDate = nextCheckInDate { if let nextDate = nextCheckInDate {
Text( Text(