From 7bfa16aec47e12ca6ba90deaf2bd9a86e2583948 Mon Sep 17 00:00:00 2001 From: kutesir Date: Wed, 8 Jul 2026 22:59:23 +0300 Subject: [PATCH] widgets: add 'This Year' mode to Progress Dots (KC-53) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Progress Dots lock-screen widget already supports Day/Week/Month via its configuration picker — no code needed for those. Year was the only mode missing. Added ProgressDotMode.year, a matching provider branch (Calendar.dateInterval(of: .year)), and yearTitle(for:), mirroring the existing day/week/month pattern exactly. Co-Authored-By: Claude Opus 4.8 --- KisaniCal/ISSUES.md | 29 +++++++++++++++++++++++++ KisaniCalWidgets/KisaniCalWidgets.swift | 15 +++++++++++++ 2 files changed, 44 insertions(+) diff --git a/KisaniCal/ISSUES.md b/KisaniCal/ISSUES.md index 2d4632f..ac4f555 100644 --- a/KisaniCal/ISSUES.md +++ b/KisaniCal/ISSUES.md @@ -1761,3 +1761,32 @@ Workout"/"Finish Anyway" (→ `markWorkoutDone`) counts the day as done. "Check all sets" now does exactly what it says: checks the boxes, nothing more. Files: `ExerciseModels.swift`. + +--- + +## KC-53 — Add "This Year" to the Progress Dots lock-screen widget + +**Status:** Implemented (not build-verified) +**Reported by:** User +**Area:** Widgets (KisaniCalWidgets) + +### Context +The "Progress Dots" widget (`DayProgressWidget`, kind `KisaniDayProgress`) is a +single configurable widget — long-press → Edit Widget lets you pick a mode. +It already supports **Day**, **Week**, and **Month** (the one the user said is +"already good") on the lock screen (`.accessoryRectangular`) and home screen. +Day and Week needed no code change — just add another widget instance and pick +that mode. **Year was the only mode that didn't exist.** + +### Change +Added `.year` to `ProgressDotMode` ("This Year"), a matching branch in +`ProgressDotProvider.entry(for:at:)` using `Calendar.dateInterval(of: .year, +for:)` (same pattern as month), and a `yearTitle(for:)` formatter ("yyyy") — +mirrors day/week/month exactly. + +Files: `KisaniCalWidgets/KisaniCalWidgets.swift`. + +### Note +Not build-verified (no iOS runtime here). To use: on the Lock Screen, tap the +widget area → Add Widgets → Wenza → Progress Dots → long-press → Edit Widget → +set Mode to This Day / This Week / This Year (This Month already configured). diff --git a/KisaniCalWidgets/KisaniCalWidgets.swift b/KisaniCalWidgets/KisaniCalWidgets.swift index 3481472..d34b845 100644 --- a/KisaniCalWidgets/KisaniCalWidgets.swift +++ b/KisaniCalWidgets/KisaniCalWidgets.swift @@ -40,6 +40,7 @@ enum ProgressDotMode: String, AppEnum { case day case week case month + case year case customEvent static var typeDisplayRepresentation: TypeDisplayRepresentation = "Progress Mode" @@ -47,6 +48,7 @@ enum ProgressDotMode: String, AppEnum { .day: "This Day", .week: "This Week", .month: "This Month", + .year: "This Year", .customEvent: "Custom Event", ] } @@ -115,6 +117,13 @@ struct ProgressDotProvider: AppIntentTimelineProvider { return ProgressDotEntry(date: date, title: Self.monthTitle(for: date), progress: Self.progress(now: date, start: start, end: end), totalDots: 100) + case .year: + let interval = Calendar.current.dateInterval(of: .year, for: date) + let start = interval?.start ?? date + let end = interval?.end ?? date + return ProgressDotEntry(date: date, title: Self.yearTitle(for: date), + progress: Self.progress(now: date, start: start, end: end), + totalDots: 100) case .customEvent: guard let event = configuration.event, let task = loadWidgetTasks().first(where: { $0.id.uuidString == event.id }), @@ -251,6 +260,12 @@ struct ProgressDotProvider: AppIntentTimelineProvider { formatter.dateFormat = "MMMM yyyy" return formatter.string(from: date) } + + private static func yearTitle(for date: Date) -> String { + let formatter = DateFormatter() + formatter.dateFormat = "yyyy" + return formatter.string(from: date) + } } struct DayProgressWidget: Widget {