wip
This commit is contained in:
@ -40,7 +40,7 @@ struct WorkoutLogListView: View {
|
||||
CheckboxListItem(
|
||||
status: workoutLogStatus,
|
||||
title: log.exerciseName,
|
||||
subtitle: "\(log.sets) sets × \(log.reps) reps × \(log.weight) lbs"
|
||||
subtitle: "\(log.sets) × \(log.reps) reps × \(log.weight) lbs"
|
||||
)
|
||||
.swipeActions(edge: .leading, allowsFullSwipe: false) {
|
||||
let status = log.status ?? WorkoutStatus.notStarted
|
||||
@ -89,6 +89,21 @@ struct WorkoutLogListView: View {
|
||||
}
|
||||
|
||||
}
|
||||
.onMove(perform: { indices, destination in
|
||||
var workoutLogArray = Array(sortedWorkoutLogs)
|
||||
workoutLogArray.move(fromOffsets: indices, toOffset: destination)
|
||||
for (index, log) in workoutLogArray.enumerated() {
|
||||
log.order = index
|
||||
}
|
||||
if let modelContext = workoutLogArray.first?.modelContext {
|
||||
do {
|
||||
try modelContext.save()
|
||||
} catch {
|
||||
print("Error saving after reordering: \(error)")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,14 +186,14 @@ struct WorkoutLogListView: View {
|
||||
if let _ = workout.logs?.first(where: { $0.status != .completed }) {
|
||||
if let notStartedLogs = workout.logs?.filter({ $0.status == .notStarted }) {
|
||||
if notStartedLogs.count == workout.logs?.count ?? 0 {
|
||||
workout.status = .notStarted
|
||||
workout.status = WorkoutStatus.notStarted.rawValue
|
||||
}
|
||||
}
|
||||
if let _ = workout.logs?.first(where: { $0.status == .inProgress }) {
|
||||
workout.status = .inProgress
|
||||
workout.status = WorkoutStatus.inProgress.rawValue
|
||||
}
|
||||
} else {
|
||||
workout.status = .completed
|
||||
workout.status = WorkoutStatus.completed.rawValue
|
||||
workout.end = Date()
|
||||
}
|
||||
try? modelContext.save()
|
||||
|
@ -7,6 +7,8 @@
|
||||
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum WorkoutStatus: Int, Codable {
|
||||
case notStarted = 1
|
||||
case inProgress = 2
|
||||
|
Reference in New Issue
Block a user