Fix 28 issues from deep audit and UI audit + redesign changes
Some checks failed
Apple Platform CI / smoke-and-tests (push) Has been cancelled
Some checks failed
Apple Platform CI / smoke-and-tests (push) Has been cancelled
Deep audit (issues 2-14): - Add missing WCSession handlers for applicationContext and userInfo - Fix BoundedFIFOQueue race condition with serial dispatch queue - Fix timer race condition with main thread guarantee - Fix watch pause state divergence — phone is now source of truth - Fix wrong notification posted on logout (createdNewWorkout → userLoggedOut) - Fix POST status check to accept any 2xx (was exact match) - Fix @StateObject → @ObservedObject for injected viewModel - Add pull-to-refresh to CompletedWorkoutsView - Fix typos: RefreshUserInfoFetcable, defualtPackageModle - Replace string concatenation with interpolation - Replace 6 @StateObject with @ObservedObject for BridgeModule.shared - Replace 7 hardcoded AVPlayer URLs with BaseURLs.currentBaseURL UI audit (issues 1-15): - Fix GeometryReader eating VStack space — replaced with .overlay - Fix refreshable continuation resuming before fetch completes - Remove duplicate @State workouts — derive from DataStore - Decouple leaf views from BridgeModule (pass discrete values) - Convert selectedIds from Array to Set for O(1) lookups - Extract .sorted() from var body into computed properties - Move search filter out of ForEach render loop - Replace import SwiftUI with import Combine in non-UI classes - Mark all @State properties private - Extract L/R exercise auto-add logic to WorkoutViewModel - Use enumerated() instead of .indices in ForEach - Make AddSupersetView frame flexible instead of fixed 300pt - Hoist Set construction out of per-exercise filter loop - Move ViewModel network fetch from init to load() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,15 +11,15 @@ import SharedCore
|
||||
|
||||
struct CompletedWorkoutView: View {
|
||||
@ObservedObject var bridgeModule = BridgeModule.shared
|
||||
@State var healthKitWorkoutData: HealthKitWorkoutData?
|
||||
@State var difficulty: Float = 0
|
||||
@State var notes: String = ""
|
||||
@State var isUploading: Bool = false
|
||||
@State var gettingHealthKitData: Bool = false
|
||||
@State private var healthKitWorkoutData: HealthKitWorkoutData?
|
||||
@State private var difficulty: Float = 0
|
||||
@State private var notes: String = ""
|
||||
@State private var isUploading: Bool = false
|
||||
@State private var gettingHealthKitData: Bool = false
|
||||
@State private var hasError = false
|
||||
@State private var errorMessage = ""
|
||||
private let runtimeReporter = RuntimeReporter.shared
|
||||
|
||||
|
||||
var postData: [String: Any]
|
||||
let healthKitHelper = HealthKitHelper()
|
||||
let workout: Workout
|
||||
@@ -29,48 +29,65 @@ struct CompletedWorkoutView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
WerkoutTheme.background
|
||||
.ignoresSafeArea()
|
||||
|
||||
if isUploading {
|
||||
ProgressView("Uploading")
|
||||
.foregroundStyle(WerkoutTheme.textPrimary)
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: WerkoutTheme.accent))
|
||||
}
|
||||
VStack {
|
||||
WorkoutInfoView(workout: workout)
|
||||
|
||||
|
||||
Divider()
|
||||
|
||||
.overlay(WerkoutTheme.divider)
|
||||
|
||||
HStack {
|
||||
if let calsBurned = healthKitWorkoutData?.caloriesBurned {
|
||||
CaloriesBurnedView(healthKitWorkoutData: $healthKitWorkoutData,
|
||||
calsBurned: calsBurned)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RateWorkoutView(difficulty: $difficulty)
|
||||
.frame(maxHeight: 88)
|
||||
|
||||
|
||||
Divider()
|
||||
|
||||
.overlay(WerkoutTheme.divider)
|
||||
|
||||
TextField("Notes", text: $notes)
|
||||
.font(WerkoutTheme.bodyText)
|
||||
.foregroundStyle(WerkoutTheme.textPrimary)
|
||||
.frame(height: 55)
|
||||
.textFieldStyle(PlainTextFieldStyle())
|
||||
.padding([.horizontal], 4)
|
||||
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 200/255, green: 200/255, blue: 200/255, alpha: 0.2)))
|
||||
.cornerRadius(8)
|
||||
|
||||
.background(WerkoutTheme.surfaceElevated)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: WerkoutTheme.buttonRadius, style: .continuous)
|
||||
.strokeBorder(WerkoutTheme.divider, lineWidth: 1)
|
||||
)
|
||||
.clipShape(RoundedRectangle(cornerRadius: WerkoutTheme.buttonRadius, style: .continuous))
|
||||
|
||||
if gettingHealthKitData {
|
||||
ProgressView("Getting HealthKit data")
|
||||
.foregroundStyle(WerkoutTheme.textPrimary)
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: WerkoutTheme.accent))
|
||||
.padding()
|
||||
}
|
||||
|
||||
|
||||
Spacer()
|
||||
|
||||
|
||||
Button("Upload", action: {
|
||||
upload(postBody: postData)
|
||||
})
|
||||
.font(.system(size: 16, weight: .bold))
|
||||
.foregroundStyle(WerkoutTheme.textPrimary)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.frame(height: 44)
|
||||
.foregroundColor(.blue)
|
||||
.background(.yellow)
|
||||
.cornerRadius(Constants.buttonRadius)
|
||||
.glassEffect(.regular.interactive())
|
||||
.tint(WerkoutTheme.success)
|
||||
.clipShape(RoundedRectangle(cornerRadius: WerkoutTheme.buttonRadius, style: .continuous))
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
.disabled(isUploading || gettingHealthKitData)
|
||||
@@ -82,19 +99,6 @@ struct CompletedWorkoutView: View {
|
||||
} message: {
|
||||
Text(errorMessage)
|
||||
}
|
||||
// .onChange(of: bridgeModule.healthKitUUID, perform: { healthKitUUID in
|
||||
// if let healthKitUUID = healthKitUUID {
|
||||
// gettingHealthKitData = true
|
||||
// healthKitHelper.getDetails(forHealthKitUUID: healthKitUUID,
|
||||
// completion: { healthKitWorkoutData in
|
||||
// guard let healthStore = healthKitWorkoutData else {
|
||||
// return
|
||||
// }
|
||||
// self.healthKitWorkoutData = healthKitWorkoutData
|
||||
// gettingHealthKitData = false
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
func upload(postBody: [String: Any]) {
|
||||
@@ -143,9 +147,9 @@ struct CompletedWorkoutView_Previews: PreviewProvider {
|
||||
"total_calories": Float(120.0),
|
||||
"heart_rates": [65,65,4,54,232,12]
|
||||
] as [String : Any]
|
||||
|
||||
|
||||
static let workout = PreviewData.workout()
|
||||
|
||||
|
||||
static var previews: some View {
|
||||
CompletedWorkoutView(postData: CompletedWorkoutView_Previews.postBody,
|
||||
workout: workout,
|
||||
|
||||
Reference in New Issue
Block a user