minor SBS changes
This commit is contained in:
parent
d41826757d
commit
01ec4ac411
@ -16,6 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var textSteps: [MKRoute.Step]?
|
||||
var currentStep: Int = 0
|
||||
var naviStarted: Bool = false
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
|
||||
@ -87,6 +87,7 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
|
||||
}
|
||||
// --------------------------
|
||||
@IBAction func startNaviPressed(_ sender: Any) {
|
||||
self.appDelegate.naviStarted = true
|
||||
self.startedNavigation = true
|
||||
self.stepCounter += 1
|
||||
|
||||
@ -110,6 +111,7 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
|
||||
@IBAction func cancelBtnPressed(_ sender: Any) {
|
||||
self.stepCounter = 0
|
||||
self.startedNavigation = false
|
||||
self.appDelegate.naviStarted = false
|
||||
mapView.removeOverlays(mapView.overlays)
|
||||
UIView.animate(withDuration: 0.3, animations: {
|
||||
self.searchView.alpha = 1.0
|
||||
|
||||
@ -13,13 +13,19 @@ class WrittenInstructionsViewController: UIViewController, UITableViewDelegate,
|
||||
|
||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||
|
||||
|
||||
// var stepBySteps = appDelegate.currentStep
|
||||
// var currentStep: Int = 0
|
||||
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
if self.appDelegate.naviStarted == true{
|
||||
let stepBySteps = appDelegate.textSteps
|
||||
return stepBySteps?.count ?? 0
|
||||
return stepBySteps?.count ?? 0}
|
||||
else {
|
||||
return 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
@ -27,11 +33,12 @@ class WrittenInstructionsViewController: UIViewController, UITableViewDelegate,
|
||||
let currentStep = appDelegate.currentStep
|
||||
let stepBySteps = appDelegate.textSteps
|
||||
let focusInstruction = (stepBySteps?[indexPath.row].instructions)!
|
||||
let focusDistance = (stepBySteps?[indexPath.row].distance)!
|
||||
let focusDistance = Int((stepBySteps?[indexPath.row].distance)!)
|
||||
cell.textLabel?.adjustsFontSizeToFitWidth = true
|
||||
if focusInstruction == "" {
|
||||
cell.textLabel?.text = "Start" }
|
||||
cell.textLabel?.text = "Start, walk for \(focusDistance) meters" }
|
||||
else {
|
||||
cell.textLabel?.text = "In \(focusDistance)m, \(focusInstruction)" }
|
||||
cell.textLabel?.text = "Then in \(focusDistance)m, \(focusInstruction)" }
|
||||
if indexPath.row == currentStep {
|
||||
cell.backgroundColor = .green }
|
||||
else {
|
||||
@ -56,6 +63,23 @@ class WrittenInstructionsViewController: UIViewController, UITableViewDelegate,
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
if appDelegate.naviStarted == false {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
let alert = UIAlertController(title: "Not Navigating", message: "Please start navigation to see step by step instructions.", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
|
||||
switch action.style{
|
||||
case .default:
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
|
||||
case .cancel:
|
||||
return
|
||||
|
||||
case .destructive:
|
||||
return
|
||||
}}))
|
||||
self.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user