实现权限驱动的首页 Tab 并对齐 Android
This commit is contained in:
60
suixinkan/UI/Home/Views/HomeStoreCardView.swift
Normal file
60
suixinkan/UI/Home/Views/HomeStoreCardView.swift
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user