Activity Chart Intensity Logic
Nucleic-Session: 76D64900-B16F-45BE-A6CB-E3D2EBC7C73A Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -218,8 +218,9 @@ struct ActivityGrid: View {
|
||||
let startOfWeek = cal.date(byAdding: .day, value: -(weekday - 1), to: today)!
|
||||
let gridStart = cal.date(byAdding: .day, value: -7 * (weeks - 1), to: startOfWeek)!
|
||||
// Brightness relative to *this user's* activity, outliers excluded so a few marathon
|
||||
// days don't crush the everyday range. Computed once for the whole grid (mirrors Mac).
|
||||
let scale = ActivityScale(activityByDay: activityByDay)
|
||||
// days don't crush the everyday range. Shades by tokens-per-day, falling back to message
|
||||
// count for days without recorded usage. Computed once for the whole grid (mirrors Mac).
|
||||
let shading = ActivityShading(tokensByDay: tokensByDay, messagesByDay: activityByDay)
|
||||
return HStack(alignment: .top, spacing: gap) {
|
||||
ForEach(0..<weeks, id: \.self) { col in
|
||||
VStack(spacing: gap) {
|
||||
@@ -230,7 +231,8 @@ struct ActivityGrid: View {
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
.fill(isFuture ? Color.clear
|
||||
: isFrozen ? Palette.frozen
|
||||
: Palette.activity(intensity: scale.intensity(for: activityByDay[date] ?? 0)))
|
||||
: Palette.activity(intensity: shading.intensity(
|
||||
tokens: tokensByDay[date] ?? 0, messages: activityByDay[date] ?? 0)))
|
||||
.frame(width: cell, height: cell)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user