summaryrefslogtreecommitdiff
path: root/HutchWidgetExtension
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-13 09:57:23 -0500
committerChristian Cleberg <[email protected]>2026-04-13 09:57:23 -0500
commit0e461a382257979037e8927e5f6b468635b0a7fe (patch)
tree0aa3a19f6f8f966b0e90f4874ed54359a7898107 /HutchWidgetExtension
parentee9f2904aa319231b7047fca3cb069f0c07019cd (diff)
downloadhutch-0e461a382257979037e8927e5f6b468635b0a7fe.tar.gz
hutch-0e461a382257979037e8927e5f6b468635b0a7fe.tar.bz2
hutch-0e461a382257979037e8927e5f6b468635b0a7fe.zip
feat: add power user actions
Implements: https://todo.sr.ht/~ccleberg/hutch/52 Implements: https://todo.sr.ht/~ccleberg/hutch/53 Implements: https://todo.sr.ht/~ccleberg/hutch/54
Diffstat (limited to 'HutchWidgetExtension')
-rw-r--r--HutchWidgetExtension/ContributionGraphWidget.swift28
1 files changed, 24 insertions, 4 deletions
diff --git a/HutchWidgetExtension/ContributionGraphWidget.swift b/HutchWidgetExtension/ContributionGraphWidget.swift
index 5dbf6a2..4245230 100644
--- a/HutchWidgetExtension/ContributionGraphWidget.swift
+++ b/HutchWidgetExtension/ContributionGraphWidget.swift
@@ -154,15 +154,19 @@ private struct ContributionGraphWidgetView: View {
private func displayedWeeks(columnCount: Int) -> [ContributionGraphWeek] {
var baseWeeks = switch entry.state {
- case .populated, .indexing, .empty:
+ case .populated, .indexing:
entry.weeks
+ case .empty:
+ ContributionGraphSampleData.emptyWeeks
case .placeholder, .disabled, .unavailable:
ContributionGraphSampleData.placeholderWeeks
}
- // Drop any trailing week where every day has zero contributions
- while let last = baseWeeks.last, last.days.allSatisfy({ $0.count == 0 }) {
- baseWeeks.removeLast()
+ if entry.state != .empty {
+ // Drop any trailing week where every day has zero contributions.
+ while let last = baseWeeks.last, last.days.allSatisfy({ $0.count == 0 }) {
+ baseWeeks.removeLast()
+ }
}
return Array(baseWeeks.suffix(columnCount))
@@ -182,6 +186,11 @@ private struct ContributionGraphGridView: View {
RoundedRectangle(cornerRadius: squareSize * 0.2, style: .continuous)
.fill((day?.intensity ?? .empty).color)
.frame(width: squareSize, height: squareSize)
+ .overlay {
+ let intensity = day?.intensity ?? .empty
+ RoundedRectangle(cornerRadius: squareSize * 0.2, style: .continuous)
+ .stroke(Color.primary.opacity(intensity == .empty ? 0.08 : 0), lineWidth: 0.5)
+ }
}
}
}
@@ -420,6 +429,17 @@ private enum ContributionGraphDateParser {
}
private enum ContributionGraphSampleData {
+ static let emptyWeeks: [ContributionGraphWeek] = {
+ let startDate = Calendar.contributionCalendar.startOfDay(for: .now)
+ let days = (0..<371).compactMap { offset -> ContributionGraphDay? in
+ guard let date = Calendar.contributionCalendar.date(byAdding: .day, value: -offset, to: startDate) else {
+ return nil
+ }
+ return ContributionGraphDay(date: date, count: 0, score: 0)
+ }
+ return ContributionGraphLayout.weekColumns(from: days)
+ }()
+
static let placeholderWeeks: [ContributionGraphWeek] = {
let startDate = Calendar.contributionCalendar.startOfDay(for: .now)
let days = (0..<150).compactMap { offset -> ContributionGraphDay? in