WIP
This commit is contained in:
@@ -395,6 +395,8 @@
|
|||||||
1CF65A9F2A452D290042FFBD /* PBXTargetDependency */,
|
1CF65A9F2A452D290042FFBD /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
name = Werkout_ios;
|
name = Werkout_ios;
|
||||||
|
packageProductDependencies = (
|
||||||
|
);
|
||||||
productName = Werkout_ios;
|
productName = Werkout_ios;
|
||||||
productReference = 1CF65A222A3972840042FFBD /* Werkout_ios.app */;
|
productReference = 1CF65A222A3972840042FFBD /* Werkout_ios.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
@@ -443,6 +445,8 @@
|
|||||||
Base,
|
Base,
|
||||||
);
|
);
|
||||||
mainGroup = 1CF65A192A3972840042FFBD;
|
mainGroup = 1CF65A192A3972840042FFBD;
|
||||||
|
packageReferences = (
|
||||||
|
);
|
||||||
productRefGroup = 1CF65A232A3972840042FFBD /* Products */;
|
productRefGroup = 1CF65A232A3972840042FFBD /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
|
|||||||
@@ -10,17 +10,20 @@ 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")!)
|
@State var videoURL = URL(string: "https://dev.werkout.fitness/media/exercise_videos/recovery.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 {
|
VideoViewControllerView(url: $videoURL)
|
||||||
videoPlayer
|
.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)
|
// if let videoPlayer = videoPlayer {
|
||||||
}
|
// videoPlayer
|
||||||
|
// .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)
|
||||||
@@ -39,9 +42,9 @@ struct ExternalWorkoutDetailView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: bridgeModule.currentExercise, perform: { newValue in
|
.onChange(of: bridgeModule.currentExercise, perform: { newValue in
|
||||||
if let newValue = newValue,
|
if let viddd = newValue?.exercise.videoURL,
|
||||||
let _videoURL = URL(string: BaseURLs.dev.rawValue + newValue.exercise.videoURL) {
|
let url = URL(string: BaseURLs.dev.rawValue + viddd) {
|
||||||
videoPlayer.updateVideoURL(url: _videoURL)
|
videoURL = url
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
|||||||
@@ -24,33 +24,69 @@ 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)
|
VideoViewControllerView(url: $url)
|
||||||
}
|
}
|
||||||
.background(.black)
|
.background(.black)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateVideoURL(url: URL) {
|
|
||||||
self.url = url
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SafariWebView: UIViewControllerRepresentable {
|
struct VideoViewControllerView: UIViewControllerRepresentable {
|
||||||
@Binding var url: URL
|
@Binding var url: URL
|
||||||
|
|
||||||
func makeUIViewController(context: Context) -> SFSafariViewController {
|
func makeUIViewController(context: Context) -> VideoViewController {
|
||||||
return SFSafariViewController(url: url)
|
return VideoViewController(videoURL: url)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
|
func updateUIViewController(_ uiViewController: VideoViewController, context: Context) {
|
||||||
|
if url != uiViewController.videoURL {
|
||||||
|
uiViewController.videoURL = url
|
||||||
|
uiViewController.layoutView()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class VideoViewController: UIViewController {
|
||||||
|
var videoURL: URL
|
||||||
|
|
||||||
struct VideoPlayerView_Previews: PreviewProvider {
|
init(videoURL: URL) {
|
||||||
static let exercise = PreviewData.parseExercises().first!
|
self.videoURL = videoURL
|
||||||
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
layoutView()
|
||||||
|
}
|
||||||
|
|
||||||
static var previews: some View {
|
required init?(coder: NSCoder) {
|
||||||
VideoPlayerView(url: Bundle.main.url(forResource: "Straight_Leg_Sit_Up", withExtension: "mp4")!)
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
}
|
||||||
|
|
||||||
|
func layoutView() {
|
||||||
|
self.view.subviews.forEach({
|
||||||
|
$0.removeFromSuperview()
|
||||||
|
})
|
||||||
|
|
||||||
|
let sfVC = SFSafariViewController(url: self.videoURL)
|
||||||
|
sfVC.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
view.backgroundColor = .green
|
||||||
|
self.addChild(sfVC)
|
||||||
|
sfVC.didMove(toParent: self)
|
||||||
|
sfVC.view.backgroundColor = .magenta
|
||||||
|
sfVC.view.frame = self.view.bounds;
|
||||||
|
self.view.addSubview(sfVC.view)
|
||||||
|
sfVC.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
|
||||||
|
sfVC.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
|
||||||
|
sfVC.view.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
|
||||||
|
sfVC.view.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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