Fixing few GPS-related bugs
This commit is contained in:
parent
d95bbe51e2
commit
21e18649ba
@ -707,7 +707,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 22;
|
CURRENT_PROJECT_VERSION = 23;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
@ -729,7 +729,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 22;
|
CURRENT_PROJECT_VERSION = 23;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
BreakpointExtensionID = "Xcode.Breakpoint.SwiftErrorBreakpoint">
|
BreakpointExtensionID = "Xcode.Breakpoint.SwiftErrorBreakpoint">
|
||||||
<BreakpointContent
|
<BreakpointContent
|
||||||
uuid = "C14D0996-5708-44D2-A6BA-4A4B50B522EE"
|
uuid = "C14D0996-5708-44D2-A6BA-4A4B50B522EE"
|
||||||
shouldBeEnabled = "Yes"
|
shouldBeEnabled = "No"
|
||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No">
|
continueAfterRunningActions = "No">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
@ -63,22 +63,6 @@
|
|||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
<BreakpointProxy
|
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
||||||
<BreakpointContent
|
|
||||||
uuid = "CDE92976-A8B4-4D3D-95F5-C2E8876C0601"
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
filePath = "AutoCat/Utils/Api.swift"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "167"
|
|
||||||
endingLineNumber = "167"
|
|
||||||
landmarkName = "add(event:to:)"
|
|
||||||
landmarkType = "7">
|
|
||||||
</BreakpointContent>
|
|
||||||
</BreakpointProxy>
|
|
||||||
<BreakpointProxy
|
<BreakpointProxy
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
<BreakpointContent
|
<BreakpointContent
|
||||||
|
|||||||
@ -18,7 +18,7 @@ class VehicleCell: UITableViewCell {
|
|||||||
func configure(with vehicle: Vehicle) {
|
func configure(with vehicle: Vehicle) {
|
||||||
self.name.text = vehicle.brand?.name?.original ?? "<unknown>"
|
self.name.text = vehicle.brand?.name?.original ?? "<unknown>"
|
||||||
self.plate.number = PlateNumber(vehicle.number)
|
self.plate.number = PlateNumber(vehicle.number)
|
||||||
self.plate.unrecognized = vehicle.brand == nil
|
self.plate.unrecognized = vehicle.unrecognized
|
||||||
self.date.text = formatter.string(from: Date(timeIntervalSince1970: vehicle.addedDate/1000))
|
self.date.text = formatter.string(from: Date(timeIntervalSince1970: vehicle.addedDate/1000))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -115,9 +115,20 @@ class CheckController: UIViewController, MaskedTextFieldDelegateListener, UITabl
|
|||||||
self.onReceivedVehicle(vehicle, event: event)
|
self.onReceivedVehicle(vehicle, event: event)
|
||||||
}, onError: { err in
|
}, onError: { err in
|
||||||
if let realm = try? Realm() {
|
if let realm = try? Realm() {
|
||||||
|
let vehicle = Vehicle(number)
|
||||||
try? realm.write {
|
try? realm.write {
|
||||||
realm.add(Vehicle(number), update: .all)
|
realm.add(vehicle, update: .all)
|
||||||
}
|
}
|
||||||
|
let eventSingle = event == nil ? self.getEvent() : Single.just(event!)
|
||||||
|
eventSingle
|
||||||
|
.flatMap { event in event.updateAddress().map{ [event] }.catchErrorJustReturn([event]) }
|
||||||
|
.catchErrorJustReturn([])
|
||||||
|
.subscribe(onSuccess: { events in
|
||||||
|
try? realm.write {
|
||||||
|
vehicle.events.append(objectsIn: events)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.disposed(by: self.bag)
|
||||||
}
|
}
|
||||||
IHProgressHUD.showError(withStatus: err.localizedDescription)
|
IHProgressHUD.showError(withStatus: err.localizedDescription)
|
||||||
print(err.localizedDescription)
|
print(err.localizedDescription)
|
||||||
@ -170,7 +181,7 @@ class CheckController: UIViewController, MaskedTextFieldDelegateListener, UITabl
|
|||||||
if let detail = detail {
|
if let detail = detail {
|
||||||
detail.popToRootViewController(animated: true)
|
detail.popToRootViewController(animated: true)
|
||||||
let report = detail.viewControllers.first as? ReportController
|
let report = detail.viewControllers.first as? ReportController
|
||||||
report?.vehicle = vehicle
|
report?.number = vehicle.number
|
||||||
splitViewController.showDetailViewController(detail, sender: self)
|
splitViewController.showDetailViewController(detail, sender: self)
|
||||||
//self.performSegue(withIdentifier: "OpenDetailSegue", sender: self)
|
//self.performSegue(withIdentifier: "OpenDetailSegue", sender: self)
|
||||||
}
|
}
|
||||||
@ -201,10 +212,16 @@ class CheckController: UIViewController, MaskedTextFieldDelegateListener, UITabl
|
|||||||
|
|
||||||
let updateAction = UIContextualAction(style: .normal, title: "Update") { action, view, completion in
|
let updateAction = UIContextualAction(style: .normal, title: "Update") { action, view, completion in
|
||||||
IHProgressHUD.show()
|
IHProgressHUD.show()
|
||||||
|
|
||||||
|
var event: VehicleEvent? = nil
|
||||||
|
if vehicle.unrecognized, let savedEvent = vehicle.events.first {
|
||||||
|
event = savedEvent
|
||||||
|
}
|
||||||
|
|
||||||
Api.checkVehicle(by: vehicle.number, force: true)
|
Api.checkVehicle(by: vehicle.number, force: true)
|
||||||
.observeOn(MainScheduler.instance)
|
.observeOn(MainScheduler.instance)
|
||||||
.subscribe(onSuccess: { vehicle in
|
.subscribe(onSuccess: { vehicle in
|
||||||
self.onReceivedVehicle(vehicle, event: nil)
|
self.onReceivedVehicle(vehicle, event: event)
|
||||||
}, onError: { err in
|
}, onError: { err in
|
||||||
IHProgressHUD.showError(withStatus: err.localizedDescription)
|
IHProgressHUD.showError(withStatus: err.localizedDescription)
|
||||||
print(err.localizedDescription)
|
print(err.localizedDescription)
|
||||||
|
|||||||
@ -37,6 +37,10 @@ class EventsController: UIViewController {
|
|||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
#if targetEnvironment(macCatalyst)
|
||||||
|
self.map.showsZoomControls = true
|
||||||
|
#endif
|
||||||
|
|
||||||
self.map.addAnnotations(self.pins)
|
self.map.addAnnotations(self.pins)
|
||||||
self.centerMap()
|
self.centerMap()
|
||||||
}
|
}
|
||||||
@ -53,7 +57,10 @@ class EventsController: UIViewController {
|
|||||||
let center = CLLocationCoordinate2D(latitude: (minLat + maxLat)/2, longitude: (minLon + maxLon)/2)
|
let center = CLLocationCoordinate2D(latitude: (minLat + maxLat)/2, longitude: (minLon + maxLon)/2)
|
||||||
let leftTop = CLLocation(latitude: minLat, longitude: minLon)
|
let leftTop = CLLocation(latitude: minLat, longitude: minLon)
|
||||||
let rightBottom = CLLocation(latitude: maxLat, longitude: maxLon)
|
let rightBottom = CLLocation(latitude: maxLat, longitude: maxLon)
|
||||||
let diagonal = leftTop.distance(from: rightBottom)
|
var diagonal = leftTop.distance(from: rightBottom)
|
||||||
|
if diagonal < 1000 {
|
||||||
|
diagonal = 1000
|
||||||
|
}
|
||||||
|
|
||||||
let region = MKCoordinateRegion(center: center, latitudinalMeters: diagonal, longitudinalMeters: diagonal)
|
let region = MKCoordinateRegion(center: center, latitudinalMeters: diagonal, longitudinalMeters: diagonal)
|
||||||
self.map.setRegion(region, animated: true)
|
self.map.setRegion(region, animated: true)
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class MainSplitController: UISplitViewController, UISplitViewControllerDelegate
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if detail.vehicle == nil {
|
if detail.number == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import UIKit
|
|||||||
import MagazineLayout
|
import MagazineLayout
|
||||||
import Kingfisher
|
import Kingfisher
|
||||||
import LinkPresentation
|
import LinkPresentation
|
||||||
|
import RealmSwift
|
||||||
|
|
||||||
enum ReportSection: Int, CaseIterable, CustomStringConvertible {
|
enum ReportSection: Int, CaseIterable, CustomStringConvertible {
|
||||||
case header = 0
|
case header = 0
|
||||||
@ -86,7 +87,7 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
|
|||||||
private let fullWidth = MagazineLayoutItemSizeMode(widthMode: .fullWidth(respectsHorizontalInsets: true), heightMode: .dynamic)
|
private let fullWidth = MagazineLayoutItemSizeMode(widthMode: .fullWidth(respectsHorizontalInsets: true), heightMode: .dynamic)
|
||||||
private var reportImageUrl: URL?
|
private var reportImageUrl: URL?
|
||||||
|
|
||||||
var vehicle: Vehicle? {
|
private var vehicle: Vehicle? {
|
||||||
didSet {
|
didSet {
|
||||||
loadViewIfNeeded()
|
loadViewIfNeeded()
|
||||||
self.collection.reloadData()
|
self.collection.reloadData()
|
||||||
@ -94,6 +95,19 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var notificationToken: NotificationToken?
|
||||||
|
var number: String? {
|
||||||
|
didSet {
|
||||||
|
if let realm = try? Realm(), let num = number {
|
||||||
|
let vehicles = realm.objects(Vehicle.self).filter("number = %@", num)
|
||||||
|
self.notificationToken?.invalidate()
|
||||||
|
self.notificationToken = vehicles.observe { _ in self.vehicle = vehicles.first }
|
||||||
|
} else {
|
||||||
|
self.vehicle = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class SearchController: UIViewController, UISearchResultsUpdating {
|
|||||||
if let detail = detail {
|
if let detail = detail {
|
||||||
detail.popToRootViewController(animated: true)
|
detail.popToRootViewController(animated: true)
|
||||||
let report = detail.viewControllers.first as? ReportController
|
let report = detail.viewControllers.first as? ReportController
|
||||||
report?.vehicle = vehicle
|
report?.number = vehicle.number
|
||||||
splitViewController.showDetailViewController(detail, sender: self)
|
splitViewController.showDetailViewController(detail, sender: self)
|
||||||
//self.performSegue(withIdentifier: "OpenDetailSegue", sender: self)
|
//self.performSegue(withIdentifier: "OpenDetailSegue", sender: self)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,4 +138,8 @@ class Vehicle: Object, Decodable, IdentifiableType {
|
|||||||
override static func primaryKey() -> String? {
|
override static func primaryKey() -> String? {
|
||||||
return "number"
|
return "number"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var unrecognized: Bool {
|
||||||
|
return self.brand == nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user