Revision control

Copy as Markdown

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import UIKit
struct SuggestionCellViewModel {
var title: String
}
class SuggestionCell: UITableViewCell {
static let identifier = "SuggestionIdentifier"
private lazy var titleLabel: UILabel = .build()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
initialViewSetup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func initialViewSetup() {
contentView.addSubview(titleLabel)
NSLayoutConstraint.activate([
titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8),
titleLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -8),
titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 8)
])
}
func configureCell(viewModel: SuggestionCellViewModel) {
titleLabel.text = viewModel.title
}
override func prepareForReuse() {
super.prepareForReuse()
titleLabel.text = nil
}
}