block-employee-directory/EmployeeDirectory/Views/TableFooterView.swift
2025-01-20 18:37:11 -06:00

52 lines
1.5 KiB
Swift

//
// EmptyStateFooterView.swift
// EmployeeDirectory
//
// Created by Matt Bruce on 1/20/25.
//
import UIKit
public class TableFooterView: UIView {
/// Label used to show the message
private let messageLabel: UILabel = {
let label = UILabel()
label.textColor = .gray
label.textAlignment = .center
label.font = UIFont.preferredFont(forTextStyle: .body) // Use a text style for Dynamic Type
label.adjustsFontForContentSizeCategory = true // Enable Dynamic Type adjustments
label.numberOfLines = 0
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
init(message: String) {
super.init(frame: .zero)
setupUI()
update(message: message)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
/// Setup the UI
private func setupUI() {
addSubview(messageLabel)
NSLayoutConstraint.activate([
messageLabel.centerXAnchor.constraint(equalTo: centerXAnchor),
messageLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
messageLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 16),
messageLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -16)
])
}
/// Updates the Current Message
/// - Parameter message: message to show
public func update(message: String) {
messageLabel.text = message
}
}