diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj
index ad10e59..a201847 100644
--- a/AutoCat.xcodeproj/project.pbxproj
+++ b/AutoCat.xcodeproj/project.pbxproj
@@ -748,7 +748,7 @@
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
- "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 13.1;
+ "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -757,7 +757,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
+ TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Debug;
};
@@ -771,7 +771,7 @@
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
- "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 13.1;
+ "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -780,7 +780,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
+ TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Release;
};
diff --git a/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist b/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist
index 4ada3d5..1ac3540 100644
--- a/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -14,35 +14,35 @@
isShown
orderHint
- 2
+ 8
DifferenceKit (Playground) 2.xcscheme
isShown
orderHint
- 3
+ 9
DifferenceKit (Playground).xcscheme
isShown
orderHint
- 1
+ 7
Eureka (Playground) 1.xcscheme
isShown
orderHint
- 8
+ 5
Eureka (Playground) 2.xcscheme
isShown
orderHint
- 9
+ 6
Eureka (Playground) 3.xcscheme
@@ -70,7 +70,7 @@
isShown
orderHint
- 7
+ 4
GettingStarted (Playground) 1.xcscheme
@@ -119,35 +119,35 @@
isShown
orderHint
- 5
+ 2
Rx (Playground) 2.xcscheme
isShown
orderHint
- 6
+ 3
Rx (Playground).xcscheme
isShown
orderHint
- 4
+ 1
SwiftDate (Playground) 1.xcscheme
isShown
orderHint
- 12
+ 11
SwiftDate (Playground) 2.xcscheme
isShown
orderHint
- 10
+ 12
SwiftDate (Playground) 3.xcscheme
@@ -175,7 +175,7 @@
isShown
orderHint
- 11
+ 10
SuppressBuildableAutocreation
diff --git a/AutoCat/AppDelegate.swift b/AutoCat/AppDelegate.swift
index e8b4862..d3ce803 100644
--- a/AutoCat/AppDelegate.swift
+++ b/AutoCat/AppDelegate.swift
@@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let config = Realm.Configuration(
- schemaVersion: 25,
+ schemaVersion: 26,
migrationBlock: { migration, oldSchemaVersion in
if oldSchemaVersion <= 3 {
var numbers: [String] = []
diff --git a/AutoCat/Controllers/CheckController.swift b/AutoCat/Controllers/CheckController.swift
index 1e4eb49..abe6525 100644
--- a/AutoCat/Controllers/CheckController.swift
+++ b/AutoCat/Controllers/CheckController.swift
@@ -101,7 +101,9 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
}
@objc private func calendarDayDidChange(_ notification : NSNotification) {
- self.historyDataSource.reload()
+ DispatchQueue.main.async {
+ self.historyDataSource.reload()
+ }
}
// MARK: - Checking new number
@@ -281,6 +283,7 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
self.getEvent(for: action)
.flatMap { event in event.findAddress().map{ [event] }.catchErrorJustReturn([event]) }
+ .observeOn(MainScheduler.instance)
.catchErrorJustReturn([])
.map { events in
try realm.write { vehicle.events.append(objectsIn: events) }
diff --git a/AutoCat/Controllers/Osago/OsagoController.swift b/AutoCat/Controllers/Osago/OsagoController.swift
index 303bf3e..6d6ca44 100644
--- a/AutoCat/Controllers/Osago/OsagoController.swift
+++ b/AutoCat/Controllers/Osago/OsagoController.swift
@@ -14,6 +14,8 @@ class OsagoController: FormViewController {
super.viewDidLoad()
self.title = "OSAGO contracts"
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(checkNewDate(_:)))
+
+ self.tableView.rowHeight = UITableView.automaticDimension
}
@objc func checkNewDate(_ sender: UIBarButtonItem) {
@@ -36,7 +38,47 @@ class OsagoController: FormViewController {
}
func updateInterface() {
- self.form.allSections.forEach { $0.reload() }
+ guard let vehicle = self.vehicle else { return }
+
+ let formatter = DateFormatter()
+ formatter.dateStyle = .medium
+ formatter.timeStyle = .none
+
+ self.form.removeAll()
+ for osago in vehicle.osagoContracts.sorted(by: { $0.date < $1.date }) {
+ self.form +++ Section(formatter.string(from: Date(timeIntervalSince1970: osago.date)))
+ <<< self.row("Contract #", value: osago.number)
+ <<< self.row("Name", value: osago.name)
+ <<< self.row("Status", value: osago.status)
+ <<< self.row("Insurant", value: osago.insurant)
+ <<< self.row("Owner", value: osago.owner)
+ <<< self.row("Region", value: osago.usageRegion)
+ <<< self.row("Restrictions", value: osago.restrictions, height: 100)
+ <<< self.row("Plate number", value: osago.plateNumber)
+ <<< self.row("VIN", value: osago.vin)
+ }
+ }
+
+ func row(_ title: String, value: String?, height: CGFloat = 44) -> LabelRow {
+ LabelRow() { row in
+ if let cell = row.cell, let label = cell.detailTextLabel, let titleLabel = cell.textLabel {
+ titleLabel.translatesAutoresizingMaskIntoConstraints = false
+ titleLabel.topAnchor.constraint(equalTo: cell.contentView.topAnchor, constant: 8).isActive = true
+ titleLabel.leadingAnchor.constraint(equalTo: cell.contentView.layoutMarginsGuide.leadingAnchor).isActive = true
+
+ label.translatesAutoresizingMaskIntoConstraints = false
+ label.topAnchor.constraint(equalTo: cell.contentView.topAnchor, constant: 8).isActive = true
+ label.bottomAnchor.constraint(equalTo: cell.contentView.bottomAnchor, constant: -8).isActive = true
+ label.leadingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: 8).isActive = true
+ label.trailingAnchor.constraint(equalTo: cell.contentView.layoutMarginsGuide.trailingAnchor).isActive = true
+ label.numberOfLines = 0
+ label.font = UIFont.preferredFont(forTextStyle: .subheadline)
+ }
+
+ //row.cell.height = { height }
+ row.title = title
+ row.value = value
+ }
}
func update(vehicle: Vehicle) {
diff --git a/AutoCat/Models/Osago.swift b/AutoCat/Models/Osago.swift
index e8166df..12357d6 100644
--- a/AutoCat/Models/Osago.swift
+++ b/AutoCat/Models/Osago.swift
@@ -2,7 +2,10 @@ import Foundation
import RealmSwift
class Osago: Object, Decodable {
+ @objc dynamic var date: TimeInterval
@objc dynamic var number: String
+ @objc dynamic var vin: String?
+ @objc dynamic var plateNumber: String?
@objc dynamic var name: String
@objc dynamic var status: String
@objc dynamic var restrictions: String
diff --git a/AutoCat/Models/Vehicle.swift b/AutoCat/Models/Vehicle.swift
index 6cf2a90..46aaf29 100644
--- a/AutoCat/Models/Vehicle.swift
+++ b/AutoCat/Models/Vehicle.swift
@@ -148,6 +148,7 @@ class Vehicle: Object, Decodable, Identifiable, Differentiable {
case photos
case ownershipPeriods
case events
+ case osagoContracts
}
required init(from decoder: Decoder) throws {
@@ -187,6 +188,10 @@ class Vehicle: Object, Decodable, Identifiable, Differentiable {
self.updatedDate = self.addedDate
}
+ if let osago = try container.decodeIfPresent([Osago].self, forKey: .osagoContracts) {
+ self.osagoContracts.append(objectsIn: osago)
+ }
+
self.identifier = self.number
}