Fixes for japanese flag and engine properties

This commit is contained in:
Selim Mustafaev 2020-10-28 13:46:34 +03:00
parent cc9a645fdc
commit 2b97df5fe1
8 changed files with 65 additions and 26 deletions

View File

@ -728,7 +728,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 51; CURRENT_PROJECT_VERSION = 53;
DEVELOPMENT_TEAM = 46DTTB8X4S; DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0; IPHONEOS_DEPLOYMENT_TARGET = 13.0;
@ -750,7 +750,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 51; CURRENT_PROJECT_VERSION = 53;
DEVELOPMENT_TEAM = 46DTTB8X4S; DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0; IPHONEOS_DEPLOYMENT_TARGET = 13.0;

View File

@ -14,35 +14,35 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>3</integer> <integer>8</integer>
</dict> </dict>
<key>DifferenceKit (Playground) 2.xcscheme</key> <key>DifferenceKit (Playground) 2.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>4</integer> <integer>9</integer>
</dict> </dict>
<key>DifferenceKit (Playground).xcscheme</key> <key>DifferenceKit (Playground).xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>2</integer> <integer>7</integer>
</dict> </dict>
<key>Eureka (Playground) 1.xcscheme</key> <key>Eureka (Playground) 1.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>5</integer>
</dict> </dict>
<key>Eureka (Playground) 2.xcscheme</key> <key>Eureka (Playground) 2.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>7</integer> <integer>6</integer>
</dict> </dict>
<key>Eureka (Playground) 3.xcscheme</key> <key>Eureka (Playground) 3.xcscheme</key>
<dict> <dict>
@ -70,7 +70,7 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>4</integer>
</dict> </dict>
<key>GettingStarted (Playground) 1.xcscheme</key> <key>GettingStarted (Playground) 1.xcscheme</key>
<dict> <dict>
@ -112,42 +112,42 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>13</integer> <integer>11</integer>
</dict> </dict>
<key>Rx (Playground) 1.xcscheme</key> <key>Rx (Playground) 1.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>9</integer> <integer>2</integer>
</dict> </dict>
<key>Rx (Playground) 2.xcscheme</key> <key>Rx (Playground) 2.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>10</integer> <integer>3</integer>
</dict> </dict>
<key>Rx (Playground).xcscheme</key> <key>Rx (Playground).xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>8</integer> <integer>1</integer>
</dict> </dict>
<key>SwiftDate (Playground) 1.xcscheme</key> <key>SwiftDate (Playground) 1.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>11</integer> <integer>12</integer>
</dict> </dict>
<key>SwiftDate (Playground) 2.xcscheme</key> <key>SwiftDate (Playground) 2.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>12</integer> <integer>13</integer>
</dict> </dict>
<key>SwiftDate (Playground) 3.xcscheme</key> <key>SwiftDate (Playground) 3.xcscheme</key>
<dict> <dict>
@ -175,7 +175,7 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>1</integer> <integer>10</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>

View File

@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let config = Realm.Configuration( let config = Realm.Configuration(
schemaVersion: 23, schemaVersion: 24,
migrationBlock: { migration, oldSchemaVersion in migrationBlock: { migration, oldSchemaVersion in
if oldSchemaVersion <= 3 { if oldSchemaVersion <= 3 {
var numbers: [String] = [] 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<Bool>()
}
}
}
}) })
Realm.Configuration.defaultConfiguration = config Realm.Configuration.defaultConfiguration = config

View File

@ -182,14 +182,18 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
cell?.configure(param: generalSection.description, value: vehicle.category ?? "<unknown>") cell?.configure(param: generalSection.description, value: vehicle.category ?? "<unknown>")
break break
case .wheelPosition: case .wheelPosition:
var position = "Unknown" var position = "<Unknown>"
if let rightWheel = vehicle.isRightWheel.value { if let rightWheel = vehicle.isRightWheel.value {
position = rightWheel ? "Right" : "Left" position = rightWheel ? "Right" : "Left"
} }
cell?.configure(param: generalSection.description, value: position) cell?.configure(param: generalSection.description, value: position)
break break
case .japanese: case .japanese:
cell?.configure(param: generalSection.description, value: vehicle.isJapanese ? "Yes" : "No") var japanese = "<Unknown>"
if let isJapanese = vehicle.isJapanese.value {
japanese = isJapanese ? "Yes" : "No"
}
cell?.configure(param: generalSection.description, value: japanese)
break break
case .owners: case .owners:
cell?.configure(param: generalSection.description, value: String(vehicle.ownershipPeriods.count)) cell?.configure(param: generalSection.description, value: String(vehicle.ownershipPeriods.count))

View File

@ -86,7 +86,11 @@ extension Vehicle {
} }
self.drawCell(y: y, width: w, height: cellHeight, title: "Steering wheel position", value: position, context: ctx) self.drawCell(y: y, width: w, height: cellHeight, title: "Steering wheel position", value: position, context: ctx)
y += cellHeight y += cellHeight
self.drawCell(y: y, width: w, height: cellHeight, title: "Japanese", value: self.isJapanese ? "Yes" : "No", lineMargin: 0, context: ctx) var japanese = "<Unknown>"
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 y += cellHeight + 32
"IDENTIFIERS".draw(with: CGRect(x: 15, y: y, width: w - 15, height: 24), options: .usesLineFragmentOrigin, attributes: headerAttributes, context: nil) "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 { if let rightWheel = self.isRightWheel.value {
position = rightWheel ? "Right" : "Left" position = rightWheel ? "Right" : "Left"
} }
var japanese = "<Unknown>"
if let isJapanese = self.isJapanese.value {
japanese = isJapanese ? "Yes" : "No"
}
text += "Steering wheel position: \(position)\n" text += "Steering wheel position: \(position)\n"
text += "Japanese: \(self.isJapanese ? "yes" : "no")\n" text += "Japanese: \(japanese)\n"
text += "Plate number: \(self.getNumber())\n" text += "Plate number: \(self.getNumber())\n"
if let vin = self.vin1 { text += "VIN: \(vin)\n" } if let vin = self.vin1 { text += "VIN: \(vin)\n" }
if let sts = self.sts { text += "STS: \(sts)\n" } if let sts = self.sts { text += "STS: \(sts)\n" }

View File

@ -22,6 +22,23 @@ class VehicleEngine: Object, Decodable {
@objc dynamic var powerHp: Float = 0 @objc dynamic var powerHp: Float = 0
var powerKw: RealmOptional<Float> = RealmOptional(0) var powerKw: RealmOptional<Float> = RealmOptional(0)
@objc dynamic var fuelType: String? @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 { class VehiclePhoto: Object, Decodable {
@ -87,7 +104,7 @@ class Vehicle: Object, Decodable, Identifiable, Differentiable {
@objc dynamic var sts: String? @objc dynamic var sts: String?
@objc dynamic var pts: String? @objc dynamic var pts: String?
var isRightWheel = RealmOptional<Bool>() var isRightWheel = RealmOptional<Bool>()
@objc dynamic var isJapanese: Bool = false var isJapanese: RealmOptional<Bool> = RealmOptional<Bool>()
@objc dynamic var addedDate: TimeInterval = 0 @objc dynamic var addedDate: TimeInterval = 0
@objc dynamic var updatedDate: TimeInterval = 0 @objc dynamic var updatedDate: TimeInterval = 0
@objc dynamic var addedBy: String = "" @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.color = try container.decodeIfPresent(String.self, forKey: .color)
self.year = try container.decodeIfPresent(Int.self, forKey: .year) ?? 0 self.year = try container.decodeIfPresent(Int.self, forKey: .year) ?? 0
self.category = try container.decodeIfPresent(String.self, forKey: .category) 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.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.currentNumber = try container.decodeIfPresent(String.self, forKey: .currentNumber)
self.vin1 = try container.decodeIfPresent(String.self, forKey: .vin1) self.vin1 = try container.decodeIfPresent(String.self, forKey: .vin1)
self.vin2 = try container.decodeIfPresent(String.self, forKey: .vin2) self.vin2 = try container.decodeIfPresent(String.self, forKey: .vin2)
self.sts = try container.decodeIfPresent(String.self, forKey: .sts) self.sts = try container.decodeIfPresent(String.self, forKey: .sts)
self.pts = try container.decodeIfPresent(String.self, forKey: .pts) self.pts = try container.decodeIfPresent(String.self, forKey: .pts)
self.isRightWheel = try container.decode(RealmOptional<Bool>.self, forKey: .isRightWheel) self.isRightWheel = try container.decode(RealmOptional<Bool>.self, forKey: .isRightWheel)
self.isJapanese = try container.decode(Bool.self, forKey: .isJapanese) self.isJapanese = try container.decode(RealmOptional<Bool>.self, forKey: .isJapanese)
self.addedDate = (try container.decode(TimeInterval.self, forKey: .addedDate))/1000 self.addedDate = (try container.decode(TimeInterval.self, forKey: .addedDate))/1000
self.addedBy = try container.decode(String.self, forKey: .addedBy) self.addedBy = try container.decode(String.self, forKey: .addedBy)

View File

@ -40,7 +40,7 @@ class Api {
} }
return URLSession.shared.rx.data(request: request).asSingle().map { data in 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("================================") // print("================================")
// if let string = str?.replacingOccurrences(of: "\\\"", with: "\"") // if let string = str?.replacingOccurrences(of: "\\\"", with: "\"")
// .replacingOccurrences(of: "\\'", with: "'") // .replacingOccurrences(of: "\\'", with: "'")

View File

@ -3,9 +3,9 @@ import Foundation
enum Constants { enum Constants {
static var baseUrl: String { static var baseUrl: String {
#if DEBUG #if DEBUG
return "http://127.0.0.1:3000/" //return "http://127.0.0.1:3000/"
//return "http://192.168.1.67:3000/" //return "http://192.168.1.67:3000/"
//return "https://vps.aliencat.pro:8443/" return "https://vps.aliencat.pro:8443/"
#else #else
return "https://vps.aliencat.pro:8443/" return "https://vps.aliencat.pro:8443/"
#endif #endif