Fix for outdated plate numbers

This commit is contained in:
Selim Mustafaev 2020-09-12 11:38:07 +03:00
parent 6dbcb56b27
commit 30fd465f06
7 changed files with 28 additions and 9 deletions

View File

@ -743,7 +743,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 = 30; CURRENT_PROJECT_VERSION = 31;
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;
@ -765,7 +765,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 = 30; CURRENT_PROJECT_VERSION = 31;
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

@ -23,7 +23,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: 16, schemaVersion: 17,
migrationBlock: { migration, oldSchemaVersion in migrationBlock: { migration, oldSchemaVersion in
if oldSchemaVersion <= 3 { if oldSchemaVersion <= 3 {
var numbers: [String] = [] var numbers: [String] = []

View File

@ -18,7 +18,11 @@ class VehicleCell: UITableViewCell {
func configure(with vehicle: Vehicle) { func configure(with vehicle: Vehicle) {
self.name.text = vehicle.brand?.name?.original ?? "<unknown>" self.name.text = vehicle.brand?.name?.original ?? "<unknown>"
self.plate.number = PlateNumber(vehicle.number) self.plate.number = PlateNumber(vehicle.number)
self.plate.unrecognized = vehicle.unrecognized if vehicle.unrecognized {
self.plate.foreground = .systemRed
} else if vehicle.outdated {
self.plate.foreground = .systemGray2
}
self.date.text = formatter.string(from: Date(timeIntervalSince1970: vehicle.addedDate/1000)) self.date.text = formatter.string(from: Date(timeIntervalSince1970: vehicle.addedDate/1000))
} }

View File

@ -202,7 +202,11 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
if let idSection = ReportIdSection(rawValue: indexPath.item) { if let idSection = ReportIdSection(rawValue: indexPath.item) {
switch idSection { switch idSection {
case .number: case .number:
cell?.configure(param: idSection.description, value: vehicle.number) var num = vehicle.number
if vehicle.outdated, let current = vehicle.currentNumber {
num = "\(vehicle.number) (\(current))"
}
cell?.configure(param: idSection.description, value: num)
break break
case .vin: case .vin:
cell?.configure(param: idSection.description, value: vehicle.vin1 ?? "<unknown>") cell?.configure(param: idSection.description, value: vehicle.vin1 ?? "<unknown>")

View File

@ -74,6 +74,7 @@ class Vehicle: Object, Decodable, IdentifiableType {
@objc dynamic var category: String? @objc dynamic var category: String?
@objc dynamic var engine: VehicleEngine? @objc dynamic var engine: VehicleEngine?
@objc dynamic var number: String = "" @objc dynamic var number: String = ""
@objc dynamic var currentNumber: String?
@objc dynamic var vin1: String? @objc dynamic var vin1: String?
@objc dynamic var vin2: String? @objc dynamic var vin2: String?
@objc dynamic var sts: String? @objc dynamic var sts: String?
@ -96,6 +97,7 @@ class Vehicle: Object, Decodable, IdentifiableType {
case category case category
case engine case engine
case number case number
case currentNumber
case vin1 case vin1
case vin2 case vin2
case sts case sts
@ -118,6 +120,7 @@ class Vehicle: Object, Decodable, IdentifiableType {
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.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.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)
@ -156,4 +159,12 @@ class Vehicle: Object, Decodable, IdentifiableType {
var unrecognized: Bool { var unrecognized: Bool {
return self.brand == nil return self.brand == nil
} }
var outdated: Bool {
if let current = self.currentNumber {
return current != self.number
} else {
return false
}
}
} }

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

View File

@ -20,7 +20,7 @@ class PlateView: UIView {
} }
} }
var unrecognized: Bool = false { var foreground: UIColor? {
didSet { didSet {
self.layoutSubviews() self.layoutSubviews()
} }
@ -70,7 +70,7 @@ class PlateView: UIView {
guard let fgColorMain = UIColor(named: "PlateForeground")?.cgColor else { return } guard let fgColorMain = UIColor(named: "PlateForeground")?.cgColor else { return }
guard let bgColor = UIColor(named: "PlateBackground")?.cgColor else { return } guard let bgColor = UIColor(named: "PlateBackground")?.cgColor else { return }
let fgColor = self.unrecognized ? /*fgColorErr*/UIColor.systemRed.cgColor : fgColorMain let fgColor = self.foreground?.cgColor ?? fgColorMain
self.bgLayer.backgroundColor = fgColor self.bgLayer.backgroundColor = fgColor
self.bgLayer.frame = self.bounds self.bgLayer.frame = self.bounds