diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index 52d04a2..38cf94c 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -109,9 +109,6 @@ 7A761C09267E8EE40005F28F /* Base64FS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A96AE32246C095700297C33 /* Base64FS.swift */; }; 7A761C0B267E8FF90005F28F /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A761C0A267E8FF90005F28F /* Error.swift */; }; 7A813DC32508EE4F00CC93B9 /* EventCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A813DC22508EE4F00CC93B9 /* EventCell.swift */; }; - 7A813DC5250AAF3C00CC93B9 /* LocationEditController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A813DC4250AAF3C00CC93B9 /* LocationEditController.swift */; }; - 7A813DC9250B5C9700CC93B9 /* LocationRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A813DC8250B5C9700CC93B9 /* LocationRow.swift */; }; - 7A813DCB250B5DC900CC93B9 /* LocationPickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A813DCA250B5DC900CC93B9 /* LocationPickerController.swift */; }; 7A8A2209248D10EC0073DFD9 /* ResizeImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8A2208248D10EC0073DFD9 /* ResizeImage.swift */; }; 7A8A220B248D67B60073DFD9 /* VehicleReportImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8A220A248D67B60073DFD9 /* VehicleReportImage.swift */; }; 7A8AB76525A0DB8F00ECF2C1 /* BundleVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8AB76425A0DB8F00ECF2C1 /* BundleVersion.swift */; }; @@ -354,9 +351,6 @@ 7A761C0A267E8FF90005F28F /* Error.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = ""; }; 7A813DBD2506A57100CC93B9 /* AuthenticationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AuthenticationServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AuthenticationServices.framework; sourceTree = DEVELOPER_DIR; }; 7A813DC22508EE4F00CC93B9 /* EventCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventCell.swift; sourceTree = ""; }; - 7A813DC4250AAF3C00CC93B9 /* LocationEditController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationEditController.swift; sourceTree = ""; }; - 7A813DC8250B5C9700CC93B9 /* LocationRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationRow.swift; sourceTree = ""; }; - 7A813DCA250B5DC900CC93B9 /* LocationPickerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationPickerController.swift; sourceTree = ""; }; 7A8A2208248D10EC0073DFD9 /* ResizeImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResizeImage.swift; sourceTree = ""; }; 7A8A220A248D67B60073DFD9 /* VehicleReportImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleReportImage.swift; sourceTree = ""; }; 7A8AB76425A0DB8F00ECF2C1 /* BundleVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleVersion.swift; sourceTree = ""; }; @@ -820,10 +814,7 @@ 7A813DC7250B5C6E00CC93B9 /* Location */ = { isa = PBXGroup; children = ( - 7A813DC4250AAF3C00CC93B9 /* LocationEditController.swift */, 7AE26A3424F31B0700625033 /* EventsController.swift */, - 7A813DC8250B5C9700CC93B9 /* LocationRow.swift */, - 7A813DCA250B5DC900CC93B9 /* LocationPickerController.swift */, 7ADF6C94250D037700F237B2 /* ShowEventController.swift */, 7ADF6C9E251201D200F237B2 /* GlobalEventsController.swift */, ); @@ -1181,7 +1172,6 @@ 7A7158092C44087E00852088 /* OsagoCoordinator.swift in Sources */, 7A1441662C297EDE00E79018 /* NotesScreen.swift in Sources */, 7A11470123FDE7E500B424AF /* AppDelegate.swift in Sources */, - 7A813DC9250B5C9700CC93B9 /* LocationRow.swift in Sources */, 7A3399AB299063370087DF98 /* SearchControllerExt.swift in Sources */, 7A14416E2C297F7C00E79018 /* Coordinator.swift in Sources */, 7A6DD90824329144009DE740 /* CenterTextLayer.swift in Sources */, @@ -1236,7 +1226,6 @@ 7A176DB22C43071A00999D6B /* ApiServiceStub.swift in Sources */, 7A1090EA24A3A26300B4F0B2 /* AudioPlayer.swift in Sources */, 7A11471623FDEB2A00B424AF /* MainSplitController.swift in Sources */, - 7A813DC5250AAF3C00CC93B9 /* LocationEditController.swift in Sources */, 7A6DD903242BF4A5009DE740 /* PlateView.swift in Sources */, 7A1022722C554A1300B84627 /* CustomHostingController.swift in Sources */, 7ADF6C9F251201D200F237B2 /* GlobalEventsController.swift in Sources */, @@ -1246,7 +1235,6 @@ 7A10226E2C551EE000B84627 /* LocationEditViewModel.swift in Sources */, 7AFBE8CE2C308B53003C491D /* ACMessageView.swift in Sources */, 7A14416C2C297F2100E79018 /* NotesCoordinator.swift in Sources */, - 7A813DCB250B5DC900CC93B9 /* LocationPickerController.swift in Sources */, 7A9FEEC82529AB23001CA50E /* RxRealmDataSource.swift in Sources */, 7AAAFADE2C4D23620050410D /* ACImageSliderModel.swift in Sources */, 7A8AB76525A0DB8F00ECF2C1 /* BundleVersion.swift in Sources */, @@ -1543,7 +1531,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 130; + CURRENT_PROJECT_VERSION = 131; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = AutoCat; @@ -1569,7 +1557,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 130; + CURRENT_PROJECT_VERSION = 131; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = AutoCat; diff --git a/AutoCat/Base.lproj/Main.storyboard b/AutoCat/Base.lproj/Main.storyboard index 00b7dc3..17faac0 100644 --- a/AutoCat/Base.lproj/Main.storyboard +++ b/AutoCat/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -42,21 +42,6 @@ - - - - - - - - - - - - - - - @@ -70,17 +55,17 @@ - + - + - + - + - + @@ -147,21 +132,6 @@ - - - - - - - - - - - - - - - @@ -963,22 +933,22 @@ - + - + - + - + - + diff --git a/AutoCat/Controllers/Location/LocationEditController.swift b/AutoCat/Controllers/Location/LocationEditController.swift deleted file mode 100644 index 96f6d7f..0000000 --- a/AutoCat/Controllers/Location/LocationEditController.swift +++ /dev/null @@ -1,58 +0,0 @@ -import UIKit -import Eureka -import CoreLocation -import AutoCatCore - -class LocationEditController: FormViewController { - - private var doneButton: UIBarButtonItem! - - var date = Date() - var placemark: Placemark? = nil - - var onDone: ((VehicleEventDto) -> Void)? - - override func viewDidLoad() { - super.viewDidLoad() - - self.doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(doneTapped(_:))) - self.navigationItem.rightBarButtonItem = self.doneButton - self.doneButton.isEnabled = false - - form +++ Section("") - <<< DateTimeInlineRow(){ - $0.title = NSLocalizedString("Date and time", comment: "") - $0.value = self.date - }.onChange { row in - if let newDate = row.value { - self.date = newDate - self.doneButton.isEnabled = true - } else { - self.doneButton.isEnabled = false - } - } - - // TODO: Use one of the standard rows (properly) - <<< /*LocationRow()*/LabelRow { row in - row.title = NSLocalizedString("Location", comment: "") - row.value = self.placemark?.address - }.onChange { row in - if let newPlacemark = row.value { - //self.placemark = newPlacemark - self.doneButton.isEnabled = true - } else { - self.doneButton.isEnabled = false - } - } - } - - @objc func doneTapped(_ sender: UIBarButtonItem) { - guard let placemark = self.placemark else { return } - var event = VehicleEventDto(lat: placemark.latitude, lon: placemark.longitude) - event.date = self.date.timeIntervalSince1970 - if let address = placemark.address { - event.address = address - } - self.onDone?(event) - } -} diff --git a/AutoCat/Controllers/Location/LocationPickerController.swift b/AutoCat/Controllers/Location/LocationPickerController.swift deleted file mode 100644 index 65f1d32..0000000 --- a/AutoCat/Controllers/Location/LocationPickerController.swift +++ /dev/null @@ -1,159 +0,0 @@ -import Foundation -import MapKit -import Intents -import AutoCatCore - -public struct Placemark: Equatable { - var latitude: Double - var longitude: Double - var address: String? -} - -public class LocationPickerController : UIViewController, MKMapViewDelegate { - - public var placemark: Placemark? - public var onDismissCallback: ((UIViewController) -> ())? - - private var address: String? - private var geocodingTask: Task? - - lazy var mapView : MKMapView = { [unowned self] in - let v = MKMapView(frame: self.view.bounds) - v.autoresizingMask = [.flexibleWidth, .flexibleHeight] - return v - }() - - lazy var pinView: UIImageView = { [unowned self] in - let v = UIImageView(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) - v.image = UIImage(named: "MapPin", in: Bundle(for: LocationPickerController.self), compatibleWith: nil) - v.image = v.image?.withRenderingMode(.alwaysTemplate) - v.tintColor = self.view.tintColor - v.backgroundColor = .clear - v.clipsToBounds = true - v.contentMode = .scaleAspectFit - v.isUserInteractionEnabled = false - return v - }() - - let width: CGFloat = 10.0 - let height: CGFloat = 5.0 - - lazy var ellipse: UIBezierPath = { [unowned self] in - let ellipse = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: self.width, height: self.height)) - return ellipse - }() - - - lazy var ellipsisLayer: CAShapeLayer = { [unowned self] in - let layer = CAShapeLayer() - layer.bounds = CGRect(x: 0, y: 0, width: self.width, height: self.height) - layer.path = self.ellipse.cgPath - layer.fillColor = UIColor.gray.cgColor - layer.fillRule = .nonZero - layer.lineCap = .butt - layer.lineDashPattern = nil - layer.lineDashPhase = 0.0 - layer.lineJoin = .miter - layer.lineWidth = 1.0 - layer.miterLimit = 10.0 - layer.strokeColor = UIColor.gray.cgColor - return layer - }() - - - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { - super.init(nibName: nil, bundle: nil) - } - - convenience public init(_ callback: ((UIViewController) -> ())?){ - self.init(nibName: nil, bundle: nil) - onDismissCallback = callback - } - - public override func viewDidLoad() { - super.viewDidLoad() - view.addSubview(mapView) - - mapView.delegate = self - mapView.addSubview(pinView) - mapView.layer.insertSublayer(ellipsisLayer, below: pinView.layer) - - let button = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(LocationPickerController.tappedDone(_:))) - button.title = "Done" - navigationItem.rightBarButtonItem = button - - if let value = placemark { - let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: value.latitude, longitude: value.longitude), latitudinalMeters: 1000, longitudinalMeters: 1000) - mapView.setRegion(region, animated: true) - } - else{ - mapView.showsUserLocation = true - } - updateTitle() - - } - - public override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - - let center = mapView.convert(mapView.centerCoordinate, toPointTo: pinView) - pinView.center = CGPoint(x: center.x, y: center.y - (pinView.bounds.height/2)) - ellipsisLayer.position = center - } - - - @objc func tappedDone(_ sender: UIBarButtonItem){ - let target = mapView.convert(ellipsisLayer.position, toCoordinateFrom: mapView) - placemark = Placemark(latitude: target.latitude, longitude: target.longitude, address: self.address) - onDismissCallback?(self) - } - - func updateTitle() { - let fmt = NumberFormatter() - fmt.maximumFractionDigits = 4 - fmt.minimumFractionDigits = 4 - let latitude = fmt.string(from: NSNumber(value: mapView.centerCoordinate.latitude))! - let longitude = fmt.string(from: NSNumber(value: mapView.centerCoordinate.longitude))! - title = "\(latitude), \(longitude)" - - self.address = nil - - geocodingTask?.cancel() - geocodingTask = Task { - address = try? await RxLocationManager.getAddressForLocation(latitude: mapView.centerCoordinate.latitude, - longitude: mapView.centerCoordinate.longitude) - title = address - geocodingTask = nil - return address - } - } - - public func mapView(_ mapView: MKMapView, regionWillChangeAnimated animated: Bool) { - ellipsisLayer.transform = CATransform3DMakeScale(0.5, 0.5, 1) - UIView.animate(withDuration: 0.2, animations: { [weak self] in - self?.pinView.center = CGPoint(x: self!.pinView.center.x, y: self!.pinView.center.y - 10) - }) - } - - public func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { - ellipsisLayer.transform = CATransform3DIdentity - UIView.animate(withDuration: 0.2, animations: { [weak self] in - self?.pinView.center = CGPoint(x: self!.pinView.center.x, y: self!.pinView.center.y + 10) - }) - updateTitle() - } - - public func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) { - let region = MKCoordinateRegion(center: userLocation.coordinate, latitudinalMeters: 1000, longitudinalMeters: 1000) - mapView.setRegion(region, animated: true) - mapView.showsUserLocation = false - } - - public func mapView(_ mapView: MKMapView, didFailToLocateUserWithError error: Error) { - print(error) - } -} diff --git a/AutoCat/Controllers/Location/LocationRow.swift b/AutoCat/Controllers/Location/LocationRow.swift deleted file mode 100644 index d6abad7..0000000 --- a/AutoCat/Controllers/Location/LocationRow.swift +++ /dev/null @@ -1,61 +0,0 @@ -import UIKit -//import Eureka -import CoreLocation - -// TODO: Rewrite Eureka forms to native UIKit/SwiftUI - -/* -public final class LocationRow: OptionsRow>, PresenterRowType, RowType { - - public typealias PresenterRow = LocationPickerController - - /// Defines how the view controller will be presented, pushed, etc. - public var presentationMode: PresentationMode? - - /// Will be called before the presentation occurs. - public var onPresentCallback: ((FormViewController, PresenterRow) -> Void)? - - public required init(tag: String?) { - super.init(tag: tag) - presentationMode = .show(controllerProvider: ControllerProvider.callback { return LocationPickerController(){ _ in } }, onDismiss: { vc in _ = vc.navigationController?.popViewController(animated: true) }) - - displayValueFor = { - guard let placemark = $0 else { return "" } - let fmt = NumberFormatter() - fmt.maximumFractionDigits = 4 - fmt.minimumFractionDigits = 4 - let latitude = fmt.string(from: NSNumber(value: placemark.latitude))! - let longitude = fmt.string(from: NSNumber(value: placemark.longitude))! - return "\(latitude), \(longitude)" - } - } - - /** - Extends `didSelect` method - */ - public override func customDidSelect() { - super.customDidSelect() - guard let presentationMode = presentationMode, !isDisabled else { return } - if let controller = presentationMode.makeController() { - controller.row = self - controller.title = selectorTitle ?? controller.title - onPresentCallback?(cell.formViewController()!, controller) - presentationMode.present(controller, row: self, presentingController: self.cell.formViewController()!) - } else { - presentationMode.present(nil, row: self, presentingController: self.cell.formViewController()!) - } - } - - /** - Prepares the pushed row setting its title and completion callback. - */ - public override func prepare(for segue: UIStoryboardSegue) { - super.prepare(for: segue) - guard let rowVC = segue.destination as? PresenterRow else { return } - rowVC.title = selectorTitle ?? rowVC.title - rowVC.onDismissCallback = presentationMode?.onDismissCallback ?? rowVC.onDismissCallback - onPresentCallback?(cell.formViewController()!, rowVC) - rowVC.row = self - } -} -*/ diff --git a/AutoCat/Controllers/SearchController.swift b/AutoCat/Controllers/SearchController.swift index 538ee67..1327b2d 100644 --- a/AutoCat/Controllers/SearchController.swift +++ b/AutoCat/Controllers/SearchController.swift @@ -56,6 +56,8 @@ class SearchController: UIViewController, UISearchResultsUpdating, UITableViewDe self.datasource = SectionedDataSource(table: self.tableView) self.tableView.delegate = self self.tableView.keyboardDismissMode = .onDrag + + updateSearchResults(with: filter) } func updateSearchResults(with filter: Filter) {