diff --git a/PortfolioJournal/Views/Dashboard/DashboardView.swift b/PortfolioJournal/Views/Dashboard/DashboardView.swift index 28b901f..7178342 100644 --- a/PortfolioJournal/Views/Dashboard/DashboardView.swift +++ b/PortfolioJournal/Views/Dashboard/DashboardView.swift @@ -418,6 +418,22 @@ struct MonthlyCheckInCard: View { 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? { guard let nextCheckInDate else { return nil } let settings = AppSettings.getOrCreate(in: CoreDataStack.shared.viewContext) @@ -475,12 +491,12 @@ struct MonthlyCheckInCard: View { } ProgressView(value: checkInProgress) - .tint(.appSecondary) + .tint(progressBarTint) if let nextDate = nextCheckInDate { Text("Next check-in: \(nextDate.mediumDateString)") .font(.caption) - .foregroundColor(.secondary) + .foregroundColor(isOverdue ? .red : .secondary) } NavigationLink( diff --git a/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift b/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift index a6e657f..6bdd132 100644 --- a/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift +++ b/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift @@ -58,6 +58,22 @@ struct MonthlyCheckInView: View { 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 { true } @@ -171,7 +187,7 @@ struct MonthlyCheckInView: View { VStack(alignment: .leading, spacing: 6) { ProgressView(value: checkInProgress) - .tint(.appSecondary) + .tint(progressBarTint) if let nextDate = nextCheckInDate { Text(