- HealthWorkoutType(WorkoutConfig 필드, 워치 자동 동기화) — 폰·워치 저장 모두 반영 - 설정 → 애플 건강에 '운동 유형' 피커, 푸터·도움말 문구 유형 중립으로 갱신 - 신규 문자열 번역(en/ja), 옛 문구 stale 2건 정리 — 전 카탈로그 missing·stale 0 - 하루 다님 연계 조사 결과 CLAUDE.md 기록(종목 다짐·타임테이블=자동 집계, 운동 시간 지표=워치 실행분만 운동 링 경유 반영) - 검증: Debug·Release·워치 빌드 그린, 설정 화면 QA Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UPmp29DQHY6Ahfss5SRopT
56 lines
1.8 KiB
Swift
56 lines
1.8 KiB
Swift
//
|
|
// WorkoutCoordinator.swift
|
|
// Keging
|
|
//
|
|
// 엔진 ↔ 진동·Live Activity·백그라운드 오디오·화면 꺼짐 방지 배선 (iOS)
|
|
//
|
|
|
|
import UIKit
|
|
|
|
@MainActor
|
|
final class WorkoutCoordinator {
|
|
static let shared = WorkoutCoordinator()
|
|
|
|
private var wired = false
|
|
|
|
private init() {}
|
|
|
|
func wire() {
|
|
guard !wired else { return }
|
|
wired = true
|
|
|
|
let engine = KegelEngine.shared
|
|
engine.onPhaseChange = { [weak engine] phase, rep, phaseEnd in
|
|
guard let engine else { return }
|
|
let config = engine.config
|
|
Haptics.play(phase == .contract ? config.contractPattern : config.relaxPattern)
|
|
if phase == .contract && rep == 1 {
|
|
LiveActivityManager.shared.start(totalReps: config.reps, phase: phase, rep: rep, phaseEnd: phaseEnd)
|
|
} else {
|
|
LiveActivityManager.shared.update(phase: phase, rep: rep, totalReps: config.reps, phaseEnd: phaseEnd)
|
|
}
|
|
}
|
|
engine.onSessionEnd = { completed, record in
|
|
LiveActivityManager.shared.end()
|
|
BackgroundAudioKeeper.shared.stop()
|
|
UIApplication.shared.isIdleTimerDisabled = false
|
|
if completed, let record {
|
|
let config = SettingsStore.shared.config
|
|
HealthRecorder.shared.save(
|
|
record: record,
|
|
effortScore: config.effortScore,
|
|
workoutType: config.healthWorkoutType
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
func startWorkout() {
|
|
guard !KegelEngine.shared.isRunning else { return }
|
|
HealthRecorder.shared.requestAuthorizationIfNeeded()
|
|
BackgroundAudioKeeper.shared.start()
|
|
UIApplication.shared.isIdleTimerDisabled = true
|
|
KegelEngine.shared.start(config: SettingsStore.shared.config)
|
|
}
|
|
}
|