Registered the LocationViewCell with the "table" outlet in the LocationsListViewController view controller and updated its "tableView(_: cellForRowAt: )" function to use and update the mentioned cell.
This commit is contained in:
parent
63f476157f
commit
2dc81fcc59
@ -29,6 +29,8 @@ class LocationsListViewController: BaseViewController {
|
||||
table.delegate = self
|
||||
table.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
table.register(LocationViewCell.self, forCellReuseIdentifier: LocationViewCell.identifier)
|
||||
|
||||
return table
|
||||
}()
|
||||
|
||||
@ -79,10 +81,21 @@ extension LocationsListViewController: UITableViewDataSource {
|
||||
_ tableView: UITableView,
|
||||
cellForRowAt indexPath: IndexPath
|
||||
) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath)
|
||||
guard let cell = tableView.dequeueReusableCell(
|
||||
withIdentifier: LocationViewCell.identifier,
|
||||
for: indexPath
|
||||
) as? LocationViewCell else {
|
||||
return .init()
|
||||
}
|
||||
|
||||
let entity = viewModel.dataItem(at: indexPath)
|
||||
|
||||
cell.textLabel?.text = entity.name
|
||||
cell.update(
|
||||
iconName: entity.source == .remote ? "network" : "house",
|
||||
name: entity.name,
|
||||
latitude: entity.latitude,
|
||||
longitude: entity.longitude
|
||||
)
|
||||
|
||||
return cell
|
||||
}
|
||||
@ -120,8 +133,6 @@ private extension LocationsListViewController {
|
||||
self.viewModel.loadLocations()
|
||||
}
|
||||
|
||||
table.register(UITableViewCell.self, forCellReuseIdentifier: "cellID")
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
error.widthAnchor.constraint(equalToConstant: 300),
|
||||
view.centerXAnchor.constraint(equalTo: error.centerXAnchor),
|
||||
|
@ -10,6 +10,8 @@ import UIKit
|
||||
|
||||
class LocationViewCell: UITableViewCell {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
static let identifier = "LocationViewCell"
|
||||
|
||||
// MARK: Outlets
|
||||
|
Loading…
x
Reference in New Issue
Block a user