Files
suixinkan_uikit/suixinkan/UI/Home/Views/HomeStoreCardView.swift

61 lines
1.8 KiB
Swift

//
// HomeStoreCardView.swift
// suixinkan
//
import SnapKit
import UIKit
///
final class HomeStoreCardView: UIView {
private let nameLabel = UILabel()
private let addressLabel = UILabel()
private let statusLabel = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
layer.cornerRadius = 10
nameLabel.font = .systemFont(ofSize: 16, weight: .semibold)
nameLabel.textColor = AppColor.text333
addressLabel.font = .systemFont(ofSize: 13)
addressLabel.textColor = AppColor.text666
addressLabel.numberOfLines = 2
statusLabel.font = .systemFont(ofSize: 12, weight: .medium)
statusLabel.textColor = AppColor.primary
addSubview(nameLabel)
addSubview(addressLabel)
addSubview(statusLabel)
nameLabel.snp.makeConstraints { make in
make.top.leading.equalToSuperview().offset(15)
make.trailing.lessThanOrEqualTo(statusLabel.snp.leading).offset(-8)
}
statusLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(15)
make.trailing.equalToSuperview().offset(-15)
}
addressLabel.snp.makeConstraints { make in
make.top.equalTo(nameLabel.snp.bottom).offset(8)
make.leading.trailing.equalToSuperview().inset(15)
make.bottom.equalToSuperview().offset(-15)
}
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func apply(store: StoreItem) {
nameLabel.text = store.name
addressLabel.text = store.address
statusLabel.text = store.statusText.isEmpty ? "营业中" : store.statusText
}
}