widgets: add 'This Year' mode to Progress Dots (KC-53)
Some checks failed
CI / build-and-test (push) Has been cancelled
Some checks failed
CI / build-and-test (push) Has been cancelled
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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).
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user