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;
|
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 = 55;
|
CURRENT_PROJECT_VERSION = 56;
|
||||||
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;
|
||||||
@ -751,7 +751,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 = 55;
|
CURRENT_PROJECT_VERSION = 56;
|
||||||
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;
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
|||||||
var vehicle: Vehicle? {
|
var vehicle: Vehicle? {
|
||||||
didSet {
|
didSet {
|
||||||
loadViewIfNeeded()
|
loadViewIfNeeded()
|
||||||
|
self.updateReport()
|
||||||
self.form.allSections.forEach { $0.reload() }
|
self.form.allSections.forEach { $0.reload() }
|
||||||
self.navigationController?.setNavigationBarHidden(self.vehicle == nil, animated: false)
|
self.navigationController?.setNavigationBarHidden(self.vehicle == nil, animated: false)
|
||||||
}
|
}
|
||||||
@ -45,59 +46,40 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
form +++ Section()
|
form +++ Section()
|
||||||
<<< LabelRow().cellUpdate { cell, _ in
|
<<< LabelRow("Model").cellUpdate { cell, _ in cell.imageView?.kf.setImage(with: URL(string: self.vehicle?.brand?.logo ?? ""), placeholder: self.logoPlaceholder) }
|
||||||
cell.detailTextLabel?.text = self.vehicle?.brand?.name?.original ?? "<unknown>"
|
|
||||||
cell.imageView?.kf.setImage(with: URL(string: self.vehicle?.brand?.logo ?? ""), placeholder: self.logoPlaceholder)
|
|
||||||
}
|
|
||||||
|
|
||||||
let generalSection = Section("General")
|
form +++ Section("General")
|
||||||
form +++ generalSection
|
<<< LabelRow("Year") { $0.title = "Year" }
|
||||||
<<< LabelRow() { $0.title = "Year" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.year ?? 0) }
|
<<< LabelRow("Color") { $0.title = "Color" }
|
||||||
<<< LabelRow() { $0.title = "Color" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.color ?? "<unknown>" }
|
<<< LabelRow("Category") { $0.title = "Category" }
|
||||||
<<< LabelRow() { $0.title = "Category" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.category ?? "<unknown>" }
|
<<< LabelRow("STP") { $0.title = "Steering wheel position" }
|
||||||
<<< LabelRow() { $0.title = "Steering wheel position" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.stringFromBool(self.vehicle?.isRightWheel.value, yes: "Right", no: "Left") }
|
<<< LabelRow("Japanese") { $0.title = "Japanese" }
|
||||||
<<< LabelRow() { $0.title = "Japanese" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.stringFromBool(self.vehicle?.isJapanese.value, yes: "Yes", no: "No") }
|
|
||||||
|
|
||||||
form +++ Section("Identifiers")
|
form +++ Section("Identifiers")
|
||||||
<<< LabelRow() { $0.title = "Number" }.cellUpdate { cell, _ in
|
<<< LabelRow("PlateNumber") { $0.title = "Number" }
|
||||||
guard let vehicle = self.vehicle else {
|
<<< LabelRow("VIN") { $0.title = "VIN" }
|
||||||
cell.detailTextLabel?.text = "<unknown>"
|
<<< LabelRow("STS") { $0.title = "STS" }
|
||||||
return
|
<<< LabelRow("PTS") { $0.title = "PTS" }
|
||||||
}
|
|
||||||
|
|
||||||
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>" }
|
|
||||||
|
|
||||||
form +++ Section("Engine")
|
form +++ Section("Engine")
|
||||||
<<< LabelRow() { $0.title = "Number" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.engine?.number ?? "<unknown>" }
|
<<< LabelRow("EngineNumber") { $0.title = "Number" }
|
||||||
<<< LabelRow() { $0.title = "Fuel type" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = self.vehicle?.engine?.fuelType ?? "<unknown>" }
|
<<< LabelRow("FuelType") { $0.title = "Fuel type" }
|
||||||
<<< LabelRow() { $0.title = "Volume (cm³)" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.engine?.volume.value ?? 0) }
|
<<< LabelRow("Volume") { $0.title = "Volume (cm³)" }
|
||||||
<<< LabelRow() { $0.title = "Power (HP)" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.engine?.powerHp ?? 0) }
|
<<< LabelRow("PowerHP") { $0.title = "Power (HP)" }
|
||||||
<<< LabelRow() { $0.title = "Power (kw)" }.cellUpdate { cell, _ in cell.detailTextLabel?.text = String(self.vehicle?.engine?.powerKw.value ?? 0) }
|
<<< LabelRow("PowerKw") { $0.title = "Power (kw)" }
|
||||||
|
|
||||||
let historySection = Section("History")
|
form +++ Section("History")
|
||||||
form +++ historySection
|
<<< LabelRow("Events") { $0.title = "Events" }
|
||||||
<<< LabelRow() { $0.title = "Events" }.cellUpdate { cell, _ in
|
.cellUpdate { cell, _ in cell.accessoryType = .disclosureIndicator }
|
||||||
cell.detailTextLabel?.text = String(self.vehicle?.events.count ?? 0)
|
|
||||||
cell.accessoryType = .disclosureIndicator
|
|
||||||
}
|
|
||||||
.onCellSelection { _, _ in
|
.onCellSelection { _, _ in
|
||||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||||
let controller = sb.instantiateViewController(identifier: "EventsController") as EventsController
|
let controller = sb.instantiateViewController(identifier: "EventsController") as EventsController
|
||||||
controller.vehicle = self.vehicle
|
controller.vehicle = self.vehicle
|
||||||
self.navigationController?.pushViewController(controller, animated: true)
|
self.navigationController?.pushViewController(controller, animated: true)
|
||||||
}
|
}
|
||||||
<<< LabelRow() { $0.title = "OSAGO" }.cellUpdate { cell, _ in
|
|
||||||
cell.accessoryType = .disclosureIndicator
|
<<< LabelRow("OSAGO") { $0.title = "OSAGO" }
|
||||||
cell.detailTextLabel?.text = String(self.vehicle?.osagoContracts.count ?? 0)
|
.cellUpdate { cell, _ in cell.accessoryType = .disclosureIndicator }
|
||||||
}
|
|
||||||
.onCellSelection { _, _ in
|
.onCellSelection { _, _ in
|
||||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||||
let controller = sb.instantiateViewController(identifier: "OsagoController") as OsagoController
|
let controller = sb.instantiateViewController(identifier: "OsagoController") as OsagoController
|
||||||
@ -105,31 +87,65 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
|
|||||||
self.navigationController?.pushViewController(controller, animated: true)
|
self.navigationController?.pushViewController(controller, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.vehicle?.ownershipPeriods.count ?? 0 > 0 {
|
<<< LabelRow("Owners") { row in
|
||||||
historySection <<< LabelRow() { $0.title = "Owners" }.cellUpdate { cell, _ in
|
row.title = "Owners"
|
||||||
cell.detailTextLabel?.text = String(self.vehicle?.ownershipPeriods.count ?? 0)
|
row.disabled = "$Owners == '0'"
|
||||||
cell.accessoryType = .disclosureIndicator
|
|
||||||
}
|
}
|
||||||
.onCellSelection { _, _ in
|
.cellUpdate { cell, _ in cell.accessoryType = .disclosureIndicator }
|
||||||
let sb = UIStoryboard(name: "Main", bundle: nil)
|
.onCellSelection { _, row in
|
||||||
let controller = sb.instantiateViewController(identifier: "OwnersController") as OwnersController
|
if row.value != "0" {
|
||||||
controller.owners = self.vehicle?.ownershipPeriods.toArray() ?? []
|
let sb = UIStoryboard(name: "Main", bundle: nil)
|
||||||
self.navigationController?.pushViewController(controller, animated: true)
|
let controller = sb.instantiateViewController(identifier: "OwnersController") as OwnersController
|
||||||
|
controller.owners = self.vehicle?.ownershipPeriods.toArray() ?? []
|
||||||
|
self.navigationController?.pushViewController(controller, animated: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if self.vehicle?.photos.count ?? 0 > 0 {
|
<<< LabelRow("Photos") { row in
|
||||||
historySection <<< LabelRow() { $0.title = "Photos" }.cellUpdate { cell, _ in
|
row.title = "Photos"
|
||||||
cell.detailTextLabel?.text = String(self.vehicle?.photos.count ?? 0)
|
row.disabled = "$Photos == '0'"
|
||||||
cell.accessoryType = .disclosureIndicator
|
|
||||||
}
|
}
|
||||||
.onCellSelection { _, _ in
|
.cellUpdate { cell, _ in cell.accessoryType = .disclosureIndicator }
|
||||||
let mediaBrowser = MediaBrowserViewController(index: 0, dataSource: self, delegate: self)
|
.onCellSelection { _, row in
|
||||||
mediaBrowser.shouldShowTitle = true
|
if row.value != "0" {
|
||||||
mediaBrowser.title = self.vehicle?.photos.first?.description
|
let mediaBrowser = MediaBrowserViewController(index: 0, dataSource: self, delegate: self)
|
||||||
self.present(mediaBrowser, animated: true, completion: nil)
|
mediaBrowser.shouldShowTitle = true
|
||||||
|
mediaBrowser.title = self.vehicle?.photos.first?.description
|
||||||
|
self.present(mediaBrowser, animated: true, completion: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
func stringFromBool(_ value: Bool?, yes: String, no: String) -> String {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user