- KegelPhase에 prepare 국면 추가(무진동 — 첫 수축 진동이 시작 신호), 준비 0초면 즉시 수축 - 세팅에 '준비' 스테퍼(0~10초), 워치 자동 동기화, 구버전 설정 decodeIfPresent 보존 - 진행 화면: 준비=회그린 원이 작게 시작해 천천히 부풀며 첫 수축으로 연결(기존 그래픽 문법 유지), 진행 링 0·카운터 색 연동. 워치·Live Activity도 준비 국면 색/표시 대응 - 기록·건강의 시작 시각은 준비를 뺀 첫 수축 기준. Live Activity는 sync 단일 진입점으로 정리 - 도움말·세팅 푸터 문구 갱신, 신규 문자열 번역(en/ja)·stale 정리 — 전 카탈로그 0/0 - 검증: 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
|
|
switch phase {
|
|
case .prepare: break // 준비는 무진동 — 첫 수축 진동이 시작 신호
|
|
case .contract: Haptics.play(config.contractPattern)
|
|
case .relax: Haptics.play(config.relaxPattern)
|
|
}
|
|
LiveActivityManager.shared.sync(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)
|
|
}
|
|
}
|