From f0e5a9c5a38353815b59688ed62407dd2921ab5f Mon Sep 17 00:00:00 2001 From: Max Hunt Date: Mon, 3 Jun 2019 00:17:29 +0100 Subject: [PATCH] added stepBySteps written view --- Guibe.xcodeproj/project.pbxproj | 8 + Guibe/AppDelegate.swift | 3 +- Guibe/Base.lproj/Main.storyboard | 138 +++++++++++++++++- Guibe/InstructionsViewController.swift | 29 ++++ Guibe/MainViewController.swift | 28 ++-- Guibe/TableViewController.swift | 2 +- Guibe/VideoInstrictionsViewController.swift | 35 +++++ Guibe/WrittenInstructionsViewController.swift | 57 ++++++++ 8 files changed, 281 insertions(+), 19 deletions(-) create mode 100644 Guibe/VideoInstrictionsViewController.swift create mode 100644 Guibe/WrittenInstructionsViewController.swift diff --git a/Guibe.xcodeproj/project.pbxproj b/Guibe.xcodeproj/project.pbxproj index 90c7ec3..5e40f2e 100644 --- a/Guibe.xcodeproj/project.pbxproj +++ b/Guibe.xcodeproj/project.pbxproj @@ -25,6 +25,8 @@ 50A7ADFF229D768900D58743 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50A7ADFE229D768900D58743 /* MainViewController.swift */; }; 50A7AE02229D7B1100D58743 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A7AE01229D7B1100D58743 /* MapKit.framework */; }; 50A9B4E1229E115B00070F61 /* Video.mov in Resources */ = {isa = PBXBuildFile; fileRef = 50A9B4E0229E115B00070F61 /* Video.mov */; }; + 50B1485C22A46EBD008B16AF /* WrittenInstructionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B1485B22A46EBD008B16AF /* WrittenInstructionsViewController.swift */; }; + 50B1485E22A46F7A008B16AF /* VideoInstrictionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B1485D22A46F7A008B16AF /* VideoInstrictionsViewController.swift */; }; 50C69B1122A16A7100EA99C1 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50C69B1022A16A7100EA99C1 /* TableViewController.swift */; }; 50C69B1322A19D8800EA99C1 /* NewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50C69B1222A19D8800EA99C1 /* NewTableViewCell.swift */; }; /* End PBXBuildFile section */ @@ -51,6 +53,8 @@ 50A7AE01229D7B1100D58743 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; 50A7AE05229D7B1E00D58743 /* Guibe.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Guibe.entitlements; sourceTree = ""; }; 50A9B4E0229E115B00070F61 /* Video.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = Video.mov; sourceTree = ""; }; + 50B1485B22A46EBD008B16AF /* WrittenInstructionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrittenInstructionsViewController.swift; sourceTree = ""; }; + 50B1485D22A46F7A008B16AF /* VideoInstrictionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoInstrictionsViewController.swift; sourceTree = ""; }; 50C69B1022A16A7100EA99C1 /* TableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = ""; }; 50C69B1222A19D8800EA99C1 /* NewTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTableViewCell.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -96,6 +100,8 @@ 50A7ADD6229D6A4200D58743 /* ViewController.swift */, 50A7ADE6229D6C7100D58743 /* Assets.xcassets */, 50A7ADD8229D6A4200D58743 /* Main.storyboard */, + 50B1485D22A46F7A008B16AF /* VideoInstrictionsViewController.swift */, + 50B1485B22A46EBD008B16AF /* WrittenInstructionsViewController.swift */, 50A7ADFE229D768900D58743 /* MainViewController.swift */, 505AFEF7229FE1BD004FF0F1 /* settingsViewController.swift */, 506421C822A33D87001E8877 /* InstructionsViewController.swift */, @@ -212,6 +218,8 @@ 50A7ADFD229D766800D58743 /* 7_ReadyViewController.swift in Sources */, 506421CD22A33EA5001E8877 /* TechSpecsViewController.swift in Sources */, 50A7ADF9229D75C100D58743 /* 5_HandChoiceViewController.swift in Sources */, + 50B1485E22A46F7A008B16AF /* VideoInstrictionsViewController.swift in Sources */, + 50B1485C22A46EBD008B16AF /* WrittenInstructionsViewController.swift in Sources */, 50A7ADD7229D6A4200D58743 /* ViewController.swift in Sources */, 50C69B1122A16A7100EA99C1 /* TableViewController.swift in Sources */, 50A7ADF5229D75A900D58743 /* 3_StartViewController.swift in Sources */, diff --git a/Guibe/AppDelegate.swift b/Guibe/AppDelegate.swift index dfc8b36..de50e3b 100644 --- a/Guibe/AppDelegate.swift +++ b/Guibe/AppDelegate.swift @@ -14,7 +14,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - var navigationResults: MKDirections.Response? + var textSteps: [MKRoute.Step]? + var currentStep: Int = 0 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { diff --git a/Guibe/Base.lproj/Main.storyboard b/Guibe/Base.lproj/Main.storyboard index 81ae29a..087876e 100644 --- a/Guibe/Base.lproj/Main.storyboard +++ b/Guibe/Base.lproj/Main.storyboard @@ -628,15 +628,11 @@ - + - - - - @@ -653,6 +649,39 @@ + + + + + + + @@ -662,6 +691,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -726,7 +853,6 @@ - diff --git a/Guibe/InstructionsViewController.swift b/Guibe/InstructionsViewController.swift index a40086b..0da7574 100644 --- a/Guibe/InstructionsViewController.swift +++ b/Guibe/InstructionsViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import MapKit class InstructionsViewController: UIViewController { @@ -14,9 +15,37 @@ class InstructionsViewController: UIViewController { self.dismiss(animated: true, completion: nil) } + @IBAction func writtenInstructionsBtnPressed(_ sender: Any) { +// let mvc = MainViewController() +// let ivc = WrittenInstructionsViewController() +// +// ivc.stepBySteps = mvc.textSteps +// ivc.currentStep = mvc.stepCounter + } + + @IBAction func VABtnPressed(_ sender: Any) { + + } + + +// ivc.stepBySteps = mvc.textSteps + +// var stepsText: [MKRoute.Step]? +// var currentStep: Int = 0 + override func viewDidLoad() { super.viewDidLoad() +// let mvc = MainViewController() +// let ivc = WrittenInstructionsViewController() +// +// print("-----InVC-----") +// print(stepsText) +// print(currentStep) +// +// ivc.stepBySteps = mvc.textSteps +// ivc.currentStep = mvc.stepCounter + // Do any additional setup after loading the view. } diff --git a/Guibe/MainViewController.swift b/Guibe/MainViewController.swift index 4f26ef2..d010088 100644 --- a/Guibe/MainViewController.swift +++ b/Guibe/MainViewController.swift @@ -38,6 +38,8 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol { var startedNavigation: Bool = false + var textSteps: [MKRoute.Step]? + // OUTLETS--------------OUTLETS @IBOutlet weak var menuWindowView: UIView! @@ -201,20 +203,12 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol { self.mapView.addOverlay(primaryRoute.polyline) -// directions.calculateETA { (etaResponse, error) -> Void in -// if let error = error { -// print("Error while requesting ETA : \(error.localizedDescription)") -// //travelTime = "Not Available" -// }else{ -// self.etaMinutes = Int((etaResponse?.expectedTravelTime)!/60) -// } -// } self.steps = primaryRoute.steps for i in 0 ..< primaryRoute.steps.count { let step = primaryRoute.steps[i] - print(step.instructions) - print(step.distance) +// print(step.instructions) +// print(step.distance) // -----------------------------Geofencing setup let region = CLCircularRegion(center: step.polyline.coordinate, radius: 15, @@ -226,11 +220,23 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol { } let travelTime = Int(primaryRoute.expectedTravelTime/60) -// let x = DateFormatter.localizedString(from: NSDate() as Date, dateStyle: DateFormatter.Style.none, timeStyle: DateFormatter.Style.short) let startDate = Date() let ETATime = startDate.addingTimeInterval(TimeInterval(travelTime*60)) let ETAVarLbl = DateFormatter.localizedString(from: ETATime, dateStyle: DateFormatter.Style.none, timeStyle: DateFormatter.Style.short) + self.textSteps = primaryRoute.steps + + self.appDelegate.textSteps = self.textSteps + self.appDelegate.currentStep = self.stepCounter + +// let ivc = self.storyboard?.instantiateViewController(withIdentifier: "ivc") as! InstructionsViewController +// let wivc = WrittenInstructionsViewController() +// wivc.stepBySteps = self.textSteps +// wivc.currentStep = self.stepCounter + +// ivc.stepsText = self.textSteps +// ivc.currentStep = self.stepCounter + self.etaLabel.text = "\(ETAVarLbl)" self.persEtaLbl.text = "\(ETAVarLbl)" diff --git a/Guibe/TableViewController.swift b/Guibe/TableViewController.swift index 4af6eca..11c399f 100644 --- a/Guibe/TableViewController.swift +++ b/Guibe/TableViewController.swift @@ -69,7 +69,7 @@ extension TableViewController: UITableViewDataSource, UITableViewDelegate { extension TableViewController: tableViewProtocol { func onClickCell(index: Int) { - debugPrint("Going to navigate to option \(index)") +// debugPrint("Going to navigate to option \(index)") self.myProtocol?.startNavigation(toPlace: (searchResults?[index])!) self.dismiss(animated: true, completion: nil) } diff --git a/Guibe/VideoInstrictionsViewController.swift b/Guibe/VideoInstrictionsViewController.swift new file mode 100644 index 0000000..72e9ad4 --- /dev/null +++ b/Guibe/VideoInstrictionsViewController.swift @@ -0,0 +1,35 @@ +// +// VideoInstrictionsViewController.swift +// Guibe +// +// Created by Max Hunt on 02/06/2019. +// Copyright © 2019 8. All rights reserved. +// + +import UIKit + +class VideoInstrictionsViewController: UIViewController { + + @IBAction func backBtnPressed(_ sender: Any) { + self.dismiss(animated: true, completion: nil) + } + + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/Guibe/WrittenInstructionsViewController.swift b/Guibe/WrittenInstructionsViewController.swift new file mode 100644 index 0000000..dcb213d --- /dev/null +++ b/Guibe/WrittenInstructionsViewController.swift @@ -0,0 +1,57 @@ +// +// WrittenInstructionsViewController.swift +// Guibe +// +// Created by Max Hunt on 02/06/2019. +// Copyright © 2019 8. All rights reserved. +// + +import UIKit +import MapKit + +class WrittenInstructionsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { + + let appDelegate = UIApplication.shared.delegate as! AppDelegate + +// var stepBySteps = appDelegate.currentStep +// var currentStep: Int = 0 + + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + let stepBySteps = appDelegate.textSteps + return stepBySteps?.count ?? 0 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "iCell", for: indexPath) + let currentStep = appDelegate.currentStep + let stepBySteps = appDelegate.textSteps + let focusInstruction = (stepBySteps?[indexPath.row].instructions)! + if focusInstruction == "" { + cell.textLabel?.text = "Start" } + else { + cell.textLabel?.text = focusInstruction } + if indexPath.row == currentStep { + cell.backgroundColor = .green } + else { + cell.backgroundColor = .white } + return cell + } + + + + + @IBAction func backBtnPressed(_ sender: Any) { + self.dismiss(animated: true, completion: nil) + } + + @IBOutlet weak var instructionsTable: UITableView! + + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } +} +