58 lines
2.5 KiB
Swift
58 lines
2.5 KiB
Swift
import SnapKit
|
|
import UIKit
|
|
|
|
/// 使用服务端已确认状态展示交付结果,不推断确认人、工作人员或历史成片范围。
|
|
@MainActor
|
|
final class DroneDockConfirmationReceiptCell: UICollectionViewCell {
|
|
private let timeLabel = DroneDockStyle.label(size: 12)
|
|
|
|
/// 完成态沿用网页的成功标识、居中标题与浅灰确认信息卡。
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
let icon = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
|
|
icon.tintColor = DroneDockStyle.success
|
|
icon.contentMode = .scaleAspectFit
|
|
icon.snp.makeConstraints { $0.size.equalTo(38) }
|
|
let title = DroneDockStyle.label("游客已确认收货", size: 22, weight: .semibold)
|
|
let detail = DroneDockStyle.label("本订单交付已完成", size: 13, color: DroneDockStyle.secondary)
|
|
for label in [title, detail] {
|
|
label.textAlignment = .center
|
|
label.numberOfLines = 0
|
|
}
|
|
|
|
let panel = UIView()
|
|
panel.backgroundColor = UIColor(hex: 0xF5F8FC)
|
|
panel.layer.cornerRadius = 12
|
|
let keyLabel = DroneDockStyle.label("确认时间", size: 12, color: DroneDockStyle.secondary)
|
|
keyLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
timeLabel.textAlignment = .right
|
|
timeLabel.numberOfLines = 0
|
|
let row = UIStackView(arrangedSubviews: [keyLabel, timeLabel])
|
|
row.alignment = .top
|
|
row.spacing = 16
|
|
panel.addSubview(row)
|
|
row.snp.makeConstraints { $0.edges.equalToSuperview().inset(14) }
|
|
|
|
let stack = UIStackView(arrangedSubviews: [icon, title, detail, panel])
|
|
stack.axis = .vertical
|
|
stack.alignment = .center
|
|
stack.spacing = 14
|
|
contentView.addSubview(stack)
|
|
stack.snp.makeConstraints {
|
|
$0.leading.trailing.equalToSuperview()
|
|
$0.top.equalToSuperview().offset(8)
|
|
$0.bottom.equalToSuperview().inset(24)
|
|
}
|
|
for view in [title, detail, panel] { view.snp.makeConstraints { $0.width.equalTo(stack) } }
|
|
accessibilityIdentifier = "drone.confirmation.receipt"
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 只展示订单实际返回的确认时间;缺失时保留明确空值。
|
|
func apply(confirmedAt: String?) {
|
|
timeLabel.text = DroneDockHomeMetric.usableText(confirmedAt) ?? "—"
|
|
}
|
|
}
|