feat(drone-dock): 接通任务召唤与状态页并固定拍摄布局
接入 plane-status、tasks/create、shoot 与 shooting,保持同一任务 ID 串接、重复提交保护和只读单次刷新。拍摄任务页固定顶部参数与底部安全控制,中间状态区域适配小屏且不滚动;同步接口记录、脱敏响应及相关测试。
This commit is contained in:
@@ -158,6 +158,9 @@ final class DroneShootingTaskTelemetryView: UIView {
|
||||
private let stackView = UIStackView()
|
||||
private let staleLabel = DroneDockStyle.label("ⓘ 状态暂未更新", size: 11, color: DroneDockStyle.secondary)
|
||||
private var cells: [DroneShootingTaskTelemetryCell] = []
|
||||
private var rowHeights: [Constraint] = []
|
||||
private var contentEdges: Constraint?
|
||||
private var usesFixedLayout = false
|
||||
|
||||
/// 以两行三列固定展示电量、温度、风速、雨量、信号与搜星。
|
||||
override init(frame: CGRect) {
|
||||
@@ -184,22 +187,38 @@ final class DroneShootingTaskTelemetryView: UIView {
|
||||
row.addArrangedSubview(cell)
|
||||
}
|
||||
stackView.addArrangedSubview(row)
|
||||
row.snp.makeConstraints { make in make.height.equalTo(55) }
|
||||
row.snp.makeConstraints { make in rowHeights.append(make.height.equalTo(55).constraint) }
|
||||
}
|
||||
stackView.snp.makeConstraints { make in make.edges.equalToSuperview().inset(10) }
|
||||
stackView.snp.makeConstraints { make in contentEdges = make.edges.equalToSuperview().inset(10).constraint }
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
/// 固定任务页不增减状态提示行;小屏仅压缩格子间距与留白,六项参数位置保持稳定。
|
||||
func configureFixedLayout(compact: Bool) {
|
||||
usesFixedLayout = true
|
||||
staleLabel.isHidden = true
|
||||
rowHeights.forEach { $0.update(offset: compact ? 46 : 55) }
|
||||
stackView.spacing = compact ? 4 : 6
|
||||
contentEdges?.update(inset: compact ? 8 : 10)
|
||||
}
|
||||
|
||||
/// 新快照覆盖全部读数;不保留断网前的值冒充有效数据。
|
||||
func apply(telemetry: DroneDockTelemetry, isStale: Bool) {
|
||||
staleLabel.isHidden = !isStale
|
||||
let values = isStale
|
||||
? Array(repeating: "—", count: 6)
|
||||
: [telemetry.batteryText, telemetry.temperatureText, telemetry.windText, telemetry.rainText, telemetry.signalText, telemetry.satelliteText]
|
||||
apply(values: [telemetry.batteryText, telemetry.temperatureText, telemetry.windText,
|
||||
telemetry.rainText, telemetry.signalText, telemetry.satelliteText], isStale: isStale)
|
||||
}
|
||||
|
||||
/// 展示后端已格式化的六项读数,保留单位;缺项与过期读数显示破折号。
|
||||
func apply(values: [String], isStale: Bool, accessibilityPrefix: String? = nil) {
|
||||
staleLabel.isHidden = usesFixedLayout || !isStale
|
||||
let keys = ["battery", "temperature", "wind", "rain", "signal", "satellite"]
|
||||
for (index, cell) in cells.enumerated() {
|
||||
cell.apply(value: values[index], isStale: isStale)
|
||||
let value = !isStale && values.indices.contains(index)
|
||||
? DroneDockHomeMetric.usableText(values[index]) ?? "—" : "—"
|
||||
cell.apply(value: value, isStale: isStale)
|
||||
if let accessibilityPrefix { cell.accessibilityIdentifier = "\(accessibilityPrefix).\(keys[index])" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user