// // KegingActivityAttributes.swift // Keging // // Live Activity(다이나믹 아일랜드) 상태 — 앱·위젯 두 타깃에 동일 파일로 컴파일. // // ⚠️설계 원칙(실기기 4차 피드백): ActivityKit엔 "미래 시점 상태 예약" API가 없어 // 국면 전환 갱신은 앱 런타임에 의존한다. 그래서 상태에 세트 전체 일정(sessionStart· // 준비/수축/이완/횟수)을 통째로 실어, 위젯이 타임라인 바·진행 플레이헤드·남은 시간을 // timerInterval 계열(시스템 렌더)로 그리게 한다 — 앱이 정지해도 이 요소들은 계속 움직인다. // #if canImport(ActivityKit) import ActivityKit import Foundation nonisolated struct KegingActivityAttributes: ActivityAttributes { nonisolated struct ContentState: Codable, Hashable { var phase: KegelPhase var rep: Int var totalReps: Int var phaseStart: Date var phaseEnd: Date // 자가 렌더링용 전체 일정 — 버튼 누른 시각부터 결정적 var sessionStart: Date var prepSeconds: Int var contractSeconds: Int var relaxSeconds: Int var sessionEnd: Date { sessionStart.addingTimeInterval( Double(prepSeconds + totalReps * (contractSeconds + relaxSeconds)) ) } } var startedAt: Date = Date() } #endif