diff --git a/AutoCat2.xcodeproj/project.pbxproj b/AutoCat2.xcodeproj/project.pbxproj index e856785..6e7632f 100644 --- a/AutoCat2.xcodeproj/project.pbxproj +++ b/AutoCat2.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ 6841AF924E165F1B3A3B5FB5 /* AuthController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6841ABEA0314E3B4E438C311 /* AuthController.swift */; }; 7A1D80E027F1F275007BD64F /* DifferenceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7A1D80DF27F1F275007BD64F /* DifferenceKit */; }; 7A1D80E627F20FCB007BD64F /* DifferenceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7A1D80E527F20FCB007BD64F /* DifferenceKit */; }; + 7A1D80E827F30399007BD64F /* VModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1D80E727F30399007BD64F /* VModel.swift */; }; 7A24C19727EE212E00049E7F /* RoadNumbers.otf in Resources */ = {isa = PBXBuildFile; fileRef = 7A24C19527EE212E00049E7F /* RoadNumbers.otf */; }; 7A24C19827EE212E00049E7F /* RoadNumbers2.0.otf in Resources */ = {isa = PBXBuildFile; fileRef = 7A24C19627EE212E00049E7F /* RoadNumbers2.0.otf */; }; 7A24C19C27EE25B400049E7F /* PlateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A24C19A27EE25B400049E7F /* PlateView.swift */; }; @@ -132,6 +133,7 @@ 6841ADEEC165FA9124C5EF40 /* UITextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UITextField.swift; sourceTree = ""; }; 6841AFB465BF16E122875D9A /* ACButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ACButton.swift; sourceTree = ""; }; 6841AFE790F6FC06838B1E2C /* UIControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIControl.swift; sourceTree = ""; }; + 7A1D80E727F30399007BD64F /* VModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VModel.swift; sourceTree = ""; }; 7A24C19527EE212E00049E7F /* RoadNumbers.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = RoadNumbers.otf; sourceTree = ""; }; 7A24C19627EE212E00049E7F /* RoadNumbers2.0.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = RoadNumbers2.0.otf; sourceTree = ""; }; 7A24C19A27EE25B400049E7F /* PlateView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlateView.swift; sourceTree = ""; }; @@ -421,6 +423,7 @@ 7A49F50927D406CB00AEAAE0 /* Settings.swift */, 7A49F50A27D406CB00AEAAE0 /* PlateNumber.swift */, 7A49F50B27D406CB00AEAAE0 /* VName.swift */, + 7A1D80E727F30399007BD64F /* VModel.swift */, ); path = Models; sourceTree = ""; @@ -726,6 +729,7 @@ 7A49F50227D406C300AEAAE0 /* StorageService.swift in Sources */, 7A49F4FE27D406BA00AEAAE0 /* AnyEncodable.swift in Sources */, 7A49F51227D406CB00AEAAE0 /* VName.swift in Sources */, + 7A1D80E827F30399007BD64F /* VModel.swift in Sources */, 7A49F51127D406CB00AEAAE0 /* PlateNumber.swift in Sources */, 7A49F50C27D406CB00AEAAE0 /* VBrand.swift in Sources */, 7A49F51027D406CB00AEAAE0 /* Settings.swift in Sources */, diff --git a/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents b/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents index c70a61c..8eb7acc 100644 --- a/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents +++ b/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents @@ -6,20 +6,38 @@ + + + + + + + + + + + + + + + + + - - + + + \ No newline at end of file diff --git a/AutoCatCore/Models/VBrand.swift b/AutoCatCore/Models/VBrand.swift index 9431752..a0278ce 100644 --- a/AutoCatCore/Models/VBrand.swift +++ b/AutoCatCore/Models/VBrand.swift @@ -9,14 +9,11 @@ public struct VBrand: Decodable { extension CDVBrand { - convenience init(vbrand: VBrand, context: NSManagedObjectContext) { + convenience init(vbrand: VBrand?, context: NSManagedObjectContext) { self.init(context: context) - self.logo = vbrand.logo - - if let vname = vbrand.name { - self.name = CDVName(vname: vname, context: context) - } + self.logo = vbrand?.logo + self.name = CDVName(vname: vbrand?.name, context: context) } } diff --git a/AutoCatCore/Models/VModel.swift b/AutoCatCore/Models/VModel.swift new file mode 100644 index 0000000..de61d59 --- /dev/null +++ b/AutoCatCore/Models/VModel.swift @@ -0,0 +1,22 @@ +// +// VModel.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 29.03.2022. +// + +import Foundation +import CoreData + +public struct VModel: Decodable { + + let name: VName? +} + +extension CDVModel { + + convenience init(model: VModel?, context: NSManagedObjectContext) { + self.init(context: context) + self.name = CDVName(vname: model?.name, context: context) + } +} diff --git a/AutoCatCore/Models/VName.swift b/AutoCatCore/Models/VName.swift index 7236600..5b95233 100644 --- a/AutoCatCore/Models/VName.swift +++ b/AutoCatCore/Models/VName.swift @@ -9,11 +9,11 @@ public struct VName: Decodable { extension CDVName { - convenience init(vname: VName, context: NSManagedObjectContext) { + convenience init(vname: VName?, context: NSManagedObjectContext) { self.init(context: context) - self.normalized = vname.normalized - self.original = vname.original + self.normalized = vname?.normalized + self.original = vname?.original } } diff --git a/AutoCatCore/Models/Vehicle.swift b/AutoCatCore/Models/Vehicle.swift index 4a56331..dca0cd1 100644 --- a/AutoCatCore/Models/Vehicle.swift +++ b/AutoCatCore/Models/Vehicle.swift @@ -7,8 +7,19 @@ public struct Vehicle: Decodable { public let number: String public let currentNumber: String? public let brand: VBrand? + public let model: VModel? public let addedDate: TimeInterval public let updatedDate: TimeInterval + public let color: String? + public let year: Int64? + public let category: String? + public let vin1: String? + public let vin2: String? + public let sts: String? + public let pts: String? + public let isRightWheel: Bool? + public let isJapanese: Bool? + public let addedBy: String? } extension CDVehicle: Dated { @@ -42,10 +53,19 @@ extension CDVehicle { self.currentNumber = vehicle.currentNumber self.addedDate = vehicle.addedDate/1000 self.updatedDate = vehicle.updatedDate/1000 - - if let vbrand = vehicle.brand { - self.brand = CDVBrand(vbrand: vbrand, context: context) - } + self.color = vehicle.color + self.brand = CDVBrand(vbrand: vehicle.brand, context: context) + self.model = CDVModel(model: vehicle.model, context: context) + self.year = vehicle.year ?? 0 + self.category = category + self.vin1 = vehicle.vin1 + self.vin2 = vehicle.vin2 + self.sts = vehicle.sts + self.pts = vehicle.pts + self.isRightWheel = vehicle.isRightWheel ?? false + self.isJapanese = vehicle.isJapanese ?? false + self.addedBy = vehicle.addedBy + self.synchronized = true } public var unrecognized: Bool {