From b7d17a502da1c1606d44fe28717b62961d0dd6b1 Mon Sep 17 00:00:00 2001 From: Max Hunt Date: Wed, 29 May 2019 19:22:25 +0100 Subject: [PATCH] MOSTLY WORKSSSSS!!!!! --- .../AppIcon.appiconset/Contents.json | 80 ++++++++++++------- Guibe/MainViewController.swift | 35 ++++---- 2 files changed, 64 insertions(+), 51 deletions(-) diff --git a/Guibe/Assets.xcassets/AppIcon.appiconset/Contents.json b/Guibe/Assets.xcassets/AppIcon.appiconset/Contents.json index d8db8d6..18664e1 100644 --- a/Guibe/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Guibe/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,93 +1,111 @@ { "images" : [ - { - "idiom" : "iphone", + { "size" : "20x20", - "scale" : "2x" + "idiom": "iphone", + "filename" : "tLogo-20@2x.png", + "scale": "2x" }, - { - "idiom" : "iphone", + { "size" : "20x20", - "scale" : "3x" + "idiom": "iphone", + "filename" : "tLogo-20@3x.png", + "scale": "3x" + }, + { + "size" : "20x20", + "idiom": "ipad", + "filename" : "tLogo-20.png", + "scale": "1x" + }, + { + "size" : "20x20", + "idiom": "ipad", + "filename" : "tLogo-20@2x.png", + "scale": "2x" }, { - "idiom" : "iphone", "size" : "29x29", + "idiom" : "iphone", + "filename" : "tLogo-29@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "29x29", + "idiom" : "iphone", + "filename" : "tLogo-29@3x.png", "scale" : "3x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "tLogo-40@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "tLogo-40@3x.png", "scale" : "3x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "tLogo-60@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "tLogo-60@3x.png", "scale" : "3x" }, { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "tLogo-29.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "tLogo-29@2x.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "tLogo-40.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "tLogo-40@2x.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "tLogo-76.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "tLogo-76@2x.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "tLogo-83.5@2x.png", "scale" : "2x" }, { - "idiom" : "ios-marketing", "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "tLogo-1024.png", "scale" : "1x" } ], @@ -95,4 +113,4 @@ "version" : 1, "author" : "xcode" } -} \ No newline at end of file +} diff --git a/Guibe/MainViewController.swift b/Guibe/MainViewController.swift index 7b8c193..6fcfb03 100644 --- a/Guibe/MainViewController.swift +++ b/Guibe/MainViewController.swift @@ -53,13 +53,18 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate { override func viewDidLoad() { super.viewDidLoad() - self.searchBarBg.layer.shadowColor = UIColor.black.cgColor - self.searchBarBg.layer.cornerRadius = 10 - self.searchBarBg.layer.shadowOffset = CGSize(width: 5, height: 7) - self.searchBarBg.layer.shadowRadius = 10 - self.searchBarBg.layer.shadowOpacity = 0.2 + searchBar.delegate = self + searchBarBg.layer.shadowColor = UIColor.black.cgColor + searchBarBg.layer.cornerRadius = 10 + searchBarBg.layer.shadowOffset = CGSize(width: 5, height: 7) + searchBarBg.layer.shadowRadius = 10 + searchBarBg.layer.shadowOpacity = 0.2 - locationManager.delegate = (self as! CLLocationManagerDelegate) + mapView.delegate = self + + + + locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.startUpdatingLocation() @@ -105,27 +110,21 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate { } //END OF CLASS - -extension ViewController: CLLocationManagerDelegate { +extension MainViewController: CLLocationManagerDelegate { func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard let currentLocation = locations.first else { return } currentCoordinate = currentLocation.coordinate mapView.userTrackingMode = .follow if startedNavigation == true { - StepLabel.text = "On step: \(stepCounter)" let nextStep = steps[stepCounter] let nextCoord = CLLocation(latitude: nextStep.polyline.coordinate.latitude, longitude: nextStep.polyline.coordinate.longitude) distanceToNextCoord = currentLocation.distance(from: nextCoord) - devonLbl.text = String(format: "Distance to next waypoint: %.2f meters", distanceToNextCoord) - a.text = String(format: "%.2f", previousDistanceToWaypoint)//"\(previousDistanceToWaypoint)" - b.text = String(format: "%.2f", distanceToNextCoord)//"\(distanceToNextCoord)" if distanceToNextCoord < previousDistanceToWaypoint { previousDistanceToWaypoint = currentLocation.distance(from: nextCoord) } if distanceToNextCoord > previousDistanceToWaypoint + 10 { - devonLbl.text = String(format: "WRONG WAY (%.2f > %.2f)", distanceToNextCoord, previousDistanceToWaypoint+10) previousDistanceToWaypoint = distanceToNextCoord - 5 playTurnArd() } @@ -134,7 +133,6 @@ extension ViewController: CLLocationManagerDelegate { if stepCounter < steps.count { // let currentStep = steps[stepCounter] let message = "\(steps[stepCounter-1].instructions)" - directionsLabel.text = message let maneuverCommand = String(message.prefix(10)) switch (maneuverCommand) { case "Turn right": @@ -154,7 +152,6 @@ extension ViewController: CLLocationManagerDelegate { default: playErr() - currentStepLbl.text = "ERR: \(message)" break; } @@ -162,13 +159,10 @@ extension ViewController: CLLocationManagerDelegate { // speechSynthesizer.speak(speechUtterance) previousDistanceToWaypoint = 1000 } else { - let message = "Arrived at destination" - directionsLabel.text = message // let speechUtterance = AVSpeechUtterance(string: message) // speechSynthesizer.speak(speechUtterance) stepCounter = 0 previousDistanceToWaypoint = 1000 - cancelView.isHidden = true searchBar.isHidden = false // locationManager.monitoredRegions.forEach({ self.locationManager.stopMonitoring(for: $0) }) @@ -224,8 +218,9 @@ extension ViewController: CLLocationManagerDelegate { -extension ViewController: UISearchBarDelegate { +extension MainViewController: UISearchBarDelegate { func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { + print("Here2") searchBar.endEditing(true) //HIDES LE KEYBOARD let localSearchRequest = MKLocalSearch.Request() @@ -243,7 +238,7 @@ extension ViewController: UISearchBarDelegate { } -extension ViewController: MKMapViewDelegate { +extension MainViewController: MKMapViewDelegate { func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { if overlay is MKPolyline { let renderer = MKPolylineRenderer(overlay: overlay)