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 {