WIP
This commit is contained in:
@@ -61,7 +61,9 @@ struct AddExerciseView: View {
|
||||
filteredExercises = exercises
|
||||
}
|
||||
.sheet(item: $videoExercise) { exercise in
|
||||
VideoPlayerView(currentExercise: exercise)
|
||||
if let url = URL(string: BaseURLs.dev.rawValue + exercise.videoURL) {
|
||||
VideoPlayerView(url: url)
|
||||
}
|
||||
}
|
||||
.sheet(item: $createWorkoutItemPickerViewModel) { item in
|
||||
CreateWorkoutItemPickerView(viewModel: item, completed: { selectedids in
|
||||
@@ -223,12 +225,20 @@ struct AddExerciseView: View {
|
||||
Button(action: {
|
||||
videoExercise = exercise
|
||||
}) {
|
||||
Image(systemName: "video.fill")
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(.blue)
|
||||
.frame(width: 44, height: 44)
|
||||
Image(systemName: "video.fill")
|
||||
.frame(width: 44, height: 44)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
}
|
||||
.frame(width: 22, height: 22)
|
||||
.frame(width: 44, height: 44)
|
||||
.background(.clear)
|
||||
.foregroundColor(.blue)
|
||||
|
||||
.cornerRadius(10)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,10 @@ struct AllWorkoutsView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if let workouts = workouts {
|
||||
if let workouts = workouts,
|
||||
let _ = DataStore.shared.allExercise,
|
||||
let _ = DataStore.shared.allMuscles,
|
||||
let _ = DataStore.shared.allEquipment {
|
||||
List {
|
||||
ForEach(workouts, id:\.name) { workout in
|
||||
VStack {
|
||||
@@ -44,7 +47,8 @@ struct AllWorkoutsView: View {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("no workouts")
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
}
|
||||
}.onAppear{
|
||||
maybeUpdateShit()
|
||||
|
||||
@@ -17,8 +17,9 @@ struct ExternalWorkoutDetailView: View {
|
||||
GeometryReader { metrics in
|
||||
VStack {
|
||||
HStack {
|
||||
if let currentExercise = bridgeModule.currentExercise {
|
||||
VideoPlayerView(currentExercise: currentExercise.exercise)
|
||||
if let currentExercise = bridgeModule.currentExercise,
|
||||
let url = URL(string: BaseURLs.dev.rawValue + currentExercise.exercise.videoURL) {
|
||||
VideoPlayerView(url: url)
|
||||
.frame(width: metrics.size.width * 0.6, height: metrics.size.height * 0.8)
|
||||
}
|
||||
|
||||
@@ -123,27 +124,6 @@ struct ExtCountdownView: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct VideoPlayerView: View {
|
||||
var currentExercise: ExerciseExercise
|
||||
@State var player = AVPlayer()
|
||||
|
||||
var body: some View {
|
||||
VideoPlayer(player: player)
|
||||
.onAppear{
|
||||
let url = URL(string: BaseURLs.dev.rawValue + currentExercise.videoURL)!
|
||||
player = AVPlayer(url: url)
|
||||
}
|
||||
.onAppear{
|
||||
player.play()
|
||||
|
||||
NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: nil, queue: .main) { _ in
|
||||
player.seek(to: .zero)
|
||||
player.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ExternalWorkoutDetailView_Previews: PreviewProvider {
|
||||
static var bridge = BridgeModule.shared
|
||||
|
||||
|
||||
50
Werkout_ios/Views/VideoPlayerView.swift
Normal file
50
Werkout_ios/Views/VideoPlayerView.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// VideoPlayerView.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 6/27/23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AVKit
|
||||
import SafariServices
|
||||
|
||||
struct VideoPlayerView: View {
|
||||
let url: URL
|
||||
@State var player: AVPlayer?
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Button(action: {
|
||||
dismiss()
|
||||
}, label: {
|
||||
Text("Done")
|
||||
})
|
||||
.padding()
|
||||
|
||||
SafariWebView(url: url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SafariWebView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
|
||||
func makeUIViewController(context: Context) -> SFSafariViewController {
|
||||
return SFSafariViewController(url: url)
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct VideoPlayerView_Previews: PreviewProvider {
|
||||
static let exercise = PreviewData.parseExercises().first!
|
||||
|
||||
static var previews: some View {
|
||||
VideoPlayerView(url: Bundle.main.url(forResource: "Straight_Leg_Sit_Up", withExtension: "mp4")!)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user