diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj
index 18ec872..40e2c18 100644
--- a/AutoCat.xcodeproj/project.pbxproj
+++ b/AutoCat.xcodeproj/project.pbxproj
@@ -728,7 +728,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 51;
+ CURRENT_PROJECT_VERSION = 53;
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
@@ -750,7 +750,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 51;
+ CURRENT_PROJECT_VERSION = 53;
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
diff --git a/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist b/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist
index 9964a67..1d0f546 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
- 3
+ 8
DifferenceKit (Playground) 2.xcscheme
isShown
orderHint
- 4
+ 9
DifferenceKit (Playground).xcscheme
isShown
orderHint
- 2
+ 7
Eureka (Playground) 1.xcscheme
isShown
orderHint
- 6
+ 5
Eureka (Playground) 2.xcscheme
isShown
orderHint
- 7
+ 6
Eureka (Playground) 3.xcscheme
@@ -70,7 +70,7 @@
isShown
orderHint
- 5
+ 4
GettingStarted (Playground) 1.xcscheme
@@ -112,42 +112,42 @@
isShown
orderHint
- 13
+ 11
Rx (Playground) 1.xcscheme
isShown
orderHint
- 9
+ 2
Rx (Playground) 2.xcscheme
isShown
orderHint
- 10
+ 3
Rx (Playground).xcscheme
isShown
orderHint
- 8
+ 1
SwiftDate (Playground) 1.xcscheme
isShown
orderHint
- 11
+ 12
SwiftDate (Playground) 2.xcscheme
isShown
orderHint
- 12
+ 13
SwiftDate (Playground) 3.xcscheme
@@ -175,7 +175,7 @@
isShown
orderHint
- 1
+ 10
SuppressBuildableAutocreation
diff --git a/AutoCat/AppDelegate.swift b/AutoCat/AppDelegate.swift
index d5cd7b7..b501f40 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: 23,
+ schemaVersion: 24,
migrationBlock: { migration, oldSchemaVersion in
if oldSchemaVersion <= 3 {
var numbers: [String] = []
@@ -100,6 +100,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
}
+
+ if oldSchemaVersion <= 23 {
+ migration.enumerateObjects(ofType: "Vehicle") { old, new in
+ if let oldJapanese = old?["isJapanese"] as? Bool {
+ new?["isJapanese"] = RealmOptional(oldJapanese)
+ } else {
+ new?["isJapanese"] = RealmOptional()
+ }
+ }
+ }
})
Realm.Configuration.defaultConfiguration = config
diff --git a/AutoCat/Controllers/ReportController.swift b/AutoCat/Controllers/ReportController.swift
index 86e5198..41af00b 100644
--- a/AutoCat/Controllers/ReportController.swift
+++ b/AutoCat/Controllers/ReportController.swift
@@ -182,14 +182,18 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
cell?.configure(param: generalSection.description, value: vehicle.category ?? "")
break
case .wheelPosition:
- var position = "Unknown"
+ var position = ""
if let rightWheel = vehicle.isRightWheel.value {
position = rightWheel ? "Right" : "Left"
}
cell?.configure(param: generalSection.description, value: position)
break
case .japanese:
- cell?.configure(param: generalSection.description, value: vehicle.isJapanese ? "Yes" : "No")
+ var japanese = ""
+ if let isJapanese = vehicle.isJapanese.value {
+ japanese = isJapanese ? "Yes" : "No"
+ }
+ cell?.configure(param: generalSection.description, value: japanese)
break
case .owners:
cell?.configure(param: generalSection.description, value: String(vehicle.ownershipPeriods.count))
diff --git a/AutoCat/Extensions/VehicleReportImage.swift b/AutoCat/Extensions/VehicleReportImage.swift
index b590d59..9b2b01c 100644
--- a/AutoCat/Extensions/VehicleReportImage.swift
+++ b/AutoCat/Extensions/VehicleReportImage.swift
@@ -86,7 +86,11 @@ extension Vehicle {
}
self.drawCell(y: y, width: w, height: cellHeight, title: "Steering wheel position", value: position, context: ctx)
y += cellHeight
- self.drawCell(y: y, width: w, height: cellHeight, title: "Japanese", value: self.isJapanese ? "Yes" : "No", lineMargin: 0, context: ctx)
+ var japanese = ""
+ if let isJapanese = self.isJapanese.value {
+ japanese = isJapanese ? "Yes" : "No"
+ }
+ self.drawCell(y: y, width: w, height: cellHeight, title: "Japanese", value: japanese, lineMargin: 0, context: ctx)
y += cellHeight + 32
"IDENTIFIERS".draw(with: CGRect(x: 15, y: y, width: w - 15, height: 24), options: .usesLineFragmentOrigin, attributes: headerAttributes, context: nil)
@@ -214,8 +218,12 @@ extension Vehicle {
if let rightWheel = self.isRightWheel.value {
position = rightWheel ? "Right" : "Left"
}
+ var japanese = ""
+ if let isJapanese = self.isJapanese.value {
+ japanese = isJapanese ? "Yes" : "No"
+ }
text += "Steering wheel position: \(position)\n"
- text += "Japanese: \(self.isJapanese ? "yes" : "no")\n"
+ text += "Japanese: \(japanese)\n"
text += "Plate number: \(self.getNumber())\n"
if let vin = self.vin1 { text += "VIN: \(vin)\n" }
if let sts = self.sts { text += "STS: \(sts)\n" }
diff --git a/AutoCat/Models/Vehicle.swift b/AutoCat/Models/Vehicle.swift
index 5e2abba..a920a6d 100644
--- a/AutoCat/Models/Vehicle.swift
+++ b/AutoCat/Models/Vehicle.swift
@@ -22,6 +22,23 @@ class VehicleEngine: Object, Decodable {
@objc dynamic var powerHp: Float = 0
var powerKw: RealmOptional = RealmOptional(0)
@objc dynamic var fuelType: String?
+
+ enum CodingKeys: String, CodingKey {
+ case number, volume, powerHp, powerKw, fuelType
+ }
+
+ required init(from decoder: Decoder) throws {
+ let container = try decoder.container(keyedBy: CodingKeys.self)
+ self.number = try container.decodeIfPresent(String.self, forKey: .number)
+ self.volume = RealmOptional(try container.decodeIfPresent(Int.self, forKey: .volume))
+ self.powerHp = try container.decode(Float.self, forKey: .powerHp)
+ self.powerKw = RealmOptional(try container.decodeIfPresent(Float.self, forKey: .powerKw))
+ self.fuelType = try container.decodeIfPresent(String.self, forKey: .fuelType)
+ }
+
+ required init() {
+ super.init()
+ }
}
class VehiclePhoto: Object, Decodable {
@@ -87,7 +104,7 @@ class Vehicle: Object, Decodable, Identifiable, Differentiable {
@objc dynamic var sts: String?
@objc dynamic var pts: String?
var isRightWheel = RealmOptional()
- @objc dynamic var isJapanese: Bool = false
+ var isJapanese: RealmOptional = RealmOptional()
@objc dynamic var addedDate: TimeInterval = 0
@objc dynamic var updatedDate: TimeInterval = 0
@objc dynamic var addedBy: String = ""
@@ -138,15 +155,15 @@ class Vehicle: Object, Decodable, Identifiable, Differentiable {
self.color = try container.decodeIfPresent(String.self, forKey: .color)
self.year = try container.decodeIfPresent(Int.self, forKey: .year) ?? 0
self.category = try container.decodeIfPresent(String.self, forKey: .category)
- self.engine = try container.decodeIfPresent(VehicleEngine.self, forKey: .engine)
self.number = try container.decode(String.self, forKey: .number)
+ self.engine = try container.decodeIfPresent(VehicleEngine.self, forKey: .engine)
self.currentNumber = try container.decodeIfPresent(String.self, forKey: .currentNumber)
self.vin1 = try container.decodeIfPresent(String.self, forKey: .vin1)
self.vin2 = try container.decodeIfPresent(String.self, forKey: .vin2)
self.sts = try container.decodeIfPresent(String.self, forKey: .sts)
self.pts = try container.decodeIfPresent(String.self, forKey: .pts)
self.isRightWheel = try container.decode(RealmOptional.self, forKey: .isRightWheel)
- self.isJapanese = try container.decode(Bool.self, forKey: .isJapanese)
+ self.isJapanese = try container.decode(RealmOptional.self, forKey: .isJapanese)
self.addedDate = (try container.decode(TimeInterval.self, forKey: .addedDate))/1000
self.addedBy = try container.decode(String.self, forKey: .addedBy)
diff --git a/AutoCat/Utils/Api.swift b/AutoCat/Utils/Api.swift
index a59987b..1a587ab 100644
--- a/AutoCat/Utils/Api.swift
+++ b/AutoCat/Utils/Api.swift
@@ -40,7 +40,7 @@ class Api {
}
return URLSession.shared.rx.data(request: request).asSingle().map { data in
-// let str = String(data: data, encoding: .utf8)
+ let str = String(data: data, encoding: .utf8)
// print("================================")
// if let string = str?.replacingOccurrences(of: "\\\"", with: "\"")
// .replacingOccurrences(of: "\\'", with: "'")
diff --git a/AutoCat/Utils/Constants.swift b/AutoCat/Utils/Constants.swift
index 34e7169..fd8bd02 100644
--- a/AutoCat/Utils/Constants.swift
+++ b/AutoCat/Utils/Constants.swift
@@ -3,9 +3,9 @@ import Foundation
enum Constants {
static var baseUrl: String {
#if DEBUG
- return "http://127.0.0.1:3000/"
+ //return "http://127.0.0.1:3000/"
//return "http://192.168.1.67:3000/"
- //return "https://vps.aliencat.pro:8443/"
+ return "https://vps.aliencat.pro:8443/"
#else
return "https://vps.aliencat.pro:8443/"
#endif