Stabilize iOS/watchOS/tvOS apps and add cross-platform audit remediation

This commit is contained in:
Trey t
2026-02-11 12:54:40 -06:00
parent e40275e694
commit acce712261
77 changed files with 2940 additions and 765 deletions

View File

@@ -8,100 +8,56 @@
import Foundation
class PreviewData {
private class func decodeFromBundle<T: Decodable>(_ fileName: String,
as type: T.Type) -> T? {
guard let filepath = Bundle.main.path(forResource: fileName, ofType: "json"),
let data = try? Data(NSData(contentsOfFile: filepath)) else {
return nil
}
return try? JSONDecoder().decode(T.self, from: data)
}
class func workout() -> Workout {
let filepath = Bundle.main.path(forResource: "WorkoutDetail", ofType: "json")!
let data = try! Data(NSData(contentsOfFile: filepath))
let workout = try! JSONDecoder().decode(Workout.self, from: data)
return workout
if let workout = decodeFromBundle("WorkoutDetail", as: Workout.self) {
return workout
}
if let firstWorkout = allWorkouts().first {
return firstWorkout
}
return Workout(id: -1, name: "Unavailable")
}
class func allWorkouts() -> [Workout] {
if let filepath = Bundle.main.path(forResource: "AllWorkouts", ofType: "json") {
do {
let data = try Data(NSData(contentsOfFile: filepath))
let workout = try JSONDecoder().decode([Workout].self, from: data)
return workout
} catch {
print(error)
fatalError()
}
} else {
fatalError()
}
decodeFromBundle("AllWorkouts", as: [Workout].self) ?? []
}
class func parseExercises() -> [Exercise] {
if let filepath = Bundle.main.path(forResource: "Exercises", ofType: "json") {
do {
let data = try Data(NSData(contentsOfFile: filepath))
let exercises = try JSONDecoder().decode([Exercise].self, from: data)
return exercises
} catch {
print(error)
fatalError()
}
} else {
fatalError()
}
decodeFromBundle("Exercises", as: [Exercise].self) ?? []
}
class func parseEquipment() -> [Equipment] {
if let filepath = Bundle.main.path(forResource: "Equipment", ofType: "json") {
do {
let data = try Data(NSData(contentsOfFile: filepath))
let equipment = try JSONDecoder().decode([Equipment].self, from: data)
return equipment
} catch {
print(error)
fatalError()
}
} else {
fatalError()
}
decodeFromBundle("Equipment", as: [Equipment].self) ?? []
}
class func parseMuscle() -> [Muscle] {
if let filepath = Bundle.main.path(forResource: "AllMuscles", ofType: "json") {
do {
let data = try Data(NSData(contentsOfFile: filepath))
let muscles = try JSONDecoder().decode([Muscle].self, from: data)
return muscles
} catch {
print(error)
fatalError()
}
} else {
fatalError()
}
decodeFromBundle("AllMuscles", as: [Muscle].self) ?? []
}
class func parseRegisterdUser() -> RegisteredUser {
if let filepath = Bundle.main.path(forResource: "RegisteredUser", ofType: "json") {
do {
let data = try Data(NSData(contentsOfFile: filepath))
let muscles = try JSONDecoder().decode(RegisteredUser.self, from: data)
return muscles
} catch {
print(error)
fatalError()
}
} else {
fatalError()
}
decodeFromBundle("RegisteredUser", as: RegisteredUser.self) ??
RegisteredUser(id: -1,
firstName: nil,
lastName: nil,
image: nil,
nickName: nil,
token: nil,
email: nil,
hasNSFWToggle: nil)
}
class func parseCompletedWorkouts() -> [CompletedWorkout] {
if let filepath = Bundle.main.path(forResource: "CompletedWorkouts", ofType: "json") {
do {
let data = try Data(NSData(contentsOfFile: filepath))
let muscles = try JSONDecoder().decode([CompletedWorkout].self, from: data)
return muscles
} catch {
print(error)
fatalError()
}
} else {
fatalError()
}
decodeFromBundle("CompletedWorkouts", as: [CompletedWorkout].self) ?? []
}
}

View File

@@ -7,5 +7,5 @@
"last_name": "test1_last",
"image": "",
"nick_name": "NickkkkName",
"token": "8f10a5b8c7532f7f8602193767b46a2625a85c52"
"token": "REDACTED_TOKEN"
}