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