Show voice record event on map
This commit is contained in:
parent
56e4fb48d0
commit
9faa57a4eb
@ -93,6 +93,7 @@
|
||||
7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8B2435C38700258F61 /* CustomTextField.swift */; };
|
||||
7AB67E8E2435D1A000258F61 /* CustomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8D2435D1A000258F61 /* CustomButton.swift */; };
|
||||
7ADF6C93250B954900F237B2 /* Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADF6C92250B954900F237B2 /* Navigation.swift */; };
|
||||
7ADF6C95250D037700F237B2 /* ShowEventController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADF6C94250D037700F237B2 /* ShowEventController.swift */; };
|
||||
7AE26A3324EEF9EC00625033 /* UIViewControllerExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE26A3224EEF9EC00625033 /* UIViewControllerExt.swift */; };
|
||||
7AE26A3524F31B0700625033 /* EventsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE26A3424F31B0700625033 /* EventsController.swift */; };
|
||||
7AEFE728240455E200910EB7 /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEFE727240455E200910EB7 /* SettingsController.swift */; };
|
||||
@ -181,6 +182,7 @@
|
||||
7AB67E8B2435C38700258F61 /* CustomTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTextField.swift; sourceTree = "<group>"; };
|
||||
7AB67E8D2435D1A000258F61 /* CustomButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomButton.swift; sourceTree = "<group>"; };
|
||||
7ADF6C92250B954900F237B2 /* Navigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Navigation.swift; sourceTree = "<group>"; };
|
||||
7ADF6C94250D037700F237B2 /* ShowEventController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowEventController.swift; sourceTree = "<group>"; };
|
||||
7AE26A3224EEF9EC00625033 /* UIViewControllerExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerExt.swift; sourceTree = "<group>"; };
|
||||
7AE26A3424F31B0700625033 /* EventsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsController.swift; sourceTree = "<group>"; };
|
||||
7AEFE727240455E200910EB7 /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
|
||||
@ -421,6 +423,7 @@
|
||||
7AE26A3424F31B0700625033 /* EventsController.swift */,
|
||||
7A813DC8250B5C9700CC93B9 /* LocationRow.swift */,
|
||||
7A813DCA250B5DC900CC93B9 /* LocationPickerController.swift */,
|
||||
7ADF6C94250D037700F237B2 /* ShowEventController.swift */,
|
||||
);
|
||||
path = Location;
|
||||
sourceTree = "<group>";
|
||||
@ -588,6 +591,7 @@
|
||||
7A21112A24FC3D7E003BBF6F /* AudioEngine.swift in Sources */,
|
||||
7A8A220B248D67B60073DFD9 /* VehicleReportImage.swift in Sources */,
|
||||
7A488C3E24A74B990054D0B2 /* Reactive+RxRealmDataSources.swift in Sources */,
|
||||
7ADF6C95250D037700F237B2 /* ShowEventController.swift in Sources */,
|
||||
7A27ADC7249D43210035F39E /* RegionsController.swift in Sources */,
|
||||
7A05161A2414FF0900FC55AC /* DateSection.swift in Sources */,
|
||||
7A333814249A532400D878F1 /* Filter.swift in Sources */,
|
||||
|
||||
@ -14,6 +14,17 @@ class EventPin: NSObject, MKAnnotation {
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
}
|
||||
|
||||
convenience init(event: VehicleEvent) {
|
||||
let coordinate = CLLocationCoordinate2D(latitude: event.latitude, longitude: event.longitude)
|
||||
let subtitle = event.address ?? "\(event.latitude), \(event.longitude)"
|
||||
let date = Date(timeIntervalSince1970: event.date)
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .short
|
||||
let title = formatter.string(from: date)
|
||||
self.init(coordinate: coordinate, title: title, subtitle: subtitle)
|
||||
}
|
||||
}
|
||||
|
||||
enum EventsMode {
|
||||
@ -34,18 +45,7 @@ class EventsController: UIViewController, UITableViewDataSource, UITableViewDele
|
||||
public var vehicle: Vehicle? {
|
||||
didSet {
|
||||
if let vehicle = self.vehicle {
|
||||
self.pins = vehicle.events.map { event in
|
||||
let coordinate = CLLocationCoordinate2D(latitude: event.latitude, longitude: event.longitude)
|
||||
let subtitle = event.address ?? "\(event.latitude), \(event.longitude)"
|
||||
let date = Date(timeIntervalSince1970: event.date)
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .short
|
||||
let title = formatter.string(from: date)
|
||||
return EventPin(coordinate: coordinate, title: title, subtitle: subtitle)
|
||||
}
|
||||
} else {
|
||||
|
||||
self.pins = vehicle.events.map(EventPin.init(event:))
|
||||
}
|
||||
|
||||
if self.isViewLoaded {
|
||||
|
||||
27
AutoCat/Controllers/Location/ShowEventController.swift
Normal file
27
AutoCat/Controllers/Location/ShowEventController.swift
Normal file
@ -0,0 +1,27 @@
|
||||
import UIKit
|
||||
import MapKit
|
||||
|
||||
class ShowEventController: UIViewController {
|
||||
|
||||
private var map = MKMapView()
|
||||
var event: VehicleEvent?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
self.map.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.view.addSubview(self.map)
|
||||
self.map.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true
|
||||
self.map.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true
|
||||
self.map.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true
|
||||
self.map.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
|
||||
|
||||
if let event = self.event {
|
||||
self.title = event.address ?? String(format: "%.02f, %.02f", event.latitude, event.longitude)
|
||||
let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: event.latitude, longitude: event.longitude), latitudinalMeters: 1000, longitudinalMeters: 1000)
|
||||
self.map.setRegion(region, animated: true)
|
||||
let pin = EventPin(event: event)
|
||||
self.map.addAnnotation(pin)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,9 +300,18 @@ class RecordsController: UIViewController, UITableViewDelegate {
|
||||
let editNumber = UIAlertAction(title: "Edit plate number", style: .default) { action in
|
||||
self.edit(record: record)
|
||||
}
|
||||
let showOnMap = UIAlertAction(title: "Show on map", style: .default) { action in
|
||||
let controller = ShowEventController()
|
||||
controller.event = record.event
|
||||
controller.hidesBottomBarWhenPushed = true
|
||||
self.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
|
||||
sheet.addAction(editNumber)
|
||||
sheet.addAction(showText)
|
||||
if record.event != nil {
|
||||
sheet.addAction(showOnMap)
|
||||
}
|
||||
sheet.addAction(share)
|
||||
sheet.addAction(cancel)
|
||||
sheet.popoverPresentationController?.sourceView = cell
|
||||
|
||||
@ -3,9 +3,9 @@ import Foundation
|
||||
enum Constants {
|
||||
static var baseUrl: String {
|
||||
#if DEBUG
|
||||
//return "http://127.0.0.1:3000/"
|
||||
return "http://127.0.0.1:3000/"
|
||||
//return "http://192.168.1.67:3000/"
|
||||
return "https://vps.aliencat.pro:8443/"
|
||||
//return "https://vps.aliencat.pro:8443/"
|
||||
#else
|
||||
return "https://vps.aliencat.pro:8443/"
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user