From 3a72a75e5c417264761df0aa9f554a5bf78b6573 Mon Sep 17 00:00:00 2001 From: alexandrev-tibco Date: Wed, 11 Feb 2026 23:41:20 +0100 Subject: [PATCH] Progress bar: red when overdue, orange when 2-3 days from deadline Fixes #13 Co-Authored-By: Claude Opus 4.6 --- .../Views/Dashboard/DashboardView.swift | 20 +++++++++++++++++-- .../Views/Dashboard/MonthlyCheckInView.swift | 18 ++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) 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(