New controllers for osago checking
This commit is contained in:
parent
6f62258f9e
commit
64d11a0413
@ -8,6 +8,9 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
7A000AA224C2EEDE001F5B00 /* Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A000AA124C2EEDE001F5B00 /* Location.swift */; };
|
||||
7A0420AA25619AEC00034941 /* Osago.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0420A925619AEC00034941 /* Osago.swift */; };
|
||||
7A0420AD2561A0B100034941 /* OsagoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0420AC2561A0B100034941 /* OsagoController.swift */; };
|
||||
7A0420B12561A0E100034941 /* OsagoAddController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0420B02561A0E100034941 /* OsagoAddController.swift */; };
|
||||
7A051611241412CA00FC55AC /* SwiftDate in Frameworks */ = {isa = PBXBuildFile; productRef = 7A051610241412CA00FC55AC /* SwiftDate */; };
|
||||
7A05161A2414FF0900FC55AC /* DateSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0516192414FF0900FC55AC /* DateSection.swift */; };
|
||||
7A1090E824A394F100B4F0B2 /* AudioRecordCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1090E724A394F100B4F0B2 /* AudioRecordCell.swift */; };
|
||||
@ -99,6 +102,9 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
7A000AA124C2EEDE001F5B00 /* Location.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Location.swift; sourceTree = "<group>"; };
|
||||
7A0420A925619AEC00034941 /* Osago.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Osago.swift; sourceTree = "<group>"; };
|
||||
7A0420AC2561A0B100034941 /* OsagoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OsagoController.swift; sourceTree = "<group>"; };
|
||||
7A0420B02561A0E100034941 /* OsagoAddController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OsagoAddController.swift; sourceTree = "<group>"; };
|
||||
7A0516192414FF0900FC55AC /* DateSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateSection.swift; sourceTree = "<group>"; };
|
||||
7A1090E724A394F100B4F0B2 /* AudioRecordCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecordCell.swift; sourceTree = "<group>"; };
|
||||
7A1090E924A3A26300B4F0B2 /* AudioPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioPlayer.swift; sourceTree = "<group>"; };
|
||||
@ -206,6 +212,15 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
7A0420AF2561A0C100034941 /* Osago */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A0420AC2561A0B100034941 /* OsagoController.swift */,
|
||||
7A0420B02561A0E100034941 /* OsagoAddController.swift */,
|
||||
);
|
||||
path = Osago;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A1146F423FDE7E500B424AF = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -248,6 +263,7 @@
|
||||
7A11471423FDEAF800B424AF /* Controllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A0420AF2561A0C100034941 /* Osago */,
|
||||
7A813DC7250B5C6E00CC93B9 /* Location */,
|
||||
7A11471523FDEB2A00B424AF /* MainSplitController.swift */,
|
||||
7A11471723FDEBFA00B424AF /* ReportController.swift */,
|
||||
@ -304,6 +320,7 @@
|
||||
7AB562B9249C9E9B00473D53 /* Region.swift */,
|
||||
7A659B5824A2B1BA0043A0F2 /* AudioRecord.swift */,
|
||||
7AAE6AD224CDDF950023860B /* VehicleEvent.swift */,
|
||||
7A0420A925619AEC00034941 /* Osago.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@ -537,6 +554,7 @@
|
||||
7A96AE2D246B2B7400297C33 /* GoogleSignInController.swift in Sources */,
|
||||
7A15051224DB3E3000F39631 /* AnyEncodable.swift in Sources */,
|
||||
7A1090EA24A3A26300B4F0B2 /* AudioPlayer.swift in Sources */,
|
||||
7A0420B12561A0E100034941 /* OsagoAddController.swift in Sources */,
|
||||
7A11474723FF2AA500B424AF /* User.swift in Sources */,
|
||||
7A11471623FDEB2A00B424AF /* MainSplitController.swift in Sources */,
|
||||
7A813DC5250AAF3C00CC93B9 /* LocationEditController.swift in Sources */,
|
||||
@ -547,8 +565,10 @@
|
||||
7A11470323FDE7E500B424AF /* SceneDelegate.swift in Sources */,
|
||||
7A530B7E24017FEE00CBFE6E /* VehicleCell.swift in Sources */,
|
||||
7A813DCB250B5DC900CC93B9 /* LocationPickerController.swift in Sources */,
|
||||
7A0420AA25619AEC00034941 /* Osago.swift in Sources */,
|
||||
7A11474423FF06CA00B424AF /* Api.swift in Sources */,
|
||||
7A9FEEC82529AB23001CA50E /* RxRealmDataSource.swift in Sources */,
|
||||
7A0420AD2561A0B100034941 /* OsagoController.swift in Sources */,
|
||||
7AB67E8E2435D1A000258F61 /* CustomButton.swift in Sources */,
|
||||
7A21112A24FC3D7E003BBF6F /* AudioEngine.swift in Sources */,
|
||||
7A8A220B248D67B60073DFD9 /* VehicleReportImage.swift in Sources */,
|
||||
@ -708,7 +728,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 54;
|
||||
CURRENT_PROJECT_VERSION = 55;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
@ -731,7 +751,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 54;
|
||||
CURRENT_PROJECT_VERSION = 55;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
|
||||
@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
|
||||
let config = Realm.Configuration(
|
||||
schemaVersion: 24,
|
||||
schemaVersion: 25,
|
||||
migrationBlock: { migration, oldSchemaVersion in
|
||||
if oldSchemaVersion <= 3 {
|
||||
var numbers: [String] = []
|
||||
|
||||
@ -57,6 +57,36 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1881" y="965"/>
|
||||
</scene>
|
||||
<!--Osago Add Controller-->
|
||||
<scene sceneID="hrL-nC-qbc">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="OsagoAddController" id="ut6-ie-wYF" customClass="OsagoAddController" customModule="AutoCat" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Gec-g2-MLF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<viewLayoutGuide key="safeArea" id="dg5-YE-IYT"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="cTZ-Ck-Mw7" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1094" y="2353"/>
|
||||
</scene>
|
||||
<!--Osago Controller-->
|
||||
<scene sceneID="LgB-gR-z4l">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="OsagoController" id="JW7-4w-Lcx" customClass="OsagoController" customModule="AutoCat" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="OhQ-CO-BRq">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<viewLayoutGuide key="safeArea" id="ujd-gp-iD5"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="vDX-Gn-acM" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1094" y="1660"/>
|
||||
</scene>
|
||||
<!--Events-->
|
||||
<scene sceneID="pPZ-gs-kHF">
|
||||
<objects>
|
||||
|
||||
42
AutoCat/Controllers/Osago/OsagoAddController.swift
Normal file
42
AutoCat/Controllers/Osago/OsagoAddController.swift
Normal file
@ -0,0 +1,42 @@
|
||||
import UIKit
|
||||
import Eureka
|
||||
|
||||
enum OsagoCheckSource: Equatable, CustomStringConvertible {
|
||||
case plateNumber(number: String)
|
||||
case vin(number: String)
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .plateNumber(let number):
|
||||
return "Plate number (\(number))"
|
||||
case .vin(let number):
|
||||
return "VIN (\(number))"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OsagoAddController: FormViewController {
|
||||
|
||||
var checkSources: [OsagoCheckSource] = []
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.title = "OSAGO check"
|
||||
|
||||
form +++ Section("Check parameters")
|
||||
<<< DateTimeInlineRow() { row in
|
||||
row.title = "Check date"
|
||||
row.value = Date()
|
||||
}
|
||||
<<< PickerInlineRow<OsagoCheckSource>() { row in
|
||||
row.title = "Check by"
|
||||
row.value = .plateNumber(number: "А123АА161")
|
||||
row.options = self.checkSources
|
||||
}
|
||||
|
||||
form +++ Section()
|
||||
<<< ButtonRow() { $0.title = "Check" }.onCellSelection { _, _ in
|
||||
print("Check")
|
||||
}
|
||||
}
|
||||
}
|
||||
29
AutoCat/Controllers/Osago/OsagoController.swift
Normal file
29
AutoCat/Controllers/Osago/OsagoController.swift
Normal file
@ -0,0 +1,29 @@
|
||||
import UIKit
|
||||
import Eureka
|
||||
|
||||
class OsagoController: FormViewController {
|
||||
|
||||
var vehicle: Vehicle? {
|
||||
didSet {
|
||||
self.form.allSections.forEach { $0.reload() }
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.title = "OSAGO contracts"
|
||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(checkNewDate(_:)))
|
||||
}
|
||||
|
||||
@objc func checkNewDate(_ sender: UIBarButtonItem) {
|
||||
guard let vehicle = self.vehicle else { return }
|
||||
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "OsagoAddController") as OsagoAddController
|
||||
controller.checkSources = [.plateNumber(number: vehicle.getNumber())]
|
||||
if let vin = vehicle.vin1, !vin.contains("*") {
|
||||
controller.checkSources.append(.vin(number: vin))
|
||||
}
|
||||
self.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
}
|
||||
@ -57,42 +57,6 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
||||
<<< LabelRow() { $0.title = "Category" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.category ?? "<unknown>" }
|
||||
<<< LabelRow() { $0.title = "Steering wheel position" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.stringFromBool(self.vehicle?.isRightWheel.value, yes: "Right", no: "Left") }
|
||||
<<< LabelRow() { $0.title = "Japanese" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.stringFromBool(self.vehicle?.isJapanese.value, yes: "Yes", no: "No") }
|
||||
<<< LabelRow() { $0.title = "Events" }.cellUpdate { cell, _ in
|
||||
cell.detailTextLabel?.text = String(self.vehicle?.events.count ?? 0)
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "EventsController") as EventsController
|
||||
controller.vehicle = self.vehicle
|
||||
self.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
|
||||
if self.vehicle?.ownershipPeriods.count ?? 0 > 0 {
|
||||
generalSection <<< LabelRow() { $0.title = "Owners" }.cellUpdate { cell, _ in
|
||||
cell.detailTextLabel?.text = String(self.vehicle?.ownershipPeriods.count ?? 0)
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "OwnersController") as OwnersController
|
||||
controller.owners = self.vehicle?.ownershipPeriods.toArray() ?? []
|
||||
self.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
if self.vehicle?.photos.count ?? 0 > 0 {
|
||||
generalSection <<< LabelRow() { $0.title = "Photos" }.cellUpdate { cell, _ in
|
||||
cell.detailTextLabel?.text = String(self.vehicle?.photos.count ?? 0)
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
let mediaBrowser = MediaBrowserViewController(index: 0, dataSource: self, delegate: self)
|
||||
mediaBrowser.shouldShowTitle = true
|
||||
mediaBrowser.title = self.vehicle?.photos.first?.description
|
||||
self.present(mediaBrowser, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
form +++ Section("Identifiers")
|
||||
<<< LabelRow() { $0.title = "Number" }.cellUpdate { cell, _ in
|
||||
@ -117,6 +81,55 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
||||
<<< LabelRow() { $0.title = "Volume (cm³)" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.engine?.volume.value ?? 0) }
|
||||
<<< LabelRow() { $0.title = "Power (HP)" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.engine?.powerHp ?? 0) }
|
||||
<<< LabelRow() { $0.title = "Power (kw)" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.engine?.powerKw.value ?? 0) }
|
||||
|
||||
let historySection = Section("History")
|
||||
form +++ historySection
|
||||
<<< LabelRow() { $0.title = "Events" }.cellUpdate { cell, _ in
|
||||
cell.detailTextLabel?.text = String(self.vehicle?.events.count ?? 0)
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "EventsController") as EventsController
|
||||
controller.vehicle = self.vehicle
|
||||
self.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
<<< LabelRow() { $0.title = "OSAGO" }.cellUpdate { cell, _ in
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
cell.detailTextLabel?.text = String(self.vehicle?.osagoContracts.count ?? 0)
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "OsagoController") as OsagoController
|
||||
controller.vehicle = self.vehicle
|
||||
self.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
|
||||
if self.vehicle?.ownershipPeriods.count ?? 0 > 0 {
|
||||
historySection <<< LabelRow() { $0.title = "Owners" }.cellUpdate { cell, _ in
|
||||
cell.detailTextLabel?.text = String(self.vehicle?.ownershipPeriods.count ?? 0)
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "OwnersController") as OwnersController
|
||||
controller.owners = self.vehicle?.ownershipPeriods.toArray() ?? []
|
||||
self.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
if self.vehicle?.photos.count ?? 0 > 0 {
|
||||
historySection <<< LabelRow() { $0.title = "Photos" }.cellUpdate { cell, _ in
|
||||
cell.detailTextLabel?.text = String(self.vehicle?.photos.count ?? 0)
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
let mediaBrowser = MediaBrowserViewController(index: 0, dataSource: self, delegate: self)
|
||||
mediaBrowser.shouldShowTitle = true
|
||||
mediaBrowser.title = self.vehicle?.photos.first?.description
|
||||
self.present(mediaBrowser, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func stringFromBool(_ value: Bool?, yes: String, no: String) -> String {
|
||||
|
||||
12
AutoCat/Models/Osago.swift
Normal file
12
AutoCat/Models/Osago.swift
Normal file
@ -0,0 +1,12 @@
|
||||
import Foundation
|
||||
import RealmSwift
|
||||
|
||||
class Osago: Object, Decodable {
|
||||
@objc dynamic var number: String
|
||||
@objc dynamic var name: String
|
||||
@objc dynamic var status: String
|
||||
@objc dynamic var restrictions: String
|
||||
@objc dynamic var insurant: String?
|
||||
@objc dynamic var owner: String?
|
||||
@objc dynamic var usageRegion: String?
|
||||
}
|
||||
@ -111,6 +111,7 @@ class Vehicle: Object, Decodable, Identifiable, Differentiable {
|
||||
let photos = List<VehiclePhoto>()
|
||||
let ownershipPeriods = List<VehicleOwnershipPeriod>()
|
||||
let events = List<VehicleEvent>()
|
||||
let osagoContracts = List<Osago>()
|
||||
|
||||
var identifier: String = ""
|
||||
var id: String {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user