From b6314db3143645a5059d6101e9b889fe6b2b6dfc Mon Sep 17 00:00:00 2001 From: alexandrev-tibco Date: Fri, 20 Feb 2026 22:44:22 +0100 Subject: [PATCH] Fix check-in progress bar always showing empty after completing check-in Previous logic measured elapsed days from lastCompletionDate to nextCheckInDate, so completing a check-in today reset the bar to 0/8 days instead of showing how far through the full monthly period we are. New logic: the bar represents the full interval (e.g. 1 month) ending at nextCheckInDate, starting from nextCheckInDate minus that interval. Today (Feb 20) with next check-in Feb 28 now shows ~74% progress (23 of 31 days elapsed since Jan 28) instead of 0%. Co-Authored-By: Claude Sonnet 4.6 --- .../Views/Dashboard/MonthlyCheckInView.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift b/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift index 5e55fd0..9b715f1 100644 --- a/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift +++ b/PortfolioJournal/Views/Dashboard/MonthlyCheckInView.swift @@ -31,12 +31,15 @@ struct MonthlyCheckInView: View { } private var checkInProgress: Double { - guard let last = lastCompletionDate, - let nextDate = nextCheckInDate else { return 1 } - let totalDays = Double(max(1, last.startOfDay.daysBetween(nextDate.startOfDay))) - guard totalDays > 0 else { return 1 } - let elapsedDays = Double(last.startOfDay.daysBetween(Date())) - return min(max(elapsedDays / totalDays, 0), 1) + guard let nextDate = nextCheckInDate, + let periodStart = Calendar.current.date( + byAdding: .month, + value: -checkInIntervalMonths, + to: nextDate + ) else { return 1 } + let totalDays = Double(max(1, periodStart.startOfDay.daysBetween(nextDate.startOfDay))) + let elapsedDays = Double(max(0, periodStart.startOfDay.daysBetween(Date().startOfDay))) + return min(elapsedDays / totalDays, 1) } private var checkInIntervalMonths: Int {