- 세트 엔진(수축→이완×횟수, 중단=미기록) iOS·워치 공용, 완주만 records.json 저장 - 첫 화면 시작 버튼 + 세팅(시간·횟수·진동 패턴)/설정(테마) 시트, 아래 스와이프 통계 - 통계: 하루(시간대별)/주간/월간 꺾은선, 달력 기준↔롤링(지난 7일·30일) 전환 - Live Activity(수축/이완·n/총·카운트다운), 백그라운드 무음 오디오로 타이머·진동 유지 - 단축어 '케겔 운동 시작', 워치 앱(즉시 시작·워치 전용 진동·physical-therapy 세션·기록 폰 병합) - 하루 다님 팔레트 계승(라이트/다크/시스템), 앱 아이콘 SVG→PNG 등록 - 검증: Debug·Release·워치 빌드 그린, 시뮬 QA 10장(26·18.5·워치 46/40mm), 완주·기록 경로 확인 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UPmp29DQHY6Ahfss5SRopT
112 lines
3.7 KiB
Swift
112 lines
3.7 KiB
Swift
//
|
|
// ContentView.swift
|
|
// KegingWatch Watch App
|
|
//
|
|
// 실행하면 바로 시작 버튼 하나 — 누르면 즉시 시작.
|
|
// 진행 중엔 수축/이완·남은 시간·몇 번째인지 한 화면에.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct WatchContentView: View {
|
|
@EnvironmentObject private var engine: KegelEngine
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
AppTheme.background.ignoresSafeArea()
|
|
switch engine.state {
|
|
case .idle:
|
|
startScreen
|
|
case let .running(phase, rep, phaseStart, phaseEnd):
|
|
runningScreen(phase: phase, rep: rep, phaseStart: phaseStart, phaseEnd: phaseEnd)
|
|
case let .finished(reps):
|
|
finishedScreen(reps: reps)
|
|
}
|
|
}
|
|
.onAppear {
|
|
#if DEBUG
|
|
if CommandLine.arguments.contains("-autoStart") { WatchCoordinator.shared.startWorkout() }
|
|
#endif
|
|
}
|
|
}
|
|
|
|
private var startScreen: some View {
|
|
VStack(spacing: 8) {
|
|
Button {
|
|
WatchCoordinator.shared.startWorkout()
|
|
} label: {
|
|
ZStack {
|
|
Circle()
|
|
.fill(
|
|
LinearGradient(
|
|
colors: [AppTheme.green, AppTheme.green.opacity(0.8)],
|
|
startPoint: .top, endPoint: .bottom
|
|
)
|
|
)
|
|
VStack(spacing: 2) {
|
|
Image(systemName: "play.fill").font(.title3)
|
|
Text("시작").font(.headline)
|
|
}
|
|
.foregroundStyle(Color(hex: "#0F2018"))
|
|
}
|
|
.frame(width: 108, height: 108)
|
|
}
|
|
.buttonStyle(.plain)
|
|
.accessibilityLabel("케겔 운동 시작")
|
|
|
|
Text(SettingsStore.shared.config.summaryText)
|
|
.font(.system(size: 11))
|
|
.foregroundStyle(.secondary)
|
|
.lineLimit(1)
|
|
.minimumScaleFactor(0.7)
|
|
}
|
|
}
|
|
|
|
private func runningScreen(phase: KegelPhase, rep: Int, phaseStart: Date, phaseEnd: Date) -> some View {
|
|
VStack(spacing: 3) {
|
|
Text(phase.label)
|
|
.font(.title3.bold())
|
|
.foregroundStyle(phase == .contract ? AppTheme.green : AppTheme.yellow)
|
|
Text(timerInterval: phaseStart...phaseEnd, countsDown: true)
|
|
.font(.system(size: 30, weight: .semibold))
|
|
.monospacedDigit()
|
|
.multilineTextAlignment(.center)
|
|
Text("\(rep) / \(engine.config.reps)")
|
|
.font(.footnote)
|
|
.monospacedDigit()
|
|
.foregroundStyle(.secondary)
|
|
.accessibilityLabel("현재 \(rep)번째, 전체 \(engine.config.reps)회")
|
|
Button {
|
|
WatchCoordinator.shared.stopWorkout()
|
|
} label: {
|
|
Text("중단")
|
|
.font(.footnote)
|
|
}
|
|
.buttonStyle(.bordered)
|
|
.tint(.red)
|
|
.padding(.top, 2)
|
|
}
|
|
}
|
|
|
|
private func finishedScreen(reps: Int) -> some View {
|
|
VStack(spacing: 6) {
|
|
Image(systemName: "checkmark.circle.fill")
|
|
.font(.system(size: 34))
|
|
.foregroundStyle(AppTheme.green)
|
|
Text("완료!")
|
|
.font(.headline)
|
|
Text("\(reps)회 완주")
|
|
.font(.footnote)
|
|
.foregroundStyle(.secondary)
|
|
Button {
|
|
engine.acknowledgeFinish()
|
|
} label: {
|
|
Text("확인")
|
|
.font(.footnote)
|
|
}
|
|
.buttonStyle(.bordered)
|
|
.padding(.top, 2)
|
|
}
|
|
}
|
|
}
|