mycode/myApp/HaruDanim/Shared/TrackingActivityAttributes.swift
songyc macbook 59d6105d21 feat(tracking): long-running session alerts, timer cap fix, memo save
- 장시간 측정 알림: 측정이 설정한 시간(1/2/3/6/12시간, 기본 끔)을 넘기면
  로컬 알림으로 종료를 잊었음을 알려준다. LiveActivityManager.sync 길목에서
  진행 세션과 예약을 동기화하므로 앱·위젯·시리·워치 어느 경로로
  시작/종료/수정해도 예약이 따라가고, 세션이 끝나거나 설정이 바뀌면
  기존 예약이 제거된다 (식별자에 행동·시작시각·설정시간 포함).
  설정 탭 '측정' 섹션에서 켜는 순간 권한 요청.
- Live Activity 타이머 상한 30일 → 1년 (상한 도달로 타이머가 멈춰 보이던
  엣지 제거)
- 메모 시트(측정 종료/횟수 기록) 저장 시 명시적 context.save — autosave
  의존 제거
- 검증용 -longSessionAlertTestSeconds(시간 대신 N초 발화)·-alertDump
  (예약 상태를 Documents/session-alerts.txt로) 추가. 시뮬레이터에서
  예약 생성(진행 세션 2건)과 설정 해제 시 제거를 덤프로 확인

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013yKDMhuF39GVYy3FMcGHh7
2026-07-14 00:04:08 +09:00

43 lines
1.5 KiB
Swift

//
// TrackingActivityAttributes.swift
// Haru_Danim
//
// Live Activity . .
//
import Foundation
import ActivityKit
import SwiftUI
nonisolated struct TrackingActivityAttributes: ActivityAttributes {
nonisolated struct ContentState: Codable, Hashable {
/// (: / )
var actionName: String
var symbolName: String
var colorHex: String
var startedAt: Date
/// (+1, +2 )
var extraCount: Int
}
}
extension TrackingActivityAttributes.ContentState {
var tintColor: Color {
let cleaned = colorHex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var value: UInt64 = 0
Scanner(string: cleaned).scanHexInt64(&value)
return Color(
red: Double((value >> 16) & 0xFF) / 255,
green: Double((value >> 8) & 0xFF) / 255,
blue: Double(value & 0xFF) / 255
)
}
/// . ClosedRange ,
/// 30 1
/// ( )
var timerRange: ClosedRange<Date> {
startedAt...startedAt.addingTimeInterval(60 * 60 * 24 * 365)
}
}