WIP
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct ExerciseElement: Codable {
|
||||
struct ExerciseElement: Codable, Equatable {
|
||||
let workout: Int
|
||||
let exercise: ExerciseExercise
|
||||
let weight: Int?
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Workout: Codable, Identifiable {
|
||||
struct Workout: Codable, Identifiable, Equatable {
|
||||
static func == (lhs: Workout, rhs: Workout) -> Bool {
|
||||
lhs.id == rhs.id
|
||||
}
|
||||
|
||||
let id: Int
|
||||
let name: String
|
||||
let description: String?
|
||||
|
||||
@@ -34,7 +34,8 @@ struct AddExerciseView: View {
|
||||
|
||||
TextField("Filter", text: $searchString)
|
||||
.padding()
|
||||
|
||||
.background(Color(uiColor: .systemBackground))
|
||||
|
||||
HStack {
|
||||
muscleView()
|
||||
.frame(maxWidth: .infinity)
|
||||
@@ -47,6 +48,7 @@ struct AddExerciseView: View {
|
||||
.padding(.top)
|
||||
.frame(height: 44)
|
||||
}
|
||||
.background(Color(uiColor: UIColor.secondarySystemBackground))
|
||||
.onAppear{
|
||||
if #function.hasPrefix("__preview") {
|
||||
DataStore.shared.setupFakeData()
|
||||
|
||||
@@ -10,22 +10,22 @@ import AVKit
|
||||
|
||||
struct ExternalWorkoutDetailView: View {
|
||||
@StateObject var bridgeModule = BridgeModule.shared
|
||||
|
||||
let videoPlayer = VideoPlayerView(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/Isometric_Bear_Crawl_with_Shoulder_Taps.mp4")!)
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if let workout = bridgeModule.currentWorkout {
|
||||
GeometryReader { metrics in
|
||||
VStack {
|
||||
HStack {
|
||||
if let currentExercise = bridgeModule.currentExercise,
|
||||
let url = URL(string: BaseURLs.dev.rawValue + currentExercise.exercise.videoURL) {
|
||||
VideoPlayerView(url: url)
|
||||
if let currentExercise = bridgeModule.currentExercise {
|
||||
videoPlayer
|
||||
.frame(width: metrics.size.width * 0.6, height: metrics.size.height * 0.8)
|
||||
}
|
||||
|
||||
ExtExerciseList(workout: workout,
|
||||
currentExerciseIdx: bridgeModule.currentExerciseIdx)
|
||||
.frame(width: metrics.size.width * 0.4, height: metrics.size.height * 0.8)
|
||||
|
||||
}
|
||||
|
||||
ExtCountdownView()
|
||||
@@ -38,6 +38,12 @@ struct ExternalWorkoutDetailView: View {
|
||||
Text("nothing here bro")
|
||||
}
|
||||
}
|
||||
.onChange(of: bridgeModule.currentExercise, perform: { newValue in
|
||||
if let newValue = newValue,
|
||||
let _videoURL = URL(string: BaseURLs.dev.rawValue + newValue.exercise.videoURL) {
|
||||
videoPlayer.updateVideoURL(url: _videoURL)
|
||||
}
|
||||
})
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(.background)
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ import AVKit
|
||||
import SafariServices
|
||||
|
||||
struct VideoPlayerView: View {
|
||||
let url: URL
|
||||
@State var player: AVPlayer?
|
||||
@State var url: URL
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
@@ -25,14 +24,18 @@ struct VideoPlayerView: View {
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color(uiColor: UIColor(red: 0.11, green: 0.11, blue: 0.12, alpha: 1)))
|
||||
|
||||
SafariWebView(url: url)
|
||||
SafariWebView(url: $url)
|
||||
}
|
||||
.background(.black)
|
||||
}
|
||||
|
||||
func updateVideoURL(url: URL) {
|
||||
self.url = url
|
||||
}
|
||||
}
|
||||
|
||||
struct SafariWebView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
@Binding var url: URL
|
||||
|
||||
func makeUIViewController(context: Context) -> SFSafariViewController {
|
||||
return SFSafariViewController(url: url)
|
||||
|
||||
Reference in New Issue
Block a user