- 메인: 텍스트 한 줄 요약 → 수축·이완·횟수 카드 3장(아이콘+큰 숫자, 탭=세팅) - 운동 화면: 국면 색 전환(수축=그린·이완=앰버, 카운터 색 연동) + 세트 진행 링 + 큰 현재 횟수 카운터(numericText 전환) - 도움말 취소선 원인 = SwiftUI Text 마크다운의 ~쌍 해석 — 사용자 문구의 ASCII ~를 전각 ~로 전면 교체(4곳), CLAUDE.md에 금지 규칙 기록 - 신규 QA 인자 -noHealth(권한 시트가 캡처 가리는 것 방지) - 검증: Debug·Release 빌드 그린, 화면 QA(메인 카드·수축/이완 국면·도움말), 카탈로그 0/0 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UPmp29DQHY6Ahfss5SRopT
157 lines
5.7 KiB
Swift
157 lines
5.7 KiB
Swift
//
|
|
// WorkoutView.swift
|
|
// Keging
|
|
//
|
|
// 운동 진행 화면 — 국면 원이 수축 때 줄고 이완 때 커진다. 중단 시 이 세트는 기록 없음.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct WorkoutView: View {
|
|
@EnvironmentObject private var engine: KegelEngine
|
|
@State private var confirmStop = false
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
AppTheme.background.ignoresSafeArea()
|
|
switch engine.state {
|
|
case let .running(phase, rep, phaseStart, phaseEnd):
|
|
runningView(phase: phase, rep: rep, phaseStart: phaseStart, phaseEnd: phaseEnd)
|
|
case let .finished(reps):
|
|
finishedView(reps: reps)
|
|
case .idle:
|
|
Color.clear
|
|
}
|
|
}
|
|
}
|
|
|
|
private func runningView(phase: KegelPhase, rep: Int, phaseStart: Date, phaseEnd: Date) -> some View {
|
|
let phaseColor = phase == .contract ? AppTheme.green : AppTheme.yellow
|
|
let progress = (Double(rep - 1) + (phase == .relax ? 0.5 : 0)) / Double(max(1, engine.config.reps))
|
|
return VStack(spacing: 0) {
|
|
HStack(alignment: .firstTextBaseline, spacing: 5) {
|
|
Text(verbatim: "\(rep)")
|
|
.font(.system(size: 46, weight: .bold))
|
|
.monospacedDigit()
|
|
.foregroundStyle(phaseColor)
|
|
.contentTransition(.numericText())
|
|
.animation(.snappy, value: rep)
|
|
Text(verbatim: "/ \(engine.config.reps)")
|
|
.font(.title3.weight(.semibold))
|
|
.monospacedDigit()
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
.padding(.top, 16)
|
|
.accessibilityElement(children: .ignore)
|
|
.accessibilityLabel(Text("현재 \(rep)번째, 전체 \(engine.config.reps)회"))
|
|
|
|
Spacer()
|
|
|
|
ZStack {
|
|
// 세트 진행 링 — 국면 색으로 채워진다
|
|
Circle()
|
|
.stroke(AppTheme.surface, lineWidth: 10)
|
|
.frame(width: 344, height: 344)
|
|
Circle()
|
|
.trim(from: 0, to: progress)
|
|
.stroke(phaseColor.opacity(0.85), style: StrokeStyle(lineWidth: 10, lineCap: .round))
|
|
.rotationEffect(.degrees(-90))
|
|
.frame(width: 344, height: 344)
|
|
.animation(.easeInOut(duration: 0.5), value: progress)
|
|
PhaseCircle(phase: phase, phaseStart: phaseStart, phaseEnd: phaseEnd)
|
|
VStack(spacing: 6) {
|
|
Text(phase.label)
|
|
.font(.system(size: 44, weight: .bold))
|
|
Text(timerInterval: phaseStart...phaseEnd, countsDown: true)
|
|
.font(.title2.weight(.medium))
|
|
.monospacedDigit()
|
|
.opacity(0.85)
|
|
}
|
|
.foregroundStyle(phase == .contract
|
|
? Color(light: .white, dark: Color(hex: "#0F2018"))
|
|
: Color(hex: "#33260A"))
|
|
}
|
|
|
|
Spacer()
|
|
|
|
Button {
|
|
confirmStop = true
|
|
} label: {
|
|
Text("중단")
|
|
.font(.headline)
|
|
.frame(maxWidth: 160)
|
|
}
|
|
.buttonStyle(.bordered)
|
|
.tint(.red)
|
|
.padding(.bottom, 30)
|
|
}
|
|
.confirmationDialog("운동을 중단할까요?", isPresented: $confirmStop, titleVisibility: .visible) {
|
|
Button("중단하기", role: .destructive) { engine.stop() }
|
|
Button("계속하기", role: .cancel) {}
|
|
} message: {
|
|
Text("중단하면 이 세트는 기록되지 않아요.")
|
|
}
|
|
}
|
|
|
|
private func finishedView(reps: Int) -> some View {
|
|
VStack(spacing: 18) {
|
|
Image(systemName: "checkmark.circle.fill")
|
|
.font(.system(size: 84))
|
|
.foregroundStyle(AppTheme.green)
|
|
Text("완료!")
|
|
.font(.largeTitle.bold())
|
|
Text("\(reps)회를 모두 마쳤어요.")
|
|
.font(.body)
|
|
.foregroundStyle(.secondary)
|
|
Button {
|
|
engine.acknowledgeFinish()
|
|
} label: {
|
|
Text("확인")
|
|
.font(.headline)
|
|
.frame(maxWidth: 160)
|
|
}
|
|
.buttonStyle(.borderedProminent)
|
|
.padding(.top, 12)
|
|
}
|
|
}
|
|
}
|
|
|
|
/// 수축이면 오므라들고 이완이면 부풀어 오르는 국면 원 — 색도 국면 따라(수축 그린·이완 앰버)
|
|
private struct PhaseCircle: View {
|
|
let phase: KegelPhase
|
|
let phaseStart: Date
|
|
let phaseEnd: Date
|
|
|
|
@State private var scale: CGFloat = 1
|
|
|
|
private var color: Color { phase == .contract ? AppTheme.green : AppTheme.yellow }
|
|
|
|
var body: some View {
|
|
Circle()
|
|
.fill(
|
|
LinearGradient(
|
|
colors: [color, color.opacity(0.8)],
|
|
startPoint: .top, endPoint: .bottom
|
|
)
|
|
)
|
|
.frame(width: 300, height: 300)
|
|
.scaleEffect(scale)
|
|
.shadow(color: color.opacity(0.3), radius: 26, x: 0, y: 10)
|
|
.animation(.easeInOut(duration: 0.4), value: phase)
|
|
.onAppear { animate() }
|
|
.onChange(of: phase) { animate() }
|
|
}
|
|
|
|
private func animate() {
|
|
let duration = max(0.3, phaseEnd.timeIntervalSince(phaseStart))
|
|
var transaction = Transaction()
|
|
transaction.disablesAnimations = true
|
|
withTransaction(transaction) {
|
|
scale = phase == .contract ? 1.0 : 0.62
|
|
}
|
|
withAnimation(.easeInOut(duration: duration)) {
|
|
scale = phase == .contract ? 0.62 : 1.0
|
|
}
|
|
}
|
|
}
|