60 lines
1.7 KiB
Swift
60 lines
1.7 KiB
Swift
//
|
|
// EmptyStateFooterView.swift
|
|
// EmployeeDirectory
|
|
//
|
|
// Created by Matt Bruce on 1/20/25.
|
|
//
|
|
import UIKit
|
|
|
|
/// Meant to be used as a Message for State in a TableView.
|
|
public class TableFooterView: UIView {
|
|
|
|
// MARK: - Properties
|
|
|
|
/// 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
|
|
}()
|
|
|
|
// MARK: - Initializer
|
|
|
|
init(message: String) {
|
|
super.init(frame: .zero)
|
|
setupUI()
|
|
update(message: message)
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
// MARK: - Private Methods
|
|
|
|
/// 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)
|
|
])
|
|
}
|
|
|
|
// MARK: - Public Methods
|
|
|
|
/// Updates the Current Message
|
|
/// - Parameter message: message to show
|
|
public func update(message: String) {
|
|
messageLabel.text = message
|
|
}
|
|
|
|
}
|