feat: 完善机巢模拟调试与素材交付交互
增加禁飞期间的设备指令拦截及本地模拟拍摄流程;适配订单素材库和景区空境库,完善素材筛选、预览与下载;订单交付入口改为方式选择弹窗并复用云端上传。补充单元测试、接口记录和模拟器截图。
This commit is contained in:
@@ -1,6 +1,34 @@
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 缩略图上的选择圆圈,显式绘制白色勾选以免透出背景图片。
|
||||
@MainActor
|
||||
enum DroneMaterialSelectionIcon {
|
||||
/// 使用固定配色绘制选择状态,避免按钮重新应用系统 tint。
|
||||
static func image(selected: Bool, tint: UIColor, opacity: CGFloat = 1) -> UIImage {
|
||||
UIGraphicsImageRenderer(size: CGSize(width: 24, height: 24)).image { context in
|
||||
context.cgContext.setAlpha(opacity)
|
||||
let circle = UIBezierPath(ovalIn: CGRect(x: 1, y: 1, width: 22, height: 22))
|
||||
tint.set()
|
||||
if selected {
|
||||
circle.fill()
|
||||
UIColor.white.setStroke()
|
||||
let check = UIBezierPath()
|
||||
check.move(to: CGPoint(x: 6.5, y: 12))
|
||||
check.addLine(to: CGPoint(x: 10.5, y: 16))
|
||||
check.addLine(to: CGPoint(x: 17.5, y: 7.5))
|
||||
check.lineWidth = 2.2
|
||||
check.lineCapStyle = .round
|
||||
check.lineJoinStyle = .round
|
||||
check.stroke()
|
||||
} else {
|
||||
circle.lineWidth = 1.6
|
||||
circle.stroke()
|
||||
}
|
||||
}.withRenderingMode(.alwaysOriginal)
|
||||
}
|
||||
}
|
||||
|
||||
/// 素材库的订单摘要,保留拍摄履约与素材处理相互独立的表达。
|
||||
@MainActor
|
||||
final class DroneMaterialOrderCell: UICollectionViewCell {
|
||||
@@ -154,6 +182,15 @@ final class DroneMaterialSelectionCell: UICollectionViewCell {
|
||||
config.imagePadding = 6
|
||||
config.contentInsets = .zero
|
||||
config.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 15)
|
||||
let foreground = enabled ? DroneDockStyle.primary : UIColor(hex: 0xC2C9D4)
|
||||
config.baseForegroundColor = foreground
|
||||
config.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||
var attributes = incoming
|
||||
attributes.font = .systemFont(ofSize: 12)
|
||||
attributes.foregroundColor = foreground
|
||||
return attributes
|
||||
}
|
||||
config.imageColorTransformer = UIConfigurationColorTransformer { _ in foreground }
|
||||
selectAllButton.configuration = config
|
||||
selectAllButton.isEnabled = enabled
|
||||
selectAllButton.accessibilityLabel = "全选可下载"
|
||||
@@ -181,6 +218,13 @@ final class DroneMaterialRecordHeaderView: UICollectionReusableView {
|
||||
config.imagePadding = 5
|
||||
config.contentInsets = .zero
|
||||
config.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 13)
|
||||
config.baseForegroundColor = DroneDockStyle.primary
|
||||
config.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||
var attributes = incoming
|
||||
attributes.font = .systemFont(ofSize: 12)
|
||||
attributes.foregroundColor = DroneDockStyle.primary
|
||||
return attributes
|
||||
}
|
||||
deliveryButton.configuration = config
|
||||
deliveryButton.tintColor = DroneDockStyle.primary
|
||||
deliveryButton.addTarget(self, action: #selector(deliveryTapped), for: .touchUpInside)
|
||||
@@ -193,7 +237,7 @@ final class DroneMaterialRecordHeaderView: UICollectionReusableView {
|
||||
deliveryButton.snp.makeConstraints { make in
|
||||
make.trailing.equalToSuperview()
|
||||
make.centerY.equalTo(titleLabel)
|
||||
make.height.equalTo(40)
|
||||
make.height.equalTo(44)
|
||||
}
|
||||
detailLabel.snp.makeConstraints { make in
|
||||
make.leading.trailing.equalToSuperview()
|
||||
@@ -229,8 +273,10 @@ final class DroneMaterialCell: UICollectionViewCell {
|
||||
private let selectionButton = UIButton(type: .custom)
|
||||
private let placeholderIcon = UIImageView()
|
||||
private let videoBadge = UILabel()
|
||||
private let nameLabel = DroneDockStyle.label(size: 12, weight: .medium)
|
||||
private let statusLabel = DroneDockStyle.label(size: 11)
|
||||
private let nameLabel = DroneDockStyle.label(size: 13, weight: .medium)
|
||||
private let statusLabel = DroneDockStyle.label(size: 12)
|
||||
private let retryUploadButton = UIButton(type: .system)
|
||||
private let nameRow = UIStackView()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
@@ -252,10 +298,23 @@ final class DroneMaterialCell: UICollectionViewCell {
|
||||
selectionButton.imageView?.contentMode = .scaleAspectFit
|
||||
selectionButton.addTarget(self, action: #selector(selectionTapped), for: .touchUpInside)
|
||||
previewButton.addTarget(self, action: #selector(previewTapped), for: .touchUpInside)
|
||||
[thumbnail, placeholderIcon, previewButton, videoBadge, selectionButton, nameLabel, statusLabel].forEach(contentView.addSubview)
|
||||
retryUploadButton.setTitle("重试上传", for: .normal)
|
||||
retryUploadButton.titleLabel?.font = .systemFont(ofSize: 11)
|
||||
retryUploadButton.isEnabled = false
|
||||
retryUploadButton.setTitleColor(DroneDockStyle.primary.withAlphaComponent(0.55), for: .disabled)
|
||||
retryUploadButton.accessibilityHint = "当前演示不执行上传重试"
|
||||
nameRow.axis = .horizontal
|
||||
nameRow.alignment = .center
|
||||
nameRow.spacing = 6
|
||||
nameRow.addArrangedSubview(nameLabel)
|
||||
nameRow.addArrangedSubview(retryUploadButton)
|
||||
retryUploadButton.setContentHuggingPriority(.required, for: .horizontal)
|
||||
retryUploadButton.setContentCompressionResistancePriority(UILayoutPriority(999), for: .horizontal)
|
||||
retryUploadButton.snp.makeConstraints { make in make.height.equalTo(16) }
|
||||
[thumbnail, placeholderIcon, previewButton, videoBadge, selectionButton, nameRow, statusLabel].forEach(contentView.addSubview)
|
||||
thumbnail.snp.makeConstraints { make in
|
||||
make.leading.trailing.top.equalToSuperview()
|
||||
make.height.equalTo(thumbnail.snp.width).multipliedBy(0.57)
|
||||
make.height.equalTo(thumbnail.snp.width).multipliedBy(9.0 / 16.0)
|
||||
}
|
||||
previewButton.snp.makeConstraints { make in make.edges.equalTo(thumbnail) }
|
||||
placeholderIcon.snp.makeConstraints { make in make.center.equalTo(thumbnail); make.size.equalTo(29) }
|
||||
@@ -269,13 +328,13 @@ final class DroneMaterialCell: UICollectionViewCell {
|
||||
make.top.trailing.equalTo(thumbnail)
|
||||
make.size.equalTo(44)
|
||||
}
|
||||
nameLabel.snp.makeConstraints { make in
|
||||
nameRow.snp.makeConstraints { make in
|
||||
make.leading.trailing.equalToSuperview()
|
||||
make.top.equalTo(thumbnail.snp.bottom).offset(7)
|
||||
}
|
||||
statusLabel.snp.makeConstraints { make in
|
||||
make.leading.trailing.equalToSuperview()
|
||||
make.top.equalTo(nameLabel.snp.bottom).offset(4)
|
||||
make.top.equalTo(nameRow.snp.bottom).offset(4)
|
||||
make.bottom.lessThanOrEqualToSuperview().inset(5)
|
||||
}
|
||||
}
|
||||
@@ -291,7 +350,10 @@ final class DroneMaterialCell: UICollectionViewCell {
|
||||
thumbnail.image = material.canPreview ? UIImage(named: material.previewAssetName) : nil
|
||||
thumbnail.layer.borderColor = selected ? DroneDockStyle.primary.cgColor : UIColor.clear.cgColor
|
||||
placeholderIcon.isHidden = material.canPreview
|
||||
placeholderIcon.image = UIImage(systemName: material.uploadState == .failed ? "exclamationmark.icloud" : "play.fill")
|
||||
placeholderIcon.image = UIImage(systemName: material.uploadState == .failed ? "xmark.circle" : "play.fill")
|
||||
placeholderIcon.tintColor = material.uploadState == .failed ? DroneDockStyle.color(for: .red) : UIColor(hex: 0x9CA6B6)
|
||||
retryUploadButton.isHidden = material.uploadState != .failed
|
||||
retryUploadButton.accessibilityIdentifier = "drone.materials.retryUpload.\(material.id)"
|
||||
videoBadge.isHidden = material.kind != .video || !material.canPreview
|
||||
previewButton.isEnabled = material.canPreview
|
||||
previewButton.accessibilityIdentifier = "drone.materials.preview.\(material.id)"
|
||||
@@ -301,11 +363,9 @@ final class DroneMaterialCell: UICollectionViewCell {
|
||||
selectionButton.accessibilityIdentifier = "drone.materials.select.\(material.id)"
|
||||
selectionButton.accessibilityLabel = completed ? "\(material.title),演示完成,未写入相册" : "选择\(material.title)"
|
||||
selectionButton.accessibilityTraits = selected || completed ? [.button, .selected] : .button
|
||||
let symbol = UIImage(systemName: selected || completed ? "checkmark.circle.fill" : "circle",
|
||||
withConfiguration: UIImage.SymbolConfiguration(pointSize: 22, weight: .regular))
|
||||
let tint = completed ? DroneDockStyle.success : selected ? DroneDockStyle.primary : UIColor.white
|
||||
selectionButton.setImage(symbol?.withTintColor(tint, renderingMode: .alwaysOriginal), for: .normal)
|
||||
selectionButton.setImage(symbol?.withTintColor(tint.withAlphaComponent(0.6), renderingMode: .alwaysOriginal), for: .disabled)
|
||||
selectionButton.setImage(DroneMaterialSelectionIcon.image(selected: selected || completed, tint: tint), for: .normal)
|
||||
selectionButton.setImage(DroneMaterialSelectionIcon.image(selected: selected || completed, tint: tint, opacity: 0.6), for: .disabled)
|
||||
selectionButton.imageView?.layer.shadowColor = UIColor.black.cgColor
|
||||
selectionButton.imageView?.layer.shadowOpacity = 0.22
|
||||
selectionButton.imageView?.layer.shadowRadius = 2
|
||||
@@ -375,6 +435,9 @@ final class DroneMaterialsFooterView: UIView {
|
||||
/// 返回选择状态或请求预留的交付入口。
|
||||
var onSecondaryTap: (() -> Void)?
|
||||
private let titleLabel = DroneDockStyle.label(size: 13, weight: .medium)
|
||||
private let trailingLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
|
||||
private let resultIcon = UIImageView()
|
||||
private let titleRow = UIStackView()
|
||||
private let detailLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
|
||||
private let progressView = UIProgressView(progressViewStyle: .default)
|
||||
private let primaryButton = UIButton(type: .system)
|
||||
@@ -389,7 +452,19 @@ final class DroneMaterialsFooterView: UIView {
|
||||
stack.axis = .vertical
|
||||
stack.spacing = 10
|
||||
titleLabel.numberOfLines = 2
|
||||
titleLabel.accessibilityIdentifier = "drone.materials.footer.title"
|
||||
trailingLabel.accessibilityIdentifier = "drone.materials.footer.trailing"
|
||||
trailingLabel.textAlignment = .right
|
||||
trailingLabel.setContentHuggingPriority(.required, for: .horizontal)
|
||||
trailingLabel.setContentCompressionResistancePriority(UILayoutPriority(999), for: .horizontal)
|
||||
resultIcon.contentMode = .scaleAspectFit
|
||||
resultIcon.accessibilityIdentifier = "drone.materials.footer.resultIcon"
|
||||
titleRow.axis = .horizontal
|
||||
titleRow.alignment = .center
|
||||
titleRow.spacing = 8
|
||||
[resultIcon, titleLabel, trailingLabel].forEach(titleRow.addArrangedSubview)
|
||||
detailLabel.numberOfLines = 2
|
||||
detailLabel.accessibilityIdentifier = "drone.materials.footer.detail"
|
||||
progressView.progressTintColor = DroneDockStyle.primary
|
||||
progressView.trackTintColor = UIColor(hex: 0xE8EDF7)
|
||||
progressView.accessibilityLabel = "本次演示下载完成项数"
|
||||
@@ -403,7 +478,7 @@ final class DroneMaterialsFooterView: UIView {
|
||||
secondaryButton.tintColor = DroneDockStyle.secondary
|
||||
primaryButton.addTarget(self, action: #selector(primaryTapped), for: .touchUpInside)
|
||||
secondaryButton.addTarget(self, action: #selector(secondaryTapped), for: .touchUpInside)
|
||||
[titleLabel, progressView, detailLabel, primaryButton, secondaryButton].forEach(stack.addArrangedSubview)
|
||||
[titleRow, progressView, detailLabel, primaryButton, secondaryButton].forEach(stack.addArrangedSubview)
|
||||
addSubview(divider)
|
||||
addSubview(stack)
|
||||
divider.snp.makeConstraints { make in make.leading.trailing.top.equalToSuperview(); make.height.equalTo(1 / UIScreen.main.scale) }
|
||||
@@ -413,8 +488,9 @@ final class DroneMaterialsFooterView: UIView {
|
||||
make.bottom.equalTo(safeAreaLayoutGuide).inset(10)
|
||||
}
|
||||
primaryButton.snp.makeConstraints { make in make.height.equalTo(44) }
|
||||
secondaryButton.snp.makeConstraints { make in make.height.equalTo(24) }
|
||||
progressView.snp.makeConstraints { make in make.height.equalTo(3) }
|
||||
secondaryButton.snp.makeConstraints { make in make.height.equalTo(44).priority(999) }
|
||||
resultIcon.snp.makeConstraints { make in make.width.height.equalTo(21).priority(999) }
|
||||
progressView.snp.makeConstraints { make in make.height.equalTo(3).priority(999) }
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
@@ -423,9 +499,17 @@ final class DroneMaterialsFooterView: UIView {
|
||||
/// 只接受显示值,按钮语义和下载状态由控制器及 ViewModel 决定。
|
||||
func apply(title: String, detail: String, primaryTitle: String, primarySymbol: String,
|
||||
enabled: Bool, identifier: String, progress: Double?, secondaryTitle: String? = nil,
|
||||
tone: DroneDockStatusTone = .gray) {
|
||||
tone: DroneDockStatusTone = .gray, trailingText: String? = nil,
|
||||
resultSymbol: String? = nil, secondaryOutlined: Bool = false, secondaryEnabled: Bool = true) {
|
||||
titleLabel.text = title
|
||||
titleLabel.textColor = tone == .gray ? DroneDockStyle.text : DroneDockStyle.color(for: tone)
|
||||
titleLabel.textColor = DroneDockStyle.text
|
||||
titleLabel.font = .systemFont(ofSize: 13, weight: resultSymbol == nil ? .regular : .semibold)
|
||||
trailingLabel.text = trailingText
|
||||
trailingLabel.isHidden = trailingText == nil
|
||||
trailingLabel.textColor = progress == nil ? DroneDockStyle.secondary : DroneDockStyle.primary
|
||||
resultIcon.image = resultSymbol.flatMap(UIImage.init(systemName:))
|
||||
resultIcon.isHidden = resultSymbol == nil
|
||||
resultIcon.tintColor = DroneDockStyle.color(for: tone)
|
||||
detailLabel.text = detail
|
||||
detailLabel.isHidden = detail.isEmpty
|
||||
progressView.isHidden = progress == nil
|
||||
@@ -436,13 +520,47 @@ final class DroneMaterialsFooterView: UIView {
|
||||
config.imagePadding = 7
|
||||
config.contentInsets = NSDirectionalEdgeInsets(top: 8, leading: 12, bottom: 8, trailing: 12)
|
||||
config.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 16)
|
||||
let primaryForeground: UIColor = enabled || progress == nil ? .white : DroneDockStyle.primary
|
||||
let primaryBackground = enabled ? DroneDockStyle.primary : UIColor(hex: 0xCEDBFC)
|
||||
config.cornerStyle = .fixed
|
||||
config.background.cornerRadius = 7
|
||||
config.background.backgroundColor = primaryBackground
|
||||
config.background.backgroundColorTransformer = UIConfigurationColorTransformer { _ in primaryBackground }
|
||||
config.baseForegroundColor = primaryForeground
|
||||
config.imageColorTransformer = UIConfigurationColorTransformer { _ in primaryForeground }
|
||||
config.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||
var attributes = incoming
|
||||
attributes.font = .systemFont(ofSize: 15, weight: .medium)
|
||||
attributes.foregroundColor = primaryForeground
|
||||
return attributes
|
||||
}
|
||||
primaryButton.configuration = config
|
||||
primaryButton.isEnabled = enabled
|
||||
primaryButton.backgroundColor = enabled ? DroneDockStyle.primary : UIColor(hex: 0xCEDBFC)
|
||||
primaryButton.backgroundColor = .clear
|
||||
primaryButton.accessibilityIdentifier = identifier
|
||||
secondaryButton.setTitle(secondaryTitle, for: .normal)
|
||||
var secondary = UIButton.Configuration.plain()
|
||||
secondary.title = secondaryTitle
|
||||
secondary.image = secondaryOutlined ? UIImage(systemName: "play.rectangle") : nil
|
||||
secondary.imagePadding = 6
|
||||
secondary.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 14)
|
||||
let secondaryForeground = secondaryOutlined ? DroneDockStyle.primary : DroneDockStyle.secondary
|
||||
secondary.cornerStyle = .fixed
|
||||
secondary.background.cornerRadius = 7
|
||||
secondary.baseForegroundColor = secondaryForeground
|
||||
secondary.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
||||
var attributes = incoming
|
||||
attributes.font = .systemFont(ofSize: 12)
|
||||
attributes.foregroundColor = secondaryForeground
|
||||
return attributes
|
||||
}
|
||||
secondaryButton.configuration = secondary
|
||||
secondaryButton.tintColor = secondaryOutlined ? DroneDockStyle.primary : DroneDockStyle.secondary
|
||||
secondaryButton.layer.cornerRadius = 7
|
||||
secondaryButton.layer.borderWidth = secondaryOutlined ? 1 : 0
|
||||
secondaryButton.layer.borderColor = DroneDockStyle.primary.cgColor
|
||||
secondaryButton.isHidden = secondaryTitle == nil
|
||||
secondaryButton.accessibilityIdentifier = "drone.materials.continueSelecting"
|
||||
secondaryButton.isEnabled = secondaryEnabled
|
||||
secondaryButton.accessibilityIdentifier = secondaryOutlined ? "drone.materials.completedDelivery" : "drone.materials.continueSelecting"
|
||||
}
|
||||
|
||||
@objc private func primaryTapped() { onPrimaryTap?() }
|
||||
|
||||
Reference in New Issue
Block a user