Streak Freeze Feature Implementation
Nucleic-Session: 89DB7BC1-F74C-4768-BC7B-25F898265E0E
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user