Fixed bug with displaying photos and ownership periods
This commit is contained in:
parent
64d11a0413
commit
951781c137
@ -728,7 +728,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 55;
|
||||
CURRENT_PROJECT_VERSION = 56;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
@ -751,7 +751,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 55;
|
||||
CURRENT_PROJECT_VERSION = 56;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
|
||||
@ -15,6 +15,7 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
||||
var vehicle: Vehicle? {
|
||||
didSet {
|
||||
loadViewIfNeeded()
|
||||
self.updateReport()
|
||||
self.form.allSections.forEach { $0.reload() }
|
||||
self.navigationController?.setNavigationBarHidden(self.vehicle == nil, animated: false)
|
||||
}
|
||||
@ -45,59 +46,40 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
||||
}
|
||||
|
||||
form +++ Section()
|
||||
<<< LabelRow().cellUpdate { cell, _ in
|
||||
cell.detailTextLabel?.text = self.vehicle?.brand?.name?.original ?? "<unknown>"
|
||||
cell.imageView?.kf.setImage(with: URL(string: self.vehicle?.brand?.logo ?? ""), placeholder: self.logoPlaceholder)
|
||||
}
|
||||
<<< LabelRow("Model").cellUpdate { cell, _ in cell.imageView?.kf.setImage(with: URL(string: self.vehicle?.brand?.logo ?? ""), placeholder: self.logoPlaceholder) }
|
||||
|
||||
let generalSection = Section("General")
|
||||
form +++ generalSection
|
||||
<<< LabelRow() { $0.title = "Year" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.year ?? 0) }
|
||||
<<< LabelRow() { $0.title = "Color" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.color ?? "<unknown>" }
|
||||
<<< 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") }
|
||||
form +++ Section("General")
|
||||
<<< LabelRow("Year") { $0.title = "Year" }
|
||||
<<< LabelRow("Color") { $0.title = "Color" }
|
||||
<<< LabelRow("Category") { $0.title = "Category" }
|
||||
<<< LabelRow("STP") { $0.title = "Steering wheel position" }
|
||||
<<< LabelRow("Japanese") { $0.title = "Japanese" }
|
||||
|
||||
form +++ Section("Identifiers")
|
||||
<<< LabelRow() { $0.title = "Number" }.cellUpdate { cell, _ in
|
||||
guard let vehicle = self.vehicle else {
|
||||
cell.detailTextLabel?.text = "<unknown>"
|
||||
return
|
||||
}
|
||||
|
||||
var num = vehicle.getNumber()
|
||||
if vehicle.outdated, let current = vehicle.currentNumber {
|
||||
num = "\(vehicle.getNumber()) (\(current))"
|
||||
}
|
||||
cell.detailTextLabel?.text = num
|
||||
}
|
||||
<<< LabelRow() { $0.title = "VIN" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.vin1 ?? "<unknown>" }
|
||||
<<< LabelRow() { $0.title = "STS" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.sts ?? "<unknown>" }
|
||||
<<< LabelRow() { $0.title = "PTS" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.pts ?? "<unknown>" }
|
||||
<<< LabelRow("PlateNumber") { $0.title = "Number" }
|
||||
<<< LabelRow("VIN") { $0.title = "VIN" }
|
||||
<<< LabelRow("STS") { $0.title = "STS" }
|
||||
<<< LabelRow("PTS") { $0.title = "PTS" }
|
||||
|
||||
form +++ Section("Engine")
|
||||
<<< LabelRow() { $0.title = "Number" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.engine?.number ?? "<unknown>" }
|
||||
<<< LabelRow() { $0.title = "Fuel type" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.engine?.fuelType ?? "<unknown>" }
|
||||
<<< 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) }
|
||||
<<< LabelRow("EngineNumber") { $0.title = "Number" }
|
||||
<<< LabelRow("FuelType") { $0.title = "Fuel type" }
|
||||
<<< LabelRow("Volume") { $0.title = "Volume (cm³)" }
|
||||
<<< LabelRow("PowerHP") { $0.title = "Power (HP)" }
|
||||
<<< LabelRow("PowerKw") { $0.title = "Power (kw)" }
|
||||
|
||||
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
|
||||
}
|
||||
form +++ Section("History")
|
||||
<<< LabelRow("Events") { $0.title = "Events" }
|
||||
.cellUpdate { cell, _ in 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)
|
||||
}
|
||||
|
||||
<<< LabelRow("OSAGO") { $0.title = "OSAGO" }
|
||||
.cellUpdate { cell, _ in cell.accessoryType = .disclosureIndicator }
|
||||
.onCellSelection { _, _ in
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "OsagoController") as OsagoController
|
||||
@ -105,12 +87,13 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
||||
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
|
||||
<<< LabelRow("Owners") { row in
|
||||
row.title = "Owners"
|
||||
row.disabled = "$Owners == '0'"
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
.cellUpdate { cell, _ in cell.accessoryType = .disclosureIndicator }
|
||||
.onCellSelection { _, row in
|
||||
if row.value != "0" {
|
||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||
let controller = sb.instantiateViewController(identifier: "OwnersController") as OwnersController
|
||||
controller.owners = self.vehicle?.ownershipPeriods.toArray() ?? []
|
||||
@ -118,12 +101,13 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
<<< LabelRow("Photos") { row in
|
||||
row.title = "Photos"
|
||||
row.disabled = "$Photos == '0'"
|
||||
}
|
||||
.onCellSelection { _, _ in
|
||||
.cellUpdate { cell, _ in cell.accessoryType = .disclosureIndicator }
|
||||
.onCellSelection { _, row in
|
||||
if row.value != "0" {
|
||||
let mediaBrowser = MediaBrowserViewController(index: 0, dataSource: self, delegate: self)
|
||||
mediaBrowser.shouldShowTitle = true
|
||||
mediaBrowser.title = self.vehicle?.photos.first?.description
|
||||
@ -132,6 +116,38 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
||||
}
|
||||
}
|
||||
|
||||
func row(_ tag: String) -> LabelRow? {
|
||||
self.form.rowBy(tag: tag) as? LabelRow
|
||||
}
|
||||
|
||||
func updateReport() {
|
||||
self.row("Model")?.value = self.vehicle?.brand?.name?.original ?? "<unknown>"
|
||||
self.row("Year")?.value = String(self.vehicle?.year ?? 0)
|
||||
self.row("Color")?.value = self.vehicle?.color ?? "<unknown>"
|
||||
self.row("Category")?.value = self.vehicle?.category ?? "<unknown>"
|
||||
self.row("STP")?.value = self.stringFromBool(self.vehicle?.isRightWheel.value, yes: "Right", no: "Left")
|
||||
self.row("Japanese")?.value = self.stringFromBool(self.vehicle?.isJapanese.value, yes: "Yes", no: "No")
|
||||
|
||||
var num = self.vehicle?.getNumber() ?? "<unknown>"
|
||||
if self.vehicle?.outdated ?? false, let current = self.vehicle?.currentNumber {
|
||||
num = "\(self.vehicle!.getNumber()) (\(current))"
|
||||
}
|
||||
self.row("PlateNumber")?.value = num
|
||||
|
||||
self.row("VIN")?.value = self.vehicle?.vin1 ?? "<unknown>"
|
||||
self.row("STS")?.value = self.vehicle?.sts ?? "<unknown>"
|
||||
self.row("PTS")?.value = self.vehicle?.pts ?? "<unknown>"
|
||||
self.row("EngineNumber")?.value = self.vehicle?.engine?.number ?? "<unknown>"
|
||||
self.row("FuelType")?.value = self.vehicle?.engine?.fuelType ?? "<unknown>"
|
||||
self.row("Volume")?.value = String(self.vehicle?.engine?.volume.value ?? 0)
|
||||
self.row("PowerHP")?.value = String(self.vehicle?.engine?.powerHp ?? 0)
|
||||
self.row("PowerKw")?.value = String(self.vehicle?.engine?.powerKw.value ?? 0)
|
||||
self.row("Events")?.value = String(self.vehicle?.events.count ?? 0)
|
||||
self.row("OSAGO")?.value = String(self.vehicle?.osagoContracts.count ?? 0)
|
||||
self.row("Owners")?.value = String(self.vehicle?.ownershipPeriods.count ?? 0)
|
||||
self.row("Photos")?.value = String(self.vehicle?.photos.count ?? 0)
|
||||
}
|
||||
|
||||
func stringFromBool(_ value: Bool?, yes: String, no: String) -> String {
|
||||
guard let value = value else { return "<unknown>" }
|
||||
return value ? yes : no
|
||||
|
||||
Loading…
Reference in New Issue
Block a user