This commit is contained in:
2025-07-19 16:42:47 -04:00
parent 6e46775f58
commit e3c3f2c6f0
38 changed files with 556 additions and 367 deletions

View File

@ -5,20 +5,25 @@ import SwiftData
final class Workout {
var start: Date = Date()
var end: Date?
var status: WorkoutStatus? = WorkoutStatus.notStarted
@Relationship(deleteRule: .nullify)
var split: Split?
@Relationship(deleteRule: .cascade, inverse: \WorkoutLog.workout)
var logs: [WorkoutLog]? = []
init(start: Date, end: Date? = nil, split: Split?) {
init(start: Date, end: Date, split: Split?) {
self.start = start
self.end = end
self.split = split
}
var label: String {
start.formattedDate()
if status == .completed, let endDate = end {
return "\(start.formattedDate())\(endDate.formattedDate())"
} else {
return start.formattedDate()
}
}
}