WIP
This commit is contained in:
@@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
class AllWorkoutFetchable: Fetchable {
|
||||
typealias Response = [Workout]
|
||||
var endPoint: String = "workout/all/"
|
||||
var endPoint: String = "/workout/all/"
|
||||
}
|
||||
|
||||
class WorkoutDetailFetchable: Fetchable {
|
||||
@@ -17,28 +17,28 @@ class WorkoutDetailFetchable: Fetchable {
|
||||
var endPoint: String
|
||||
|
||||
init(workoutID: Int) {
|
||||
self.endPoint = "workout/"+String(workoutID)+"/details/"
|
||||
self.endPoint = "/workout/"+String(workoutID)+"/details/"
|
||||
}
|
||||
}
|
||||
|
||||
class AllMusclesFetchable: Fetchable {
|
||||
typealias Response = [Muscle]
|
||||
var endPoint: String = "muscle/all/"
|
||||
var endPoint: String = "/muscle/all/"
|
||||
}
|
||||
|
||||
class AllEquipmentFetchable: Fetchable {
|
||||
typealias Response = [Equipment]
|
||||
var endPoint: String = "equipment/all/"
|
||||
var endPoint: String = "/equipment/all/"
|
||||
}
|
||||
|
||||
class AllExerciseFetchable: Fetchable {
|
||||
typealias Response = [ExerciseExercise]
|
||||
var endPoint: String = "exercise/all/"
|
||||
var endPoint: String = "/exercise/all/"
|
||||
}
|
||||
|
||||
class CompletedWorkoutFetchable: Fetchable {
|
||||
typealias Response = [CompletedWorkout]
|
||||
var endPoint: String = "workout/completed/"
|
||||
var endPoint: String = "/workout/completed/"
|
||||
}
|
||||
|
||||
class CreateWorkoutFetchable: Postable {
|
||||
@@ -46,7 +46,7 @@ class CreateWorkoutFetchable: Postable {
|
||||
var successStatus = 201
|
||||
|
||||
typealias Response = Workout
|
||||
var endPoint: String = "workout/create/"
|
||||
var endPoint: String = "/workout/create/"
|
||||
|
||||
init(postData: [String: Any]) {
|
||||
self.postableData = postData
|
||||
@@ -58,7 +58,7 @@ class CompleteWorkoutFetchable: Postable {
|
||||
var successStatus = 201
|
||||
|
||||
typealias Response = CompletedWorkout
|
||||
var endPoint: String = "workout/complete/"
|
||||
var endPoint: String = "/workout/complete/"
|
||||
|
||||
init(postData: [String: Any]) {
|
||||
self.postableData = postData
|
||||
@@ -70,7 +70,7 @@ class LoginFetchable: Postable {
|
||||
var successStatus = 200
|
||||
|
||||
typealias Response = RegisteredUser
|
||||
var endPoint: String = "registered_user/login/"
|
||||
var endPoint: String = "/registered_user/login/"
|
||||
|
||||
var attachToken: Bool {
|
||||
return false
|
||||
|
||||
@@ -37,7 +37,7 @@ protocol Postable: Fetchable {
|
||||
|
||||
extension Fetchable {
|
||||
var baseURL: String {
|
||||
BaseURLs.local.rawValue
|
||||
BaseURLs.dev.rawValue
|
||||
}
|
||||
|
||||
var attachToken: Bool {
|
||||
|
||||
@@ -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")!)
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ struct Werkout_iosApp: App {
|
||||
.tag(3)
|
||||
}
|
||||
.onAppear{
|
||||
|
||||
// UserStore.shared.logout()
|
||||
}
|
||||
.onReceive(pub) { (output) in
|
||||
self.tabSelection = 1
|
||||
|
||||
Reference in New Issue
Block a user