added other labels to the employee cell
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
a1214cf38b
commit
ee4d976b2b
@ -13,6 +13,10 @@ public class EmployeeTableViewCell: UITableViewCell {
|
|||||||
private let photoImageView = UIImageView()
|
private let photoImageView = UIImageView()
|
||||||
private let nameLabel = UILabel()
|
private let nameLabel = UILabel()
|
||||||
private let emailLabel = UILabel()
|
private let emailLabel = UILabel()
|
||||||
|
private let teamLabel = UILabel()
|
||||||
|
private let employeeTypeLabel = UILabel()
|
||||||
|
private let phoneLabel = UILabel()
|
||||||
|
private let bioLabel = UILabel()
|
||||||
private let stackView = UIStackView()
|
private let stackView = UIStackView()
|
||||||
|
|
||||||
private var cancellable: AnyCancellable?
|
private var cancellable: AnyCancellable?
|
||||||
@ -42,6 +46,22 @@ public class EmployeeTableViewCell: UITableViewCell {
|
|||||||
emailLabel.textColor = .blue
|
emailLabel.textColor = .blue
|
||||||
emailLabel.adjustsFontForContentSizeCategory = true // Adapts to Dynamic Type
|
emailLabel.adjustsFontForContentSizeCategory = true // Adapts to Dynamic Type
|
||||||
|
|
||||||
|
teamLabel.font = UIFont.preferredFont(forTextStyle: .subheadline) // Secondary, smaller text
|
||||||
|
teamLabel.textColor = .gray
|
||||||
|
teamLabel.adjustsFontForContentSizeCategory = true // Adapts to Dynamic Type
|
||||||
|
|
||||||
|
employeeTypeLabel.font = UIFont.preferredFont(forTextStyle: .subheadline)
|
||||||
|
employeeTypeLabel.adjustsFontForContentSizeCategory = true // Adapts to Dynamic Type
|
||||||
|
|
||||||
|
phoneLabel.font = UIFont.preferredFont(forTextStyle: .body) // Standard body text
|
||||||
|
phoneLabel.textColor = .darkGray
|
||||||
|
phoneLabel.adjustsFontForContentSizeCategory = true// Adapts to Dynamic Type
|
||||||
|
|
||||||
|
bioLabel.font = UIFont.preferredFont(forTextStyle: .footnote) // Smaller text for additional info
|
||||||
|
bioLabel.numberOfLines = 0
|
||||||
|
bioLabel.textColor = .lightGray
|
||||||
|
bioLabel.adjustsFontForContentSizeCategory = true // Adapts to Dynamic Type
|
||||||
|
|
||||||
// Configure stackView
|
// Configure stackView
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
stackView.spacing = 5
|
stackView.spacing = 5
|
||||||
@ -49,7 +69,11 @@ public class EmployeeTableViewCell: UITableViewCell {
|
|||||||
|
|
||||||
// Add labels to stackView
|
// Add labels to stackView
|
||||||
stackView.addArrangedSubview(nameLabel)
|
stackView.addArrangedSubview(nameLabel)
|
||||||
|
stackView.addArrangedSubview(teamLabel)
|
||||||
|
stackView.addArrangedSubview(employeeTypeLabel)
|
||||||
|
stackView.addArrangedSubview(phoneLabel)
|
||||||
stackView.addArrangedSubview(emailLabel)
|
stackView.addArrangedSubview(emailLabel)
|
||||||
|
stackView.addArrangedSubview(bioLabel)
|
||||||
|
|
||||||
// Add subviews
|
// Add subviews
|
||||||
contentView.addSubview(photoImageView)
|
contentView.addSubview(photoImageView)
|
||||||
@ -71,9 +95,14 @@ public class EmployeeTableViewCell: UITableViewCell {
|
|||||||
|
|
||||||
public override func prepareForReuse() {
|
public override func prepareForReuse() {
|
||||||
super.prepareForReuse()
|
super.prepareForReuse()
|
||||||
|
cancellable = nil
|
||||||
photoImageView.image = UIImage(systemName: "person.crop.circle")
|
photoImageView.image = UIImage(systemName: "person.crop.circle")
|
||||||
nameLabel.text = nil
|
nameLabel.text = nil
|
||||||
emailLabel.text = nil
|
emailLabel.text = nil
|
||||||
|
teamLabel.text = nil
|
||||||
|
employeeTypeLabel.text = nil
|
||||||
|
phoneLabel.text = nil
|
||||||
|
bioLabel.text = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
public func configure(with viewModel: EmployeeCellViewModel) {
|
public func configure(with viewModel: EmployeeCellViewModel) {
|
||||||
@ -88,6 +117,14 @@ public class EmployeeTableViewCell: UITableViewCell {
|
|||||||
// 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
|
||||||
|
teamLabel.text = viewModel.team
|
||||||
|
employeeTypeLabel.text = viewModel.employeeType
|
||||||
|
phoneLabel.text = viewModel.phoneNumber
|
||||||
|
bioLabel.text = viewModel.biography
|
||||||
|
|
||||||
|
// Dynamically show or hide elements based on their content
|
||||||
|
phoneLabel.isHidden = viewModel.phoneNumber == nil
|
||||||
|
bioLabel.isHidden = viewModel.biography == nil
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user