feat(drone-dock): 接入成片云端交付并精简准备页定位展示

This commit is contained in:
2026-10-29 10:24:45 +08:00
parent 88fa1f9b77
commit 4d763ef5d1
29 changed files with 2870 additions and 100 deletions
@@ -92,13 +92,11 @@ final class DronePreparationOrderCell: UICollectionViewCell {
}
}
/// 横向点位小卡,展示点位、距离与拍摄记录,真实数据缺图时使用中性占位。
/// 横向点位小卡,展示点位与拍摄记录,真实数据缺图时使用中性占位。
@MainActor
final class DronePreparationPointCell: UICollectionViewCell {
private let nameLabel = DroneDockStyle.label(size: 13, weight: .semibold)
private let rangeLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
private let countLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
private let locationIcon = UIImageView(image: UIImage(systemName: "mappin.circle.fill"))
private let thumbnail = UIImageView()
override init(frame: CGRect) {
@@ -110,30 +108,19 @@ final class DronePreparationPointCell: UICollectionViewCell {
thumbnail.backgroundColor = DroneDockStyle.background
thumbnail.layer.cornerRadius = 5
thumbnail.clipsToBounds = true
locationIcon.contentMode = .scaleAspectFit
[thumbnail, nameLabel, locationIcon, rangeLabel, countLabel].forEach(contentView.addSubview)
[thumbnail, nameLabel, countLabel].forEach(contentView.addSubview)
thumbnail.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(8)
make.centerY.equalToSuperview()
make.size.equalTo(48)
}
nameLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(10)
make.bottom.equalTo(contentView.snp.centerY).offset(-3)
make.leading.equalTo(thumbnail.snp.trailing).offset(8)
make.trailing.equalToSuperview().inset(6)
}
locationIcon.snp.makeConstraints { make in
make.leading.equalTo(nameLabel)
make.top.equalTo(nameLabel.snp.bottom).offset(5)
make.size.equalTo(10)
}
rangeLabel.snp.makeConstraints { make in
make.leading.equalTo(locationIcon.snp.trailing).offset(3)
make.centerY.equalTo(locationIcon)
make.trailing.equalToSuperview().inset(5)
}
countLabel.snp.makeConstraints { make in
make.top.equalTo(rangeLabel.snp.bottom).offset(4)
make.top.equalTo(contentView.snp.centerY).offset(3)
make.leading.equalTo(nameLabel)
make.trailing.equalToSuperview().inset(5)
}
@@ -143,43 +130,33 @@ final class DronePreparationPointCell: UICollectionViewCell {
@available(*, unavailable)
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
/// 仅映射模型提供的范围和次数,已拍摄的点位仍保持可选择。
/// 展示点位名称与次数,已拍摄的点位仍保持可选择。
func apply(point: DroneShootingPoint, selected: Bool) {
thumbnail.kf.cancelDownloadTask()
contentView.alpha = 1
nameLabel.text = point.name
thumbnail.contentMode = .scaleAspectFill
thumbnail.image = UIImage(named: point.id == "point-jinque" ? "drone_demo_pagoda" : "drone_demo_mountain")
rangeLabel.text = point.range.title
switch point.range {
case .inside: rangeLabel.textColor = DroneDockStyle.success
case .outside: rangeLabel.textColor = DroneDockStyle.secondary
case .unknown: rangeLabel.textColor = DroneDockStyle.warning
}
locationIcon.tintColor = rangeLabel.textColor
countLabel.text = point.successfulCountText
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.07) : .white
contentView.layer.borderColor = (selected ? DroneDockStyle.primary : DroneDockStyle.border).cgColor
accessibilityLabel = "\(point.name),\(point.range.title),\(point.successfulCountText)"
accessibilityLabel = "\(point.name),\(point.successfulCountText)"
accessibilityTraits = selected ? [.button, .selected] : .button
accessibilityIdentifier = "drone.preparation.point.\(point.id)"
}
/// 展示已购点位;当前接口未提供距离与点位已拍次数,保持未知占位。
/// 展示已购点位与可用性;点位已拍次数缺失时保持未知占位。
func apply(spot: DroneDockPurchasedSpot, selected: Bool) {
nameLabel.text = spot.name
thumbnail.kf.cancelDownloadTask()
thumbnail.image = UIImage(systemName: "mappin.and.ellipse")
thumbnail.image = UIImage(systemName: "photo")
thumbnail.contentMode = .center
thumbnail.tintColor = DroneDockStyle.secondary
if let text = spot.coverURL, let url = URL(string: text),
let scheme = url.scheme?.lowercased(), ["https", "http"].contains(scheme), url.host != nil {
thumbnail.contentMode = .scaleAspectFill
thumbnail.kf.setImage(with: url, placeholder: UIImage(systemName: "mappin.and.ellipse"))
thumbnail.kf.setImage(with: url, placeholder: UIImage(systemName: "photo"))
}
rangeLabel.text = "距离待确认"
rangeLabel.textColor = DroneDockStyle.secondary
locationIcon.tintColor = rangeLabel.textColor
if spot.available != true {
countLabel.text = spot.available == false ? "拍摄点不可用" : "可用性待确认"
} else {
@@ -188,7 +165,7 @@ final class DronePreparationPointCell: UICollectionViewCell {
contentView.backgroundColor = selected ? DroneDockStyle.primary.withAlphaComponent(0.07) : .white
contentView.layer.borderColor = (selected ? DroneDockStyle.primary : DroneDockStyle.border).cgColor
contentView.alpha = spot.available == true ? 1 : 0.55
accessibilityLabel = "\(spot.name),\(rangeLabel.text ?? ""),\(countLabel.text ?? "")"
accessibilityLabel = "\(spot.name),\(countLabel.text ?? "")"
accessibilityTraits = selected ? [.button, .selected] : .button
if spot.available != true { accessibilityTraits.insert(.notEnabled) }
accessibilityIdentifier = "drone.preparation.point.\(spot.id)"
@@ -417,7 +394,7 @@ final class DronePreparationEmptyCell: UICollectionViewCell {
}
}
/// 固定底部许可栏,独立刷新连接、范围、设备与主按钮。
/// 固定底部许可栏,独立刷新连接、设备与主按钮。
@MainActor
final class DronePreparationFooterView: UIView {
/// 工作人员主动点击主操作时通知控制器。
@@ -426,7 +403,6 @@ final class DronePreparationFooterView: UIView {
var onRefreshTap: (() -> Void)?
private let connectionLabel = DronePreparationIndicatorView()
private let rangeLabel = DronePreparationIndicatorView()
private let selectionLabel = DroneDockStyle.label(size: 13, weight: .semibold)
private let deviceCaption = DroneDockStyle.label("无人机:", size: 11, color: DroneDockStyle.secondary)
private let deviceLabel = DroneDockStatusLabel()
@@ -437,13 +413,8 @@ final class DronePreparationFooterView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
let statusRow = UIStackView(arrangedSubviews: [connectionLabel, rangeLabel])
statusRow.axis = .horizontal
statusRow.distribution = .fillEqually
let divider = UIView()
divider.backgroundColor = DroneDockStyle.border
let verticalDivider = UIView()
verticalDivider.backgroundColor = DroneDockStyle.border
let deviceRow = UIStackView(arrangedSubviews: [deviceCaption, deviceLabel, UIView()])
deviceRow.axis = .horizontal
deviceRow.alignment = .center
@@ -470,19 +441,13 @@ final class DronePreparationFooterView: UIView {
primaryButton.titleLabel?.minimumScaleFactor = 0.85
primaryButton.accessibilityIdentifier = "drone.preparation.summon"
primaryButton.addTarget(self, action: #selector(primaryTapped), for: .touchUpInside)
[statusRow, divider, summary, primaryButton, messageRow].forEach(addSubview)
statusRow.addSubview(verticalDivider)
statusRow.snp.makeConstraints { make in
[connectionLabel, divider, summary, primaryButton, messageRow].forEach(addSubview)
connectionLabel.snp.makeConstraints { make in
make.leading.trailing.top.equalToSuperview()
make.height.equalTo(42)
}
verticalDivider.snp.makeConstraints { make in
make.center.equalToSuperview()
make.width.equalTo(1 / UIScreen.main.scale)
make.height.equalTo(18)
}
divider.snp.makeConstraints { make in
make.top.equalTo(statusRow.snp.bottom)
make.top.equalTo(connectionLabel.snp.bottom)
make.leading.trailing.equalToSuperview()
make.height.equalTo(1 / UIScreen.main.scale)
}
@@ -515,7 +480,6 @@ final class DronePreparationFooterView: UIView {
/// 只绑定 ViewModel 已计算的展示内容和许可,不按电量或连接自行判定可召唤。
func apply(viewModel: DroneShootingPreparationViewModel) {
connectionLabel.apply(title: viewModel.connectionTitle, tone: viewModel.connectionTone)
rangeLabel.apply(title: viewModel.rangeTitle, tone: viewModel.rangeTone)
selectionLabel.text = viewModel.selectionSummary
deviceLabel.apply(title: viewModel.deviceStatusText, tone: viewModel.deviceState.tone)
primaryButton.setTitle(viewModel.primaryButtonTitle, for: .normal)
@@ -523,7 +487,12 @@ final class DronePreparationFooterView: UIView {
primaryButton.backgroundColor = viewModel.primaryButtonEnabled ? DroneDockStyle.primary : UIColor(hex: 0xE1E7F0)
primaryButton.setTitleColor(.white, for: .normal)
primaryButton.setTitleColor(UIColor(hex: 0x8792A5), for: .disabled)
messageLabel.text = viewModel.admission.message
switch viewModel.admission {
case .outOfRange, .unknownRange:
messageLabel.text = "当前暂不可召唤,请稍后重试"
default:
messageLabel.text = viewModel.admission.message
}
messageLabel.textColor = DroneDockStyle.color(for: viewModel.admission.tone)
refreshButton.isHidden = !viewModel.shouldShowSummonRefresh
}
@@ -531,7 +500,6 @@ final class DronePreparationFooterView: UIView {
/// 展示真实准备状态;本阶段保留召唤按钮文案,但尚不提供飞行执行入口。
func apply(preparationViewModel viewModel: DroneDockPreparationViewModel, isRefreshing: Bool = false) {
connectionLabel.apply(title: viewModel.connectionTitle, tone: viewModel.connectionTone)
rangeLabel.apply(title: viewModel.rangeTitle, tone: viewModel.rangeTone)
selectionLabel.text = viewModel.selectionSummary
selectionLabel.numberOfLines = 2
deviceLabel.apply(title: viewModel.deviceStatusText, tone: viewModel.deviceTone)
@@ -549,7 +517,7 @@ final class DronePreparationFooterView: UIView {
@objc private func refreshTapped() { onRefreshTap?() }
}
/// 连接与范围共用的小型状态图标,图标只映射语义色。
/// 机巢连接的小型状态图标,图标只映射语义色。
@MainActor
private final class DronePreparationIndicatorView: UIView {
private let icon = UIImageView()