From 9b6af9365054195ef0cdf22fcb35fd653b59783e Mon Sep 17 00:00:00 2001 From: Max Hunt Date: Wed, 29 May 2019 15:57:09 +0100 Subject: [PATCH] DoneTheSetup --- Guibe.xcodeproj/project.pbxproj | 8 --- Guibe/2_WelcomeViewController.swift | 13 ----- Guibe/3_StartViewController.swift | 57 +++++++++++++++++- Guibe/4_VideoViewController.swift | 70 +++++++++++++--------- Guibe/Base.lproj/Main.storyboard | 91 ++++++++--------------------- Guibe/ViewController.swift | 4 +- 6 files changed, 125 insertions(+), 118 deletions(-) diff --git a/Guibe.xcodeproj/project.pbxproj b/Guibe.xcodeproj/project.pbxproj index d5bc210..5ab66c8 100644 --- a/Guibe.xcodeproj/project.pbxproj +++ b/Guibe.xcodeproj/project.pbxproj @@ -12,9 +12,7 @@ 50A7ADDA229D6A4200D58743 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50A7ADD8229D6A4200D58743 /* Main.storyboard */; }; 50A7ADDF229D6A4200D58743 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50A7ADDD229D6A4200D58743 /* LaunchScreen.storyboard */; }; 50A7ADE7229D6C7100D58743 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50A7ADE6229D6C7100D58743 /* Assets.xcassets */; }; - 50A7ADF3229D759F00D58743 /* 2_WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A7ADF2229D759F00D58743 /* 2_WelcomeViewController.swift */; }; 50A7ADF5229D75A900D58743 /* 3_StartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A7ADF4229D75A900D58743 /* 3_StartViewController.swift */; }; - 50A7ADF7229D75B600D58743 /* 4_VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A7ADF6229D75B600D58743 /* 4_VideoViewController.swift */; }; 50A7ADF9229D75C100D58743 /* 5_HandChoiceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A7ADF8229D75C100D58743 /* 5_HandChoiceViewController.swift */; }; 50A7ADFB229D75E900D58743 /* 6_SideChoiceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A7ADFA229D75E900D58743 /* 6_SideChoiceViewController.swift */; }; 50A7ADFD229D766800D58743 /* 7_ReadyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A7ADFC229D766800D58743 /* 7_ReadyViewController.swift */; }; @@ -31,9 +29,7 @@ 50A7ADDE229D6A4200D58743 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50A7ADE0229D6A4200D58743 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50A7ADE6229D6C7100D58743 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 50A7ADF2229D759F00D58743 /* 2_WelcomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 2_WelcomeViewController.swift; sourceTree = ""; }; 50A7ADF4229D75A900D58743 /* 3_StartViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 3_StartViewController.swift; sourceTree = ""; }; - 50A7ADF6229D75B600D58743 /* 4_VideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 4_VideoViewController.swift; sourceTree = ""; }; 50A7ADF8229D75C100D58743 /* 5_HandChoiceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 5_HandChoiceViewController.swift; sourceTree = ""; }; 50A7ADFA229D75E900D58743 /* 6_SideChoiceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 6_SideChoiceViewController.swift; sourceTree = ""; }; 50A7ADFC229D766800D58743 /* 7_ReadyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 7_ReadyViewController.swift; sourceTree = ""; }; @@ -83,9 +79,7 @@ 50A7ADD8229D6A4200D58743 /* Main.storyboard */, 50A7ADFE229D768900D58743 /* MainViewController.swift */, 50A7ADFC229D766800D58743 /* 7_ReadyViewController.swift */, - 50A7ADF2229D759F00D58743 /* 2_WelcomeViewController.swift */, 50A7ADF4229D75A900D58743 /* 3_StartViewController.swift */, - 50A7ADF6229D75B600D58743 /* 4_VideoViewController.swift */, 50A7ADF8229D75C100D58743 /* 5_HandChoiceViewController.swift */, 50A7ADFA229D75E900D58743 /* 6_SideChoiceViewController.swift */, 50A7ADDD229D6A4200D58743 /* LaunchScreen.storyboard */, @@ -192,10 +186,8 @@ 50A7ADF9229D75C100D58743 /* 5_HandChoiceViewController.swift in Sources */, 50A7ADD7229D6A4200D58743 /* ViewController.swift in Sources */, 50A7ADF5229D75A900D58743 /* 3_StartViewController.swift in Sources */, - 50A7ADF3229D759F00D58743 /* 2_WelcomeViewController.swift in Sources */, 50A7ADD5229D6A4200D58743 /* AppDelegate.swift in Sources */, 50A7ADFF229D768900D58743 /* MainViewController.swift in Sources */, - 50A7ADF7229D75B600D58743 /* 4_VideoViewController.swift in Sources */, 50A7ADFB229D75E900D58743 /* 6_SideChoiceViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Guibe/2_WelcomeViewController.swift b/Guibe/2_WelcomeViewController.swift index 531fd4b..ad3b3a2 100644 --- a/Guibe/2_WelcomeViewController.swift +++ b/Guibe/2_WelcomeViewController.swift @@ -33,19 +33,6 @@ class W2lcomeViewController: UIViewController, CLLocationManagerDelegate { // Do any additional setup after loading the view. } - func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { - if status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse{ - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen3") as! S3artViewController - nextViewController.modalTransitionStyle = .crossDissolve - self.present(nextViewController, animated: true, completion: nil) - } - } - if status == CLAuthorizationStatus.denied{ - //bad - - } - } /* // MARK: - Navigation diff --git a/Guibe/3_StartViewController.swift b/Guibe/3_StartViewController.swift index 0c91cbb..e805f0a 100644 --- a/Guibe/3_StartViewController.swift +++ b/Guibe/3_StartViewController.swift @@ -7,21 +7,61 @@ // import UIKit +import CoreLocation +import AVKit -class S3artViewController: UIViewController { +class S3artViewController: UIViewController, CLLocationManagerDelegate { + + @IBOutlet var getStartedBtn: UIButton! + @IBOutlet var playAgainBtn: UIButton! + @IBOutlet var nextBtn: UIButton! + + + let locationManager = CLLocationManager() @IBAction func startBtnPressed(_ sender: Any) { - let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen4") as! V4deoViewController + DispatchQueue.main.asyncAfter(deadline: .now() + 1){ + self.getStartedBtn.isHidden = true + self.playAgainBtn.isHidden = false + self.nextBtn.isHidden = false + } + playVideo() + + + + } + @IBAction func playAgainBtnPressed(_ sender: Any) { + playVideo() + } + @IBAction func nextBtnPressed(_ sender: Any) { + let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen5") as! H5ndChoiceViewController nextViewController.modalTransitionStyle = .crossDissolve self.present(nextViewController, animated: true, completion: nil) } + + + override func viewDidLoad() { super.viewDidLoad() +// self.locationManager.delegate = self + self.locationManager.requestAlwaysAuthorization() + // Do any additional setup after loading the view. } - + private func playVideo() { + guard let path = Bundle.main.path(forResource: "Video", ofType:"mov") else { + debugPrint("Video.mov not found") + return } + let player = AVPlayer(url: URL(fileURLWithPath: path)) + let playerController = AVPlayerViewController() + playerController.player = player +// playerController.modalPresentationStyle = .popover + present(playerController, animated: true) { + player.play() + } + } /* // MARK: - Navigation @@ -33,3 +73,14 @@ class S3artViewController: UIViewController { */ } + +/* +class W2lcomeViewController: UIViewController, CLLocationManagerDelegate { + + let locationManager = CLLocationManager() + + override func viewDidLoad() { + super.viewDidLoad() + // sleep(1) + self.locationManager.requestAlwaysAuthorization() +*/ diff --git a/Guibe/4_VideoViewController.swift b/Guibe/4_VideoViewController.swift index 6fe11a7..94d5b80 100644 --- a/Guibe/4_VideoViewController.swift +++ b/Guibe/4_VideoViewController.swift @@ -11,40 +11,58 @@ import AVKit import AVFoundation class V4deoViewController: UIViewController { - @IBOutlet var videoBtn: UIButton! - @IBOutlet var nextBtn: UIButton! +// @IBOutlet var videoBtn: UIButton! +// @IBOutlet var nextBtn: UIButton! + @IBOutlet weak var videoPreviewLayer: UIView! + + var player: AVPlayer! + var avpController = AVPlayerViewController() override func viewDidLoad() { super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - @IBAction func nextBtnPressed(_ sender: Any) { - let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen5") as! H5ndChoiceViewController - nextViewController.modalTransitionStyle = .crossDissolve - self.present(nextViewController, animated: true, completion: nil) - } - @IBAction func videoBtnPress(_ sender: Any) { - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - self.videoBtn.isHidden = true - self.nextBtn.isHidden = false} - playVideo() - } - - private func playVideo() { guard let path = Bundle.main.path(forResource: "Video", ofType:"mov") else { debugPrint("Video.mov not found") return } - let player = AVPlayer(url: URL(fileURLWithPath: path)) - let playerController = AVPlayerViewController() - playerController.player = player -// playerController.modalPresentationStyle = .popover - present(playerController, animated: true) { - player.play() - } + + self.player = AVPlayer(url: URL(fileURLWithPath: path)) + self.avpController = AVPlayerViewController() + self.avpController.player = self.player + avpController.view.frame = videoPreviewLayer.frame + self.addChild(avpController) + self.view.addSubview(avpController.view) + + // Do any additional setup after loading the view. } + +// @IBAction func nextBtnPressed(_ sender: Any) { +// let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen5") as! H5ndChoiceViewController +// nextViewController.modalTransitionStyle = .crossDissolve +// self.present(nextViewController, animated: true, completion: nil) +// } +// @IBAction func videoBtnPress(_ sender: Any) { +// DispatchQueue.main.asyncAfter(deadline: .now() + 1) { +// self.videoBtn.isHidden = true +// self.nextBtn.isHidden = false} +// playVideo() +// } + + + + +// private func playVideo() { +// guard let path = Bundle.main.path(forResource: "Video", ofType:"mov") else { +// debugPrint("Video.mov not found") +// return +// } +// let player = AVPlayer(url: URL(fileURLWithPath: path)) +// let playerController = AVPlayerViewController() +// playerController.player = player +//// playerController.modalPresentationStyle = .popover +// present(playerController, animated: true) { +// player.play() +// } +// } /* // MARK: - Navigation diff --git a/Guibe/Base.lproj/Main.storyboard b/Guibe/Base.lproj/Main.storyboard index 387afbc..aa3070d 100644 --- a/Guibe/Base.lproj/Main.storyboard +++ b/Guibe/Base.lproj/Main.storyboard @@ -31,27 +31,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -72,54 +51,35 @@ + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + @@ -158,7 +118,7 @@ - + @@ -197,7 +157,7 @@ - + @@ -225,7 +185,7 @@ - + @@ -260,6 +220,5 @@ - diff --git a/Guibe/ViewController.swift b/Guibe/ViewController.swift index 64131b5..88b2a02 100644 --- a/Guibe/ViewController.swift +++ b/Guibe/ViewController.swift @@ -19,7 +19,7 @@ class ViewController: UIViewController { if setupDone != 2 { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { - let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen2") as! W2lcomeViewController + let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen3") as! S3artViewController nextViewController.modalTransitionStyle = .crossDissolve self.present(nextViewController, animated: true, completion: nil) } @@ -27,7 +27,7 @@ class ViewController: UIViewController { if setupDone == 2 { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { - let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "mainView") as! MainViewController + let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "mainScreen") as! MainViewController nextViewController.modalTransitionStyle = .crossDissolve self.present(nextViewController, animated: true, completion: nil) }