TABLE VIEW DONEEEE!!!!!
This commit is contained in:
parent
60cc742779
commit
79cc73fc47
@ -329,7 +329,7 @@
|
|||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="100" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="402-5S-nhO">
|
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="100" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="402-5S-nhO">
|
||||||
<rect key="frame" x="0.0" y="305" width="414" height="591"/>
|
<rect key="frame" x="0.0" y="106" width="414" height="790"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<prototypes>
|
<prototypes>
|
||||||
@ -348,7 +348,7 @@
|
|||||||
<action selector="goPressed:" destination="87K-Xo-0a5" eventType="touchUpInside" id="fxz-cj-oJk"/>
|
<action selector="goPressed:" destination="87K-Xo-0a5" eventType="touchUpInside" id="fxz-cj-oJk"/>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mlZ-q9-9a8">
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mlZ-q9-9a8">
|
||||||
<rect key="frame" x="20" y="11" width="374" height="39"/>
|
<rect key="frame" x="20" y="11" width="374" height="39"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
|
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
|
||||||
@ -375,6 +375,13 @@
|
|||||||
<outlet property="delegate" destination="jBr-V0-GbL" id="JWz-Zv-Onp"/>
|
<outlet property="delegate" destination="jBr-V0-GbL" id="JWz-Zv-Onp"/>
|
||||||
</connections>
|
</connections>
|
||||||
</tableView>
|
</tableView>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Destinations" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="26H-72-eUL">
|
||||||
|
<rect key="frame" x="20" y="44" width="235" height="48"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
|
<fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
</subviews>
|
</subviews>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<viewLayoutGuide key="safeArea" id="WeT-3n-RQD"/>
|
<viewLayoutGuide key="safeArea" id="WeT-3n-RQD"/>
|
||||||
|
|||||||
@ -12,7 +12,12 @@ import MapKit
|
|||||||
import CoreLocation
|
import CoreLocation
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
|
|
||||||
class MainViewController: UIViewController, AVAudioPlayerDelegate {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MainViewController: UIViewController, AVAudioPlayerDelegate, myProtocol {
|
||||||
|
|
||||||
|
|
||||||
// DELETE
|
// DELETE
|
||||||
let defaults = UserDefaults.standard
|
let defaults = UserDefaults.standard
|
||||||
@ -35,6 +40,7 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate {
|
|||||||
|
|
||||||
var startedNavigation: Bool = false
|
var startedNavigation: Bool = false
|
||||||
|
|
||||||
|
var toLocationId: Int = -1
|
||||||
|
|
||||||
// OUTLETS--------------OUTLETS
|
// OUTLETS--------------OUTLETS
|
||||||
@IBOutlet weak var menuWindowView: UIView!
|
@IBOutlet weak var menuWindowView: UIView!
|
||||||
@ -48,8 +54,6 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate {
|
|||||||
@IBOutlet weak var micBtn: UIButton!
|
@IBOutlet weak var micBtn: UIButton!
|
||||||
// ---------------------
|
// ---------------------
|
||||||
@IBOutlet weak var mapView: MKMapView!
|
@IBOutlet weak var mapView: MKMapView!
|
||||||
@IBOutlet weak var tableView: UITableView!
|
|
||||||
|
|
||||||
// OUTLETS--------------OUTLETS
|
// OUTLETS--------------OUTLETS
|
||||||
|
|
||||||
// ACTIONS--------------ACTIONS
|
// ACTIONS--------------ACTIONS
|
||||||
@ -139,6 +143,10 @@ class MainViewController: UIViewController, AVAudioPlayerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startNavigation(toPlace: MKMapItem){
|
||||||
|
getDirections(to: toPlace)
|
||||||
|
}
|
||||||
|
|
||||||
} //END OF CLASS
|
} //END OF CLASS
|
||||||
|
|
||||||
|
|
||||||
@ -261,18 +269,23 @@ extension MainViewController: UISearchBarDelegate {
|
|||||||
let localSearch = MKLocalSearch(request: localSearchRequest)
|
let localSearch = MKLocalSearch(request: localSearchRequest)
|
||||||
localSearch.start { (response, _) in
|
localSearch.start { (response, _) in
|
||||||
guard let response = response else { return }
|
guard let response = response else { return }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let resultsViewController = self.storyboard?.instantiateViewController(withIdentifier: "resultsScreen") as! TableViewController
|
let resultsViewController = self.storyboard?.instantiateViewController(withIdentifier: "resultsScreen") as! TableViewController
|
||||||
resultsViewController.searchResults = response.mapItems
|
resultsViewController.searchResults = response.mapItems
|
||||||
resultsViewController.modalTransitionStyle = .coverVertical
|
resultsViewController.modalTransitionStyle = .coverVertical
|
||||||
|
resultsViewController.myProtocol = self
|
||||||
self.present(resultsViewController, animated: true, completion: nil)
|
self.present(resultsViewController, animated: true, completion: nil)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// guard let firstMapItem = response.mapItems.first else { return }
|
// guard let firstMapItem = response.mapItems.first else { return }
|
||||||
// self.getDirections(to: firstMapItem)
|
// self.getDirections(to: firstMapItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension MainViewController: MKMapViewDelegate {
|
extension MainViewController: MKMapViewDelegate {
|
||||||
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
|
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
|
||||||
if overlay is MKPolyline {
|
if overlay is MKPolyline {
|
||||||
|
|||||||
@ -9,15 +9,24 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import MapKit
|
import MapKit
|
||||||
|
|
||||||
|
protocol myProtocol {
|
||||||
|
func startNavigation(toPlace: MKMapItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TableViewController: UIViewController {
|
class TableViewController: UIViewController {
|
||||||
|
|
||||||
var searchResults: [MKMapItem]?
|
var searchResults: [MKMapItem]?
|
||||||
|
var myProtocol: myProtocol?
|
||||||
|
|
||||||
@IBOutlet weak var tableView: UITableView!
|
@IBOutlet weak var tableView: UITableView!
|
||||||
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
|
||||||
// let testData = appDelegate.navigationResults
|
// let testData = appDelegate.navigationResults
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +69,8 @@ extension TableViewController: UITableViewDataSource, UITableViewDelegate {
|
|||||||
|
|
||||||
extension TableViewController: tableViewProtocol {
|
extension TableViewController: tableViewProtocol {
|
||||||
func onClickCell(index: Int) {
|
func onClickCell(index: Int) {
|
||||||
print("Going to navigate to option \(index)")
|
debugPrint("Going to navigate to option \(index)")
|
||||||
|
self.myProtocol?.startNavigation(toPlace: (searchResults?[index])!)
|
||||||
|
self.dismiss(animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user