wired up the ViewModel's SmallPhoto property change event with Combine
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
9d3a23e69d
commit
887cfd99ea
@ -5,6 +5,7 @@
|
|||||||
// Created by Matt Bruce on 1/20/25.
|
// Created by Matt Bruce on 1/20/25.
|
||||||
//
|
//
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Combine
|
||||||
|
|
||||||
public class EmployeeTableViewCell: UITableViewCell {
|
public class EmployeeTableViewCell: UITableViewCell {
|
||||||
static let identifier = "EmployeeTableViewCell"
|
static let identifier = "EmployeeTableViewCell"
|
||||||
@ -14,6 +15,8 @@ public class EmployeeTableViewCell: UITableViewCell {
|
|||||||
private let emailLabel = UILabel()
|
private let emailLabel = UILabel()
|
||||||
private let stackView = UIStackView()
|
private let stackView = UIStackView()
|
||||||
|
|
||||||
|
private var cancellable: AnyCancellable?
|
||||||
|
|
||||||
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
setupUI()
|
setupUI()
|
||||||
@ -75,6 +78,13 @@ public class EmployeeTableViewCell: UITableViewCell {
|
|||||||
|
|
||||||
public func configure(with viewModel: EmployeeCellViewModel) {
|
public func configure(with viewModel: EmployeeCellViewModel) {
|
||||||
|
|
||||||
|
// Bind the image to the photoImageView
|
||||||
|
cancellable = viewModel.$smallPhoto
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink { [weak self] image in
|
||||||
|
self?.photoImageView.image = image
|
||||||
|
}
|
||||||
|
|
||||||
// Bind data to UI components
|
// Bind data to UI components
|
||||||
nameLabel.text = viewModel.fullName
|
nameLabel.text = viewModel.fullName
|
||||||
emailLabel.text = viewModel.emailAddress
|
emailLabel.text = viewModel.emailAddress
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user