From f96e2948abbffd80069d85b6b2d9b7e479c8b447 Mon Sep 17 00:00:00 2001 From: Nucleic Date: Fri, 26 Jun 2026 01:18:03 -0700 Subject: [PATCH] Streak Freeze Feature Implementation Nucleic-Session: 89DB7BC1-F74C-4768-BC7B-25F898265E0E --- NucleicRemote/NucleicRemote/Views/HomeView.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/NucleicRemote/NucleicRemote/Views/HomeView.swift b/NucleicRemote/NucleicRemote/Views/HomeView.swift index 53aaa5e..643a0e9 100644 --- a/NucleicRemote/NucleicRemote/Views/HomeView.swift +++ b/NucleicRemote/NucleicRemote/Views/HomeView.swift @@ -19,16 +19,11 @@ struct HomeView: View { uniquingKeysWith: +) } - private var streak: Int { - let cal = Calendar.current - var day = cal.startOfDay(for: Date()) - if (activityByDay[day] ?? 0) == 0 { day = cal.date(byAdding: .day, value: -1, to: day)! } - var count = 0 - while (activityByDay[day] ?? 0) > 0 { - count += 1 - day = cal.date(byAdding: .day, value: -1, to: day)! - } - return count + /// Current activity streak with streak freezes folded in — the run of consecutive active + /// days, where a banked freeze (one earned per five days) bridges a missed day. Shared with + /// the Mac via `StreakState`, so both devices report the same streak and frozen days. + private var streakState: StreakState { + StreakState.compute(activityByDay: activityByDay) } private var greeting: String {