feat(drone-dock): 接入游客确认交付并对齐网页样式

This commit is contained in:
2026-10-30 16:19:40 +08:00
parent f99a175f99
commit fad2ed8a50
23 changed files with 2437 additions and 89 deletions
@@ -1,3 +1,4 @@
import Kingfisher
import SnapKit
import UIKit
@@ -49,7 +50,7 @@ final class DroneDeliveryReviewTextCell: UICollectionViewCell {
titleLabel.numberOfLines = 0
detailLabel.numberOfLines = 0
iconView.tintColor = DroneDockStyle.primary
iconView.contentMode = .scaleAspectFit
iconView.contentMode = .center
iconView.backgroundColor = DroneDockStyle.primary.withAlphaComponent(0.06)
iconView.layer.cornerRadius = 10
iconView.snp.makeConstraints { make in make.size.equalTo(42).priority(999) }
@@ -101,17 +102,73 @@ final class DroneDeliveryReviewStatisticsCell: UICollectionViewCell {
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])
func apply(workCount: Int, pointCount: Int, label: String = "本订单已交付") {
let text = NSMutableAttributedString(string: "\(label) ", 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)个打卡点"
accessibilityLabel = "\(label)\(workCount)个成片,覆盖\(pointCount)个打卡点"
}
}
/// 横排交付清单标题,也可作为确认码下方整单清单的展开入口。
@MainActor
final class DroneDeliveryReviewManifestHeaderCell: UICollectionViewCell {
/// 用户点击整行后由页面切换清单展开状态。
var onToggle: (() -> Void)?
private let titleLabel = DroneDockStyle.label(size: 16, weight: .semibold)
private let detailLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
private let chevron = UIImageView()
private let toggleButton = UIButton(type: .custom)
override init(frame: CGRect) {
super.init(frame: frame)
titleLabel.numberOfLines = 0
detailLabel.textAlignment = .right
detailLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
chevron.contentMode = .scaleAspectFit
chevron.tintColor = DroneDockStyle.secondary
chevron.snp.makeConstraints { $0.size.equalTo(12) }
let row = UIStackView(arrangedSubviews: [chevron, titleLabel, UIView(), detailLabel])
row.alignment = .center
row.spacing = 8
contentView.addSubview(row)
row.snp.makeConstraints {
$0.leading.trailing.equalToSuperview()
$0.top.equalToSuperview().offset(16)
$0.bottom.equalToSuperview().inset(8)
}
contentView.addSubview(toggleButton)
toggleButton.snp.makeConstraints { $0.edges.equalToSuperview() }
toggleButton.addTarget(self, action: #selector(toggleTapped), for: .touchUpInside)
toggleButton.accessibilityIdentifier = "drone.confirmation.manifest.toggle"
}
@available(*, unavailable)
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
override func prepareForReuse() { super.prepareForReuse(); onToggle = nil }
/// expanded 为 nil 时展示静态标题,否则按指定状态展示可折叠的清单入口。
func apply(title: String, detail: String?, expanded: Bool? = nil) {
titleLabel.text = title
titleLabel.font = .systemFont(ofSize: expanded == nil ? 16 : 12, weight: expanded == nil ? .semibold : .regular)
titleLabel.textColor = expanded == nil ? DroneDockStyle.text : DroneDockStyle.secondary
detailLabel.text = detail
detailLabel.isHidden = detail?.isEmpty != false
chevron.isHidden = expanded == nil
chevron.image = UIImage(systemName: expanded == true ? "chevron.down" : "chevron.right")
toggleButton.isHidden = expanded == nil
toggleButton.accessibilityLabel = title
toggleButton.accessibilityValue = expanded == true ? "已展开" : "已收起"
toggleButton.accessibilityHint = expanded == true ? "收起成片清单" : "展开成片清单"
}
@objc private func toggleTapped() { onToggle?() }
}
/// 单个打卡点的成片分组标题,核对页和冻结记录复用同一布局。
@MainActor
final class DroneDeliveryReviewPointHeader: UICollectionReusableView {
@@ -143,17 +200,27 @@ final class DroneDeliveryReviewWorkCell: UICollectionViewCell {
/// 点击封面或文件名时请求只读预览。
var onPreviewTap: (() -> Void)?
private let imageView = UIImageView()
private let placeholderView = UIImageView(image: UIImage(systemName: "film"))
private let playView = UIImageView(image: UIImage(systemName: "play.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 10)))
private let durationLabel = UILabel()
private let titleLabel = DroneDockStyle.label(size: 13, weight: .medium)
private let titleLabel = DroneDockStyle.label(size: 13, weight: .semibold)
private let fileLabel = DroneDockStyle.label(size: 10, color: DroneDockStyle.secondary)
private let previewButton = UIButton(type: .custom)
private var imageGeneration = 0
override init(frame: CGRect) {
super.init(frame: frame)
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 7
imageView.layer.cornerRadius = 8
imageView.backgroundColor = DroneDockStyle.background
placeholderView.tintColor = DroneDockStyle.secondary
placeholderView.contentMode = .scaleAspectFit
playView.tintColor = .white
playView.contentMode = .center
playView.backgroundColor = UIColor(red: 16 / 255, green: 34 / 255, blue: 63 / 255, alpha: 0.4)
playView.layer.cornerRadius = 13
playView.clipsToBounds = true
durationLabel.font = .monospacedDigitSystemFont(ofSize: 10, weight: .medium)
durationLabel.textColor = .white
durationLabel.backgroundColor = UIColor.black.withAlphaComponent(0.48)
@@ -163,8 +230,10 @@ final class DroneDeliveryReviewWorkCell: UICollectionViewCell {
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) }
[imageView, placeholderView, playView, durationLabel, titleLabel, fileLabel, previewButton].forEach(contentView.addSubview)
imageView.snp.makeConstraints { make in make.leading.trailing.top.equalToSuperview(); make.height.equalTo(imageView.snp.width).multipliedBy(9.0 / 16.0) }
placeholderView.snp.makeConstraints { make in make.center.equalTo(imageView); make.size.equalTo(28) }
playView.snp.makeConstraints { make in make.center.equalTo(imageView); make.size.equalTo(26) }
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) }
@@ -178,18 +247,58 @@ final class DroneDeliveryReviewWorkCell: UICollectionViewCell {
override func prepareForReuse() {
super.prepareForReuse()
onPreviewTap = nil
imageGeneration += 1
imageView.kf.cancelDownloadTask()
imageView.image = nil
placeholderView.isHidden = false
playView.isHidden = true
durationLabel.text = nil
durationLabel.isHidden = true
}
/// 本地封面与时长始终明确属于演示作品。
func apply(id: String, title: String, fileName: String, previewAssetName: String, durationText: String) {
imageGeneration += 1
imageView.kf.cancelDownloadTask()
imageView.image = UIImage(named: previewAssetName)
placeholderView.isHidden = imageView.image != nil
playView.isHidden = imageView.image == nil
titleLabel.text = title
fileLabel.text = fileName
durationLabel.text = durationText
durationLabel.isHidden = false
previewButton.accessibilityIdentifier = "drone.delivery.review.preview.\(id)"
previewButton.accessibilityLabel = "预览\(title),本地演示成片"
}
/// 正式成片使用接口封面和文件名;接口未提供时长时不显示演示时长。
func apply(film: DroneDockMaterialFilm, taskID: Int, title: String, localImage: UIImage?, allowsRemoteImage: Bool) {
imageGeneration += 1
let generation = imageGeneration
imageView.kf.cancelDownloadTask()
imageView.image = localImage
placeholderView.isHidden = localImage != nil
playView.isHidden = localImage == nil
titleLabel.text = title
fileLabel.text = DroneDockHomeMetric.usableText(film.fileName) ?? "文件名未提供"
durationLabel.text = nil
durationLabel.isHidden = true
previewButton.accessibilityIdentifier = "drone.confirmation.preview.\(taskID)"
previewButton.accessibilityLabel = "预览\(title),\(fileLabel.text ?? "")"
guard allowsRemoteImage, localImage == nil,
let value = DroneDockHomeMetric.usableText(film.coverURL),
let url = URL(string: value), ["http", "https"].contains(url.scheme?.lowercased() ?? ""),
let host = url.host, !host.isEmpty else { return }
imageView.kf.setImage(with: url) { [weak self] result in
Task { @MainActor [weak self] in
guard let self, self.imageGeneration == generation else { return }
let loaded = (try? result.get()) != nil
self.placeholderView.isHidden = loaded
self.playView.isHidden = !loaded
}
}
}
@objc private func previewTapped() { onPreviewTap?() }
}
@@ -402,14 +511,17 @@ final class DroneDeliveryReviewFooterView: UIView {
/// 根据明确页面状态配置操作;未核对时不能展示确认码。
func apply(acknowledged: Bool?, note: String?, primaryTitle: String, primaryIdentifier: String, primaryEnabled: Bool,
secondaryTitle: String?, secondaryIdentifier: String) {
secondaryTitle: String?, secondaryIdentifier: String, primarySymbol: String? = nil) {
noteLabel.text = note
noteLabel.isHidden = note == nil
noteLabel.isHidden = note?.isEmpty != false
acknowledgementButton.isHidden = acknowledged == nil
if let acknowledged {
var configuration = UIButton.Configuration.plain()
configuration.title = "我已核对,本订单成片已全部交齐"
configuration.image = UIImage(systemName: acknowledged ? "checkmark.square.fill" : "square")
configuration.image = UIImage(systemName: acknowledged ? "checkmark.square.fill" : "square",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 16))?
.withTintColor(acknowledged ? DroneDockStyle.primary : UIColor(hex: 0xCBD2DC), renderingMode: .alwaysOriginal)
configuration.baseForegroundColor = DroneDockStyle.secondary
configuration.imagePadding = 7
configuration.contentInsets = .zero
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { attributes in
@@ -421,10 +533,23 @@ final class DroneDeliveryReviewFooterView: UIView {
acknowledgementButton.accessibilityTraits = acknowledged ? [.button, .selected] : .button
}
acknowledgementButton.accessibilityIdentifier = "drone.delivery.review.acknowledge"
primaryButton.setTitle(primaryTitle, for: .normal)
var primaryConfiguration = UIButton.Configuration.plain()
primaryConfiguration.cornerStyle = .fixed
primaryConfiguration.background.cornerRadius = 9
primaryConfiguration.background.backgroundColor = primaryEnabled ? DroneDockStyle.primary : DroneDockStyle.primary.withAlphaComponent(0.2)
primaryConfiguration.title = primaryTitle
primaryConfiguration.image = primarySymbol.flatMap { UIImage(systemName: $0, withConfiguration: UIImage.SymbolConfiguration(pointSize: 14)) }
primaryConfiguration.imagePadding = 7
primaryConfiguration.baseForegroundColor = primaryEnabled ? .white : DroneDockStyle.secondary
primaryConfiguration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { attributes in
var attributes = attributes
attributes.font = .systemFont(ofSize: 15, weight: .semibold)
return attributes
}
primaryButton.configuration = primaryConfiguration
primaryButton.accessibilityIdentifier = primaryIdentifier
primaryButton.isEnabled = primaryEnabled
primaryButton.backgroundColor = primaryEnabled ? DroneDockStyle.primary : DroneDockStyle.primary.withAlphaComponent(0.2)
primaryButton.backgroundColor = .clear
secondaryButton.setTitle(secondaryTitle, for: .normal)
secondaryButton.accessibilityIdentifier = secondaryIdentifier
secondaryButton.isHidden = secondaryTitle == nil