- 완주한 세트만 애플 건강에 '기타' 운동으로 자동 기록 (중단=미기록 규칙 일관) - 폰=사후 HKWorkoutBuilder, 워치=라이브 HKWorkoutSession(심박 포함·손목 내림 유지 겸용, 실패 시 확장 런타임 세션 폴백) - 운동 강도: 설정 → 애플 건강 → 자동 기록(기본 2·쉬움, 안 함 가능) — relateWorkoutEffortSample, 워치 11+/iOS 18, 워치 10은 운동만 기록 - 쓰기 전용 권한(첫 시작 때 요청·거부 시 조용히 스킵), 건강 문구 3언어, 새 UI 문자열 11키 번역 - WorkoutConfig 전 필드 decodeIfPresent 디코더 (필드 추가에도 기존 설정 보존) - 검증: Debug·Release·워치 빌드 그린, 권한 시트·설정 ko/ja 화면 QA, 카탈로그 missing·stale 0 (건강 실제 저장은 권한 시트 조작 불가로 실기기 확인 필요) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UPmp29DQHY6Ahfss5SRopT
47 lines
1.3 KiB
Swift
47 lines
1.3 KiB
Swift
//
|
|
// WatchCoordinator.swift
|
|
// KegingWatch Watch App
|
|
//
|
|
// 엔진 ↔ 워치 진동·확장 런타임 세션·폰 기록 전송 배선. 진동은 워치에서만 울린다.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
@MainActor
|
|
final class WatchCoordinator {
|
|
static let shared = WatchCoordinator()
|
|
|
|
private var wired = false
|
|
|
|
private init() {}
|
|
|
|
func wire() {
|
|
guard !wired else { return }
|
|
wired = true
|
|
|
|
let engine = KegelEngine.shared
|
|
engine.onPhaseChange = { [weak engine] phase, _, _ in
|
|
guard let engine else { return }
|
|
let config = engine.config
|
|
WatchHaptics.play(phase == .contract ? config.contractPattern : config.relaxPattern)
|
|
}
|
|
engine.onSessionEnd = { completed, record in
|
|
WatchWorkoutSession.shared.end(completed: completed, effortScore: SettingsStore.shared.config.effortScore)
|
|
if completed, let record {
|
|
WatchSync.shared.sendRecord(record)
|
|
WatchHaptics.playSuccess()
|
|
}
|
|
}
|
|
}
|
|
|
|
func startWorkout() {
|
|
guard !KegelEngine.shared.isRunning else { return }
|
|
KegelEngine.shared.start(config: SettingsStore.shared.config)
|
|
WatchWorkoutSession.shared.begin(startDate: Date())
|
|
}
|
|
|
|
func stopWorkout() {
|
|
KegelEngine.shared.stop()
|
|
}
|
|
}
|