437 lines
23 KiB
Swift
437 lines
23 KiB
Swift
import SnapKit
|
|
import UIKit
|
|
|
|
/// 核对页与确认记录共用的整单抬头,不把拍摄履约状态混入成片确认。
|
|
@MainActor
|
|
final class DroneDeliveryReviewOrderCell: UICollectionViewCell {
|
|
private let nameLabel = DroneDockStyle.label(size: 18, weight: .semibold)
|
|
private let numberLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
|
private let badgeLabel = DroneDockStatusLabel()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
badgeLabel.apply(title: "整单确认", tone: .blue)
|
|
let row = UIStackView(arrangedSubviews: [nameLabel, UIView(), badgeLabel])
|
|
row.alignment = .center
|
|
row.spacing = 10
|
|
let stack = UIStackView(arrangedSubviews: [row, numberLabel])
|
|
stack.axis = .vertical
|
|
stack.spacing = 7
|
|
contentView.addSubview(stack)
|
|
stack.snp.makeConstraints { make in make.leading.trailing.equalToSuperview(); make.top.bottom.equalToSuperview().inset(18) }
|
|
let divider = UIView()
|
|
divider.backgroundColor = DroneDockStyle.border
|
|
contentView.addSubview(divider)
|
|
divider.snp.makeConstraints { make in make.leading.trailing.bottom.equalToSuperview(); make.height.equalTo(1) }
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 展示订单身份,整单确认不按入口点位缩小清单。
|
|
func apply(customer: String, orderNumber: String) {
|
|
nameLabel.text = customer
|
|
numberLabel.text = orderNumber
|
|
accessibilityIdentifier = "drone.delivery.review.order"
|
|
}
|
|
}
|
|
|
|
/// 核对提示、清单标题和演示说明共用的文字单元。
|
|
@MainActor
|
|
final class DroneDeliveryReviewTextCell: UICollectionViewCell {
|
|
private let titleLabel = DroneDockStyle.label(size: 16, weight: .semibold)
|
|
private let detailLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
|
private let iconView = UIImageView()
|
|
private let row = UIStackView()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
titleLabel.numberOfLines = 0
|
|
detailLabel.numberOfLines = 0
|
|
iconView.tintColor = DroneDockStyle.primary
|
|
iconView.contentMode = .scaleAspectFit
|
|
iconView.backgroundColor = DroneDockStyle.primary.withAlphaComponent(0.06)
|
|
iconView.layer.cornerRadius = 10
|
|
iconView.snp.makeConstraints { make in make.size.equalTo(42).priority(999) }
|
|
let texts = UIStackView(arrangedSubviews: [titleLabel, detailLabel])
|
|
texts.axis = .vertical
|
|
texts.spacing = 5
|
|
row.addArrangedSubview(iconView)
|
|
row.addArrangedSubview(texts)
|
|
row.alignment = .center
|
|
row.spacing = 12
|
|
contentView.addSubview(row)
|
|
row.snp.makeConstraints { make in make.leading.trailing.equalToSuperview(); make.top.bottom.equalToSuperview().inset(14) }
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 应用语义明确的标题和说明,可选图标仅用于核对引导。
|
|
func apply(title: String?, detail: String?, symbol: String? = nil) {
|
|
titleLabel.text = title
|
|
titleLabel.isHidden = title == nil
|
|
detailLabel.text = detail
|
|
detailLabel.isHidden = detail == nil
|
|
iconView.isHidden = symbol == nil
|
|
iconView.image = symbol.flatMap { UIImage(systemName: $0, withConfiguration: UIImage.SymbolConfiguration(pointSize: 23)) }
|
|
}
|
|
}
|
|
|
|
/// 整单已交付作品与覆盖点位数量,统计范围由 ViewModel 提供。
|
|
@MainActor
|
|
final class DroneDeliveryReviewStatisticsCell: UICollectionViewCell {
|
|
private let countLabel = UILabel()
|
|
private let pointLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
contentView.backgroundColor = DroneDockStyle.primary.withAlphaComponent(0.055)
|
|
contentView.layer.cornerRadius = 11
|
|
countLabel.numberOfLines = 0
|
|
pointLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
let row = UIStackView(arrangedSubviews: [countLabel, UIView(), pointLabel])
|
|
row.alignment = .center
|
|
row.spacing = 8
|
|
contentView.addSubview(row)
|
|
row.snp.makeConstraints { make in make.edges.equalToSuperview().inset(15) }
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 显示整单所有上传批次的作品数量,不以本次上传数代替。
|
|
func apply(workCount: Int, pointCount: Int) {
|
|
let text = NSMutableAttributedString(string: "本订单已交付 ", attributes: [.font: UIFont.systemFont(ofSize: 12), .foregroundColor: DroneDockStyle.secondary])
|
|
text.append(NSAttributedString(string: "\(workCount)", attributes: [.font: UIFont.systemFont(ofSize: 25, weight: .semibold), .foregroundColor: DroneDockStyle.primary]))
|
|
text.append(NSAttributedString(string: " 个成片", attributes: [.font: UIFont.systemFont(ofSize: 12, weight: .medium), .foregroundColor: DroneDockStyle.primary]))
|
|
countLabel.attributedText = text
|
|
pointLabel.text = "覆盖 \(pointCount) 个打卡点"
|
|
accessibilityIdentifier = "drone.delivery.review.statistics"
|
|
accessibilityLabel = "本订单已交付\(workCount)个成片,覆盖\(pointCount)个打卡点"
|
|
}
|
|
}
|
|
|
|
/// 单个打卡点的成片分组标题,核对页和冻结记录复用同一布局。
|
|
@MainActor
|
|
final class DroneDeliveryReviewPointHeader: UICollectionReusableView {
|
|
private let titleLabel = DroneDockStyle.label(size: 14, weight: .semibold)
|
|
private let countLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
let row = UIStackView(arrangedSubviews: [titleLabel, UIView(), countLabel])
|
|
row.alignment = .center
|
|
row.spacing = 8
|
|
addSubview(row)
|
|
row.snp.makeConstraints { make in make.leading.trailing.equalToSuperview(); make.centerY.equalToSuperview() }
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 只显示当前分组快照的名称与作品数。
|
|
func apply(pointName: String, workCount: Int) {
|
|
titleLabel.text = pointName
|
|
countLabel.text = "\(workCount) 个视频"
|
|
}
|
|
}
|
|
|
|
/// 两列成片封面,点击仅提出预览请求,不修改核对或游客确认状态。
|
|
@MainActor
|
|
final class DroneDeliveryReviewWorkCell: UICollectionViewCell {
|
|
/// 点击封面或文件名时请求只读预览。
|
|
var onPreviewTap: (() -> Void)?
|
|
private let imageView = UIImageView()
|
|
private let durationLabel = UILabel()
|
|
private let titleLabel = DroneDockStyle.label(size: 13, weight: .medium)
|
|
private let fileLabel = DroneDockStyle.label(size: 10, color: DroneDockStyle.secondary)
|
|
private let previewButton = UIButton(type: .custom)
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
imageView.contentMode = .scaleAspectFill
|
|
imageView.clipsToBounds = true
|
|
imageView.layer.cornerRadius = 7
|
|
imageView.backgroundColor = DroneDockStyle.background
|
|
durationLabel.font = .monospacedDigitSystemFont(ofSize: 10, weight: .medium)
|
|
durationLabel.textColor = .white
|
|
durationLabel.backgroundColor = UIColor.black.withAlphaComponent(0.48)
|
|
durationLabel.layer.cornerRadius = 3
|
|
durationLabel.clipsToBounds = true
|
|
durationLabel.textAlignment = .center
|
|
titleLabel.numberOfLines = 1
|
|
fileLabel.numberOfLines = 1
|
|
fileLabel.lineBreakMode = .byTruncatingMiddle
|
|
[imageView, durationLabel, titleLabel, fileLabel, previewButton].forEach(contentView.addSubview)
|
|
imageView.snp.makeConstraints { make in make.leading.trailing.top.equalToSuperview(); make.height.equalTo(imageView.snp.width).multipliedBy(0.57) }
|
|
durationLabel.snp.makeConstraints { make in make.bottom.trailing.equalTo(imageView).inset(5); make.width.greaterThanOrEqualTo(38); make.height.equalTo(19) }
|
|
titleLabel.snp.makeConstraints { make in make.top.equalTo(imageView.snp.bottom).offset(7); make.leading.trailing.equalToSuperview() }
|
|
fileLabel.snp.makeConstraints { make in make.top.equalTo(titleLabel.snp.bottom).offset(4); make.leading.trailing.equalToSuperview(); make.bottom.lessThanOrEqualToSuperview().inset(2) }
|
|
previewButton.snp.makeConstraints { make in make.edges.equalToSuperview() }
|
|
previewButton.addTarget(self, action: #selector(previewTapped), for: .touchUpInside)
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
override func prepareForReuse() {
|
|
super.prepareForReuse()
|
|
onPreviewTap = nil
|
|
}
|
|
|
|
/// 本地封面与时长始终明确属于演示作品。
|
|
func apply(id: String, title: String, fileName: String, previewAssetName: String, durationText: String) {
|
|
imageView.image = UIImage(named: previewAssetName)
|
|
titleLabel.text = title
|
|
fileLabel.text = fileName
|
|
durationLabel.text = durationText
|
|
previewButton.accessibilityIdentifier = "drone.delivery.review.preview.\(id)"
|
|
previewButton.accessibilityLabel = "预览\(title),本地演示成片"
|
|
}
|
|
|
|
@objc private func previewTapped() { onPreviewTap?() }
|
|
}
|
|
|
|
/// 订单确认码演示面板;图案没有编码任何游客地址,不提供真实扫码服务。
|
|
@MainActor
|
|
final class DroneDeliveryConfirmationCodeCell: UICollectionViewCell {
|
|
private let statusLabel = DroneDockStatusLabel()
|
|
private let titleLabel = DroneDockStyle.label(size: 21, weight: .semibold)
|
|
private let detailLabel = DroneDockStyle.label(size: 13, color: DroneDockStyle.secondary)
|
|
private let codeView = DroneDeliveryDemoCodeView()
|
|
private let countLabel = DroneDockStyle.label(size: 13, weight: .medium)
|
|
private let explanationLabel = DroneDockStyle.label("扫描不等于收货,需游客本人主动确认", size: 11, color: DroneDockStyle.secondary)
|
|
private let demoLabel = DroneDockStyle.label("仅供本机交互演示 · 不连接游客手机", size: 12, weight: .medium, color: DroneDockStyle.primary)
|
|
private let feedbackLabel = DroneDockStyle.label(size: 13, color: DroneDockStyle.warning)
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
contentView.layer.cornerRadius = 15
|
|
contentView.layer.borderWidth = 1
|
|
contentView.layer.borderColor = DroneDockStyle.border.cgColor
|
|
contentView.backgroundColor = DroneDockStyle.primary.withAlphaComponent(0.025)
|
|
[titleLabel, detailLabel, countLabel, explanationLabel, demoLabel, feedbackLabel].forEach { $0.textAlignment = .center; $0.numberOfLines = 0 }
|
|
let stack = UIStackView(arrangedSubviews: [statusLabel, titleLabel, detailLabel, codeView, countLabel, explanationLabel, demoLabel, feedbackLabel])
|
|
stack.axis = .vertical
|
|
stack.alignment = .center
|
|
stack.spacing = 13
|
|
stack.setCustomSpacing(20, after: detailLabel)
|
|
codeView.snp.makeConstraints { make in make.size.equalTo(202) }
|
|
contentView.addSubview(stack)
|
|
stack.snp.makeConstraints { make in make.edges.equalToSuperview().inset(20) }
|
|
[titleLabel, detailLabel, countLabel, explanationLabel, demoLabel, feedbackLabel].forEach { label in
|
|
label.snp.makeConstraints { make in make.width.equalTo(stack) }
|
|
}
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 仅展示当前确认快照数量;刷新状态不代替游客本人主动确认。
|
|
func apply(status: String, tone: DroneDockStatusTone, workCount: Int, pointCount: Int, feedback: String?) {
|
|
statusLabel.apply(title: status, tone: tone)
|
|
titleLabel.text = feedback == nil ? "请游客扫码确认收货" : "游客反馈待处理"
|
|
detailLabel.text = "查看本订单全部成片后,一次确认"
|
|
countLabel.text = "\(workCount) 个成片 · \(pointCount) 个打卡点"
|
|
feedbackLabel.text = feedback
|
|
feedbackLabel.isHidden = feedback == nil
|
|
accessibilityIdentifier = "drone.delivery.confirmation.code"
|
|
}
|
|
}
|
|
|
|
/// 不可扫码的本地演示图案,刻意不生成二维码数据或有效游客链接。
|
|
@MainActor
|
|
private final class DroneDeliveryDemoCodeView: UIView {
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
backgroundColor = .white
|
|
layer.cornerRadius = 12
|
|
layer.borderWidth = 1
|
|
layer.borderColor = DroneDockStyle.border.cgColor
|
|
isAccessibilityElement = true
|
|
accessibilityLabel = "订单确认演示图案,不支持真实扫码"
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
override func draw(_ rect: CGRect) {
|
|
super.draw(rect)
|
|
guard let context = UIGraphicsGetCurrentContext() else { return }
|
|
let gridCount = 25
|
|
let module = min(bounds.width, bounds.height) / 31
|
|
let origin = CGPoint(x: (bounds.width - CGFloat(gridCount) * module) / 2, y: (bounds.height - CGFloat(gridCount) * module) / 2)
|
|
context.setFillColor(UIColor.black.cgColor)
|
|
for row in 0..<gridCount {
|
|
for column in 0..<gridCount {
|
|
let inFinder = (row < 8 && column < 8) || (row < 8 && column > 16) || (row > 16 && column < 8)
|
|
guard !inFinder, (row * 13 + column * 7 + row * column) % 5 < 2 else { continue }
|
|
context.fill(CGRect(x: origin.x + CGFloat(column) * module, y: origin.y + CGFloat(row) * module, width: module, height: module))
|
|
}
|
|
}
|
|
for position in [CGPoint.zero, CGPoint(x: 18, y: 0), CGPoint(x: 0, y: 18)] {
|
|
let outer = CGRect(x: origin.x + position.x * module, y: origin.y + position.y * module, width: 7 * module, height: 7 * module)
|
|
context.setFillColor(UIColor.black.cgColor)
|
|
context.fill(outer)
|
|
context.setFillColor(UIColor.white.cgColor)
|
|
context.fill(outer.insetBy(dx: module, dy: module))
|
|
context.setFillColor(UIColor.black.cgColor)
|
|
context.fill(outer.insetBy(dx: 2 * module, dy: 2 * module))
|
|
}
|
|
let badge = CGRect(x: 10, y: bounds.midY - 24, width: bounds.width - 20, height: 48)
|
|
context.setFillColor(UIColor.white.cgColor)
|
|
context.fill(badge)
|
|
let text = "演示 · 不可扫码" as NSString
|
|
let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 15, weight: .semibold), .foregroundColor: DroneDockStyle.primary]
|
|
let size = text.size(withAttributes: attributes)
|
|
text.draw(at: CGPoint(x: bounds.midX - size.width / 2, y: bounds.midY - size.height / 2), withAttributes: attributes)
|
|
}
|
|
}
|
|
|
|
/// 游客确认回执的固定快照摘要,人员与时间由确认记录提供。
|
|
@MainActor
|
|
final class DroneDeliveryReceiptCell: UICollectionViewCell {
|
|
private let titleLabel = DroneDockStyle.label("游客已确认收货", size: 21, weight: .semibold)
|
|
private let detailLabel = DroneDockStyle.label(size: 13, color: DroneDockStyle.secondary)
|
|
private let metadataStack = UIStackView()
|
|
private let statementLabel = DroneDockStyle.label("我已查看本订单交付清单,确认收到上述全部成片。", size: 12, color: DroneDockStyle.secondary)
|
|
|
|
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 { make in make.size.equalTo(38) }
|
|
titleLabel.textAlignment = .center
|
|
detailLabel.textAlignment = .center
|
|
detailLabel.numberOfLines = 0
|
|
metadataStack.axis = .vertical
|
|
metadataStack.spacing = 14
|
|
let panel = UIView()
|
|
panel.backgroundColor = DroneDockStyle.background
|
|
panel.layer.cornerRadius = 10
|
|
panel.addSubview(metadataStack)
|
|
metadataStack.snp.makeConstraints { make in make.edges.equalToSuperview().inset(14) }
|
|
statementLabel.numberOfLines = 0
|
|
let statementTitle = DroneDockStyle.label("游客确认内容", size: 13, weight: .semibold)
|
|
let stack = UIStackView(arrangedSubviews: [icon, titleLabel, detailLabel, panel, statementTitle, statementLabel])
|
|
stack.axis = .vertical
|
|
stack.alignment = .center
|
|
stack.spacing = 14
|
|
contentView.addSubview(stack)
|
|
stack.snp.makeConstraints { make in make.leading.trailing.equalToSuperview(); make.top.bottom.equalToSuperview().inset(20) }
|
|
[panel, statementTitle, statementLabel].forEach { view in view.snp.makeConstraints { make in make.width.equalTo(stack) } }
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 这些值来自确认时的记录,不读取当前追加后的作品数量或人员。
|
|
func apply(workCount: Int, pointCount: Int, visitor: String, confirmedAt: String, operatorName: String) {
|
|
detailLabel.text = "本订单一次确认,共 \(workCount) 个成片\n本机演示记录 · 并非真实收货凭据"
|
|
metadataStack.arrangedSubviews.forEach { metadataStack.removeArrangedSubview($0); $0.removeFromSuperview() }
|
|
for (label, value) in [("确认人", visitor), ("确认时间", confirmedAt), ("交付工作人员", operatorName), ("确认范围", "\(pointCount) 个打卡点 · \(workCount) 个成片")] {
|
|
let key = DroneDockStyle.label(label, size: 12, color: DroneDockStyle.secondary)
|
|
key.snp.makeConstraints { make in make.width.equalTo(86) }
|
|
let content = DroneDockStyle.label(value, size: 12)
|
|
content.numberOfLines = 0
|
|
content.textAlignment = .right
|
|
let row = UIStackView(arrangedSubviews: [key, content])
|
|
row.alignment = .top
|
|
row.spacing = 10
|
|
metadataStack.addArrangedSubview(row)
|
|
}
|
|
accessibilityIdentifier = "drone.delivery.confirmation.receipt"
|
|
}
|
|
}
|
|
|
|
/// 核对、确认码与确认记录共用的固定底部操作区,所有按钮至少 44 点高。
|
|
@MainActor
|
|
final class DroneDeliveryReviewFooterView: UIView {
|
|
/// 核对勾选变化由 Controller 主动同步到 ViewModel。
|
|
var onAcknowledgementTap: (() -> Void)?
|
|
/// 主操作随页面阶段变化。
|
|
var onPrimaryTap: (() -> Void)?
|
|
/// 次操作用于继续交付、稍后返回或回到当前核对。
|
|
var onSecondaryTap: (() -> Void)?
|
|
private let noteLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
|
|
private let acknowledgementButton = UIButton(type: .system)
|
|
private let primaryButton = UIButton(type: .system)
|
|
private let secondaryButton = UIButton(type: .system)
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
backgroundColor = .white
|
|
let divider = UIView()
|
|
divider.backgroundColor = DroneDockStyle.border
|
|
addSubview(divider)
|
|
divider.snp.makeConstraints { make in make.leading.trailing.top.equalToSuperview(); make.height.equalTo(1) }
|
|
noteLabel.textAlignment = .center
|
|
noteLabel.numberOfLines = 2
|
|
acknowledgementButton.contentHorizontalAlignment = .leading
|
|
acknowledgementButton.tintColor = DroneDockStyle.primary
|
|
acknowledgementButton.addTarget(self, action: #selector(acknowledgementTapped), for: .touchUpInside)
|
|
primaryButton.layer.cornerRadius = 9
|
|
primaryButton.backgroundColor = DroneDockStyle.primary
|
|
primaryButton.setTitleColor(.white, for: .normal)
|
|
primaryButton.setTitleColor(UIColor.white.withAlphaComponent(0.85), for: .disabled)
|
|
primaryButton.titleLabel?.font = .systemFont(ofSize: 15, weight: .semibold)
|
|
primaryButton.titleLabel?.adjustsFontSizeToFitWidth = true
|
|
primaryButton.titleLabel?.minimumScaleFactor = 0.8
|
|
primaryButton.addTarget(self, action: #selector(primaryTapped), for: .touchUpInside)
|
|
secondaryButton.setTitleColor(DroneDockStyle.secondary, for: .normal)
|
|
secondaryButton.titleLabel?.font = .systemFont(ofSize: 13)
|
|
secondaryButton.addTarget(self, action: #selector(secondaryTapped), for: .touchUpInside)
|
|
let stack = UIStackView(arrangedSubviews: [noteLabel, acknowledgementButton, primaryButton, secondaryButton])
|
|
stack.axis = .vertical
|
|
stack.spacing = 5
|
|
addSubview(stack)
|
|
stack.snp.makeConstraints { make in
|
|
make.leading.trailing.equalToSuperview().inset(16)
|
|
make.top.equalToSuperview().offset(9)
|
|
make.bottom.equalTo(safeAreaLayoutGuide).inset(4)
|
|
}
|
|
acknowledgementButton.snp.makeConstraints { make in make.height.equalTo(44).priority(999) }
|
|
primaryButton.snp.makeConstraints { make in make.height.equalTo(48) }
|
|
secondaryButton.snp.makeConstraints { make in make.height.equalTo(44).priority(999) }
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 根据明确页面状态配置操作;未核对时不能展示确认码。
|
|
func apply(acknowledged: Bool?, note: String?, primaryTitle: String, primaryIdentifier: String, primaryEnabled: Bool,
|
|
secondaryTitle: String?, secondaryIdentifier: String) {
|
|
noteLabel.text = note
|
|
noteLabel.isHidden = note == nil
|
|
acknowledgementButton.isHidden = acknowledged == nil
|
|
if let acknowledged {
|
|
var configuration = UIButton.Configuration.plain()
|
|
configuration.title = "我已核对,本订单成片已全部交齐"
|
|
configuration.image = UIImage(systemName: acknowledged ? "checkmark.square.fill" : "square")
|
|
configuration.imagePadding = 7
|
|
configuration.contentInsets = .zero
|
|
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { attributes in
|
|
var attributes = attributes
|
|
attributes.font = .systemFont(ofSize: 12)
|
|
return attributes
|
|
}
|
|
acknowledgementButton.configuration = configuration
|
|
acknowledgementButton.accessibilityTraits = acknowledged ? [.button, .selected] : .button
|
|
}
|
|
acknowledgementButton.accessibilityIdentifier = "drone.delivery.review.acknowledge"
|
|
primaryButton.setTitle(primaryTitle, for: .normal)
|
|
primaryButton.accessibilityIdentifier = primaryIdentifier
|
|
primaryButton.isEnabled = primaryEnabled
|
|
primaryButton.backgroundColor = primaryEnabled ? DroneDockStyle.primary : DroneDockStyle.primary.withAlphaComponent(0.2)
|
|
secondaryButton.setTitle(secondaryTitle, for: .normal)
|
|
secondaryButton.accessibilityIdentifier = secondaryIdentifier
|
|
secondaryButton.isHidden = secondaryTitle == nil
|
|
}
|
|
|
|
@objc private func acknowledgementTapped() { onAcknowledgementTap?() }
|
|
@objc private func primaryTapped() { onPrimaryTap?() }
|
|
@objc private func secondaryTapped() { onSecondaryTap?() }
|
|
}
|