- 첫 화면 우하단 ? 버튼 → 도움말(5그룹 13주제 — 기본 사용법·통계·앱 밖에서·애플워치·설정 기타) - String Catalog ko(원문)/en/ja 3타깃(iOS 98·워치 15·위젯 9키) 전수 번역, InfoPlist 표시 이름 포함 - 설정 → 언어(시스템/한국어/English/日本語) — AppleLanguages 오버라이드, 재실행 시 적용(하루 다님 방식) - 검증: Debug·Release·워치 빌드 그린, missing·stale 0, en/ja/ko 화면 QA 7장(도움말·설정·세팅·통계·워치) - DEBUG 인자 추가: -openHelp/-openSettings/-openTimerSettings/-resetConfig Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UPmp29DQHY6Ahfss5SRopT
131 lines
4.3 KiB
Swift
131 lines
4.3 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 {
|
|
VStack(spacing: 0) {
|
|
Text("\(rep) / \(engine.config.reps)")
|
|
.font(.title2.weight(.semibold))
|
|
.monospacedDigit()
|
|
.foregroundStyle(.secondary)
|
|
.padding(.top, 24)
|
|
.accessibilityLabel(Text("현재 \(rep)번째, 전체 \(engine.config.reps)회"))
|
|
|
|
Spacer()
|
|
|
|
ZStack {
|
|
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(Color(light: .white, dark: Color(hex: "#0F2018")))
|
|
}
|
|
|
|
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
|
|
|
|
var body: some View {
|
|
Circle()
|
|
.fill(
|
|
LinearGradient(
|
|
colors: [AppTheme.green, AppTheme.green.opacity(0.8)],
|
|
startPoint: .top, endPoint: .bottom
|
|
)
|
|
)
|
|
.frame(width: 300, height: 300)
|
|
.scaleEffect(scale)
|
|
.shadow(color: AppTheme.green.opacity(0.3), radius: 26, x: 0, y: 10)
|
|
.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
|
|
}
|
|
}
|
|
}
|