IGListKit/Examples/Examples-iOS/IGListKitExamples/Views/MonthTitleCell.swift

47 lines
1.1 KiB
Swift
Raw Normal View History

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import IGListKit
import UIKit
final class MonthTitleCell: UICollectionViewCell {
fileprivate lazy var label: UILabel = {
let view = UILabel()
view.backgroundColor = .clear
view.textAlignment = .center
view.textColor = UIColor(white: 0.7, alpha: 1)
view.font = .boldSystemFont(ofSize: 13)
self.contentView.addSubview(view)
return view
}()
var text: String? {
get {
return label.text
}
set {
label.text = newValue
}
}
override func layoutSubviews() {
super.layoutSubviews()
label.frame = contentView.bounds
}
}
extension MonthTitleCell: ListBindable {
func bindViewModel(_ viewModel: Any) {
guard let viewModel = viewModel as? MonthTitleViewModel else { return }
label.text = viewModel.name.uppercased()
}
}