feat(drone-dock): 完善真实联调、状态轮询与准备页反馈
开放 Release 真实操作并保留 Debug 拦截;恢复前台 shooting 串行轮询;统一打印机巢请求与完整原值响应;优化长点位名称、未拍摄文案、报备失败及已结束任务提示,移除成功回执 UI。补充相关测试、离线策略检查和联调说明。
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 在准备页展示任务创建或召唤请求的回执,保留 data 原文结构并支持滚动与选择文本。
|
||||
/// 准备页业务失败卡片,完整换行展示原因,不展示成功回执或接口 JSON。
|
||||
@MainActor
|
||||
final class DroneDockTaskCreationResultCell: UICollectionViewCell {
|
||||
private let titleLabel = DroneDockStyle.label(size: 16, weight: .semibold)
|
||||
private let detailLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
||||
private let responseView = UITextView()
|
||||
private let detailLabel = DroneDockStyle.label(size: 14, color: DroneDockStyle.secondary)
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
@@ -14,23 +13,13 @@ final class DroneDockTaskCreationResultCell: UICollectionViewCell {
|
||||
contentView.layer.cornerRadius = 10
|
||||
titleLabel.numberOfLines = 0
|
||||
detailLabel.numberOfLines = 0
|
||||
responseView.backgroundColor = .clear
|
||||
responseView.isEditable = false
|
||||
responseView.isSelectable = true
|
||||
responseView.alwaysBounceVertical = true
|
||||
responseView.textContainerInset = .zero
|
||||
responseView.textContainer.lineFragmentPadding = 0
|
||||
responseView.accessibilityIdentifier = "drone.preparation.creationResponse"
|
||||
[titleLabel, detailLabel, responseView].forEach(contentView.addSubview)
|
||||
titleLabel.textColor = DroneDockStyle.warning
|
||||
[titleLabel, detailLabel].forEach(contentView.addSubview)
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.leading.trailing.equalToSuperview().inset(12)
|
||||
}
|
||||
detailLabel.snp.makeConstraints { make in
|
||||
make.top.equalTo(titleLabel.snp.bottom).offset(6)
|
||||
make.leading.trailing.equalTo(titleLabel)
|
||||
}
|
||||
responseView.snp.makeConstraints { make in
|
||||
make.top.equalTo(detailLabel.snp.bottom).offset(12)
|
||||
make.top.equalTo(titleLabel.snp.bottom).offset(8)
|
||||
make.leading.trailing.equalTo(titleLabel)
|
||||
make.bottom.equalToSuperview().inset(12)
|
||||
}
|
||||
@@ -39,42 +28,10 @@ final class DroneDockTaskCreationResultCell: UICollectionViewCell {
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
/// 成功保留完整 data,失败显示真实错误,不构造任务 ID 或成功响应。
|
||||
func apply(task: DroneDockCreatedTask?, errorMessage: String?, outcomeUnknown: Bool) {
|
||||
responseView.accessibilityIdentifier = "drone.preparation.creationResponse"
|
||||
if let task {
|
||||
titleLabel.text = "任务已创建 · ID \(task.taskID)"
|
||||
titleLabel.textColor = DroneDockStyle.success
|
||||
detailLabel.text = "tasks/create 返回的 data"
|
||||
responseView.font = .monospacedSystemFont(ofSize: 12, weight: .regular)
|
||||
if responseView.text != task.dataJSON { responseView.text = task.dataJSON }
|
||||
} else {
|
||||
titleLabel.text = outcomeUnknown ? "任务创建结果待确认" : "任务创建未成功"
|
||||
titleLabel.textColor = DroneDockStyle.warning
|
||||
detailLabel.text = outcomeUnknown ? "请先核对订单任务,避免重复创建" : "接口返回的错误信息"
|
||||
responseView.font = .systemFont(ofSize: 14)
|
||||
responseView.text = errorMessage
|
||||
}
|
||||
responseView.textColor = DroneDockStyle.text
|
||||
}
|
||||
|
||||
/// 展示 shoot 回执;提交成功不代表无人机已到达,结果未知不能引导直接重发。
|
||||
func applyShoot(taskID: Int?, dataJSON: String?, errorMessage: String?, isLoading: Bool,
|
||||
hasSucceeded: Bool, outcomeUnknown: Bool) {
|
||||
responseView.accessibilityIdentifier = "drone.preparation.shootResponse"
|
||||
let suffix = taskID.map { " · ID \($0)" } ?? ""
|
||||
let title: String
|
||||
if isLoading { title = "正在召唤无人机" }
|
||||
else if hasSucceeded { title = "召唤请求已提交" }
|
||||
else { title = outcomeUnknown ? "召唤结果待核对" : "召唤请求未成功" }
|
||||
titleLabel.text = title + suffix
|
||||
titleLabel.textColor = hasSucceeded ? DroneDockStyle.success : errorMessage == nil ? DroneDockStyle.text : DroneDockStyle.warning
|
||||
if isLoading { detailLabel.text = "正在为已创建的任务提交召唤请求" }
|
||||
else if hasSucceeded { detailLabel.text = "shoot 返回信息;飞行进度以任务状态为准" }
|
||||
else { detailLabel.text = outcomeUnknown ? "请先核对任务状态,避免重复发送召唤" : "任务已保留,可重试召唤" }
|
||||
responseView.font = dataJSON == nil ? .systemFont(ofSize: 14) : .monospacedSystemFont(ofSize: 12, weight: .regular)
|
||||
let text = dataJSON ?? errorMessage ?? (hasSucceeded ? "接口已返回业务成功,未提供可展示的 data。" : "")
|
||||
if responseView.text != text { responseView.text = text }
|
||||
responseView.textColor = DroneDockStyle.text
|
||||
/// 只接收面向用户的错误模型,成功 data 不进入视图层。
|
||||
func apply(failure: DroneDockPreparationFailure, identifier: String) {
|
||||
titleLabel.text = failure.title
|
||||
detailLabel.text = failure.message
|
||||
detailLabel.accessibilityIdentifier = identifier
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user