import SnapKit import UIKit /// 准备页业务失败卡片,完整换行展示原因,不展示成功回执或接口 JSON。 @MainActor final class DroneDockTaskCreationResultCell: UICollectionViewCell { private let titleLabel = DroneDockStyle.label(size: 16, weight: .semibold) private let detailLabel = DroneDockStyle.label(size: 14, color: DroneDockStyle.secondary) override init(frame: CGRect) { super.init(frame: frame) contentView.backgroundColor = DroneDockStyle.background contentView.layer.cornerRadius = 10 titleLabel.numberOfLines = 0 detailLabel.numberOfLines = 0 titleLabel.textColor = DroneDockStyle.warning [titleLabel, detailLabel].forEach(contentView.addSubview) titleLabel.snp.makeConstraints { make in make.top.leading.trailing.equalToSuperview().inset(12) } detailLabel.snp.makeConstraints { make in make.top.equalTo(titleLabel.snp.bottom).offset(8) make.leading.trailing.equalTo(titleLabel) make.bottom.equalToSuperview().inset(12) } } @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } /// 只接收面向用户的错误模型,成功 data 不进入视图层。 func apply(failure: DroneDockPreparationFailure, identifier: String) { titleLabel.text = failure.title detailLabel.text = failure.message detailLabel.accessibilityIdentifier = identifier } }