This commit is contained in:
Trey t
2023-08-12 13:41:53 -05:00
parent 4824fbc0fe
commit 2aa83f12f2
6 changed files with 89 additions and 6 deletions

View File

@@ -0,0 +1,40 @@
//
// AudioQueue.swift
// Werkout_ios
//
// Created by Trey Tartt on 8/12/23.
//
import Foundation
enum AudioType {
case shortBeep
case finishBeep
case remoteURL(URL)
}
struct AudioQueue: Codable, Identifiable, Equatable {
var id = UUID()
let playAt: Int
let audioURL: String
enum CodingKeys: String, CodingKey {
case playAt = "play_at"
case audioURL = "audio_url"
}
var audioType: AudioType {
if audioURL == "short_beep" {
return .shortBeep
} else if audioURL == "long_beep" {
return .finishBeep
} else {
if let url = URL(string: BaseURLs.currentBaseURL + "/media/" + audioURL) {
return .remoteURL(url)
} else {
return .shortBeep
}
}
}
}

View File

@@ -21,6 +21,7 @@ struct SupersetExercise: Identifiable, Codable, Equatable, Hashable {
let order, superset: Int?
let uniqueID: String?
let description: String?
let audioQueues: [AudioQueue]?
enum CodingKeys: String, CodingKey {
case workout, exercise, weight, reps, duration, order, superset, id, description
@@ -28,6 +29,7 @@ struct SupersetExercise: Identifiable, Codable, Equatable, Hashable {
case weightAudio = "weight_audio"
case createdAt = "created_at"
case uniqueID = "unique_id"
case audioQueues = "audio_queues"
}
public func hash(into hasher: inout Hasher) {
@@ -49,7 +51,7 @@ struct Exercise: Identifiable, Codable, Equatable {
let isDistance, isDuration, isReps: Bool
let jointsUsed, movementPatterns, equipmentRequired, muscleGroups: String
let synonyms: String?
enum CodingKeys: String, CodingKey {
case id, muscles, equipment
case audioURL = "audio_url"