// // 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)! let focusDistance = (stepBySteps?[indexPath.row].distance)! if focusInstruction == "" { cell.textLabel?.text = "Start" } else { cell.textLabel?.text = "In \(focusDistance)m, \(focusInstruction)" } if indexPath.row == currentStep { cell.backgroundColor = .green } else { cell.backgroundColor = .white } return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { // Maybe speak this? self.dismiss(animated: true, completion: nil) } @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. } }