Streak Freeze Feature Implementation
Nucleic-Session: 89DB7BC1-F74C-4768-BC7B-25F898265E0E
This commit is contained in:
@@ -19,16 +19,11 @@ struct HomeView: View {
|
|||||||
uniquingKeysWith: +)
|
uniquingKeysWith: +)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var streak: Int {
|
/// Current activity streak with streak freezes folded in — the run of consecutive active
|
||||||
let cal = Calendar.current
|
/// days, where a banked freeze (one earned per five days) bridges a missed day. Shared with
|
||||||
var day = cal.startOfDay(for: Date())
|
/// the Mac via `StreakState`, so both devices report the same streak and frozen days.
|
||||||
if (activityByDay[day] ?? 0) == 0 { day = cal.date(byAdding: .day, value: -1, to: day)! }
|
private var streakState: StreakState {
|
||||||
var count = 0
|
StreakState.compute(activityByDay: activityByDay)
|
||||||
while (activityByDay[day] ?? 0) > 0 {
|
|
||||||
count += 1
|
|
||||||
day = cal.date(byAdding: .day, value: -1, to: day)!
|
|
||||||
}
|
|
||||||
return count
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var greeting: String {
|
private var greeting: String {
|
||||||
|
|||||||
Reference in New Issue
Block a user