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 textSteps: [MKRoute.Step]?
|
||||||
var currentStep: Int = 0
|
var currentStep: Int = 0
|
||||||
|
var naviStarted: Bool = false
|
||||||
|
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
|||||||
@ -87,6 +87,7 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
|
|||||||
}
|
}
|
||||||
// --------------------------
|
// --------------------------
|
||||||
@IBAction func startNaviPressed(_ sender: Any) {
|
@IBAction func startNaviPressed(_ sender: Any) {
|
||||||
|
self.appDelegate.naviStarted = true
|
||||||
self.startedNavigation = true
|
self.startedNavigation = true
|
||||||
self.stepCounter += 1
|
self.stepCounter += 1
|
||||||
|
|
||||||
@ -110,6 +111,7 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
|
|||||||
@IBAction func cancelBtnPressed(_ sender: Any) {
|
@IBAction func cancelBtnPressed(_ sender: Any) {
|
||||||
self.stepCounter = 0
|
self.stepCounter = 0
|
||||||
self.startedNavigation = false
|
self.startedNavigation = false
|
||||||
|
self.appDelegate.naviStarted = false
|
||||||
mapView.removeOverlays(mapView.overlays)
|
mapView.removeOverlays(mapView.overlays)
|
||||||
UIView.animate(withDuration: 0.3, animations: {
|
UIView.animate(withDuration: 0.3, animations: {
|
||||||
self.searchView.alpha = 1.0
|
self.searchView.alpha = 1.0
|
||||||
|
|||||||
@ -13,13 +13,19 @@ class WrittenInstructionsViewController: UIViewController, UITableViewDelegate,
|
|||||||
|
|
||||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||||
|
|
||||||
|
|
||||||
// var stepBySteps = appDelegate.currentStep
|
// var stepBySteps = appDelegate.currentStep
|
||||||
// var currentStep: Int = 0
|
// var currentStep: Int = 0
|
||||||
|
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
let stepBySteps = appDelegate.textSteps
|
if self.appDelegate.naviStarted == true{
|
||||||
return stepBySteps?.count ?? 0
|
let stepBySteps = appDelegate.textSteps
|
||||||
|
return stepBySteps?.count ?? 0}
|
||||||
|
else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
@ -27,11 +33,12 @@ class WrittenInstructionsViewController: UIViewController, UITableViewDelegate,
|
|||||||
let currentStep = appDelegate.currentStep
|
let currentStep = appDelegate.currentStep
|
||||||
let stepBySteps = appDelegate.textSteps
|
let stepBySteps = appDelegate.textSteps
|
||||||
let focusInstruction = (stepBySteps?[indexPath.row].instructions)!
|
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 == "" {
|
if focusInstruction == "" {
|
||||||
cell.textLabel?.text = "Start" }
|
cell.textLabel?.text = "Start, walk for \(focusDistance) meters" }
|
||||||
else {
|
else {
|
||||||
cell.textLabel?.text = "In \(focusDistance)m, \(focusInstruction)" }
|
cell.textLabel?.text = "Then in \(focusDistance)m, \(focusInstruction)" }
|
||||||
if indexPath.row == currentStep {
|
if indexPath.row == currentStep {
|
||||||
cell.backgroundColor = .green }
|
cell.backgroundColor = .green }
|
||||||
else {
|
else {
|
||||||
@ -56,7 +63,24 @@ class WrittenInstructionsViewController: UIViewController, UITableViewDelegate,
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.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.
|
// Do any additional setup after loading the view.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user