guide/Guibe/WrittenInstructionsViewController.swift
2019-06-03 00:17:29 +01:00

58 lines
1.6 KiB
Swift

//
// 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.
}
}