- 完善双路 RTC 接收、首帧切换及拍摄结束后的本地播放释放 - 对齐无人机状态枚举与正常拍完返航标记,新增到达后本地倒计时 - 补充准备页电量与前往回执,进入任务时移除准备页路由 - 对齐拍摄中和拍摄完成原型布局,移除详情按钮 - 补充隔离测试、接口记录与项目约定 验证:最近 157 项相关模拟器隔离测试通过,Release 无签名编译通过;未调用真实飞控或图传。
134 lines
6.2 KiB
Swift
134 lines
6.2 KiB
Swift
import SnapKit
|
|
import UIKit
|
|
|
|
/// 拍摄完成区域:左侧完成图标、右侧状态说明以及整行素材入口。
|
|
@MainActor
|
|
final class DroneDockTaskCompletedView: UIView {
|
|
/// 用户点击已允许的素材入口时通知任务页面。
|
|
var onViewMaterials: (() -> Void)?
|
|
/// 与任务固定区域共享紧凑布局指标,操作区域始终至少 44 点高。
|
|
private(set) var usesCompactLayout = false
|
|
|
|
private let content = UIView()
|
|
private let iconBackground = UIView()
|
|
private let icon = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
|
|
private let titleLabel = DroneDockStyle.label(size: 20, weight: .semibold)
|
|
private let messageLabel = DroneDockStyle.label(size: 14, color: DroneDockStyle.secondary)
|
|
private let materialsButton = UIButton(type: .system)
|
|
private var messageHeight: Constraint?
|
|
private var titleHeight: Constraint?
|
|
private var buttonHeight: Constraint?
|
|
|
|
/// 创建不包含设备摘要或次级详情按钮的完成面板。
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
setupUI()
|
|
setupConstraints()
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 仅展示已确认的完成文案,素材入口继续服从任务门禁与页面刷新状态。
|
|
func apply(_ presentation: DroneDockTaskPresentation, isRefreshing: Bool) {
|
|
titleLabel.text = presentation.title
|
|
messageLabel.text = presentation.message
|
|
var configuration = materialsButton.configuration
|
|
configuration?.title = presentation.actionTitle
|
|
materialsButton.isEnabled = presentation.action == .materials && presentation.isActionEnabled && !isRefreshing
|
|
configuration?.baseBackgroundColor = DroneDockStyle.primary.withAlphaComponent(materialsButton.isEnabled ? 1 : 0.35)
|
|
materialsButton.configuration = configuration
|
|
setNeedsLayout()
|
|
}
|
|
|
|
/// 仅当前可见面板提供通用任务访问标识,防止状态切换后匹配到隐藏控件。
|
|
func setIdentifiersActive(_ active: Bool) {
|
|
titleLabel.accessibilityIdentifier = active ? "drone.task.remote.statusTitle" : nil
|
|
messageLabel.accessibilityIdentifier = active ? "drone.task.remote.statusMessage" : nil
|
|
materialsButton.accessibilityIdentifier = active ? "drone.task.remote.primary" : nil
|
|
}
|
|
|
|
/// 固定区域变小时收紧说明行数与间距,不改变整页布局或缩小点击区域。
|
|
override func layoutSubviews() {
|
|
usesCompactLayout = bounds.height < 190
|
|
let extreme = bounds.height < 120
|
|
titleLabel.font = .systemFont(ofSize: extreme ? 17 : 20, weight: .semibold)
|
|
messageLabel.font = .systemFont(ofSize: usesCompactLayout ? 13 : 14)
|
|
messageLabel.numberOfLines = usesCompactLayout ? 2 : 3
|
|
let width = max(1, bounds.width - 84)
|
|
let measured = messageLabel.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude)).height
|
|
let title = ceil(titleLabel.font.lineHeight)
|
|
let button: CGFloat = usesCompactLayout ? 44 : 50
|
|
let availableMessageHeight = max(0, bounds.height - 24 - title - 6 - 16 - button)
|
|
let body = min(ceil(measured), availableMessageHeight)
|
|
messageLabel.isHidden = body < messageLabel.font.lineHeight
|
|
messageHeight?.update(offset: messageLabel.isHidden ? 0 : body)
|
|
titleHeight?.update(offset: title)
|
|
buttonHeight?.update(offset: button)
|
|
super.layoutSubviews()
|
|
}
|
|
|
|
private func setupUI() {
|
|
accessibilityIdentifier = "drone.task.remote.completed"
|
|
addSubview(content)
|
|
[iconBackground, titleLabel, messageLabel, materialsButton].forEach(content.addSubview)
|
|
iconBackground.addSubview(icon)
|
|
iconBackground.backgroundColor = DroneDockStyle.success.withAlphaComponent(0.12)
|
|
iconBackground.layer.cornerRadius = 20
|
|
icon.contentMode = .scaleAspectFit
|
|
icon.tintColor = DroneDockStyle.success
|
|
titleLabel.accessibilityTraits = .header
|
|
titleLabel.numberOfLines = 1
|
|
titleLabel.lineBreakMode = .byTruncatingTail
|
|
messageLabel.lineBreakMode = .byTruncatingTail
|
|
var configuration = UIButton.Configuration.filled()
|
|
configuration.baseForegroundColor = .white
|
|
configuration.background.cornerRadius = 8
|
|
configuration.cornerStyle = .fixed
|
|
configuration.image = UIImage(systemName: "photo", withConfiguration: UIImage.SymbolConfiguration(pointSize: 15))
|
|
configuration.imagePadding = 8
|
|
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { attributes in
|
|
var result = attributes
|
|
result.font = .systemFont(ofSize: 15, weight: .semibold)
|
|
return result
|
|
}
|
|
materialsButton.configuration = configuration
|
|
materialsButton.addTarget(self, action: #selector(viewMaterials), for: .touchUpInside)
|
|
}
|
|
|
|
private func setupConstraints() {
|
|
content.snp.makeConstraints { make in
|
|
make.leading.trailing.equalToSuperview().inset(16)
|
|
make.centerY.equalToSuperview()
|
|
}
|
|
iconBackground.snp.makeConstraints { make in
|
|
make.top.leading.equalToSuperview()
|
|
make.size.equalTo(40)
|
|
}
|
|
icon.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
make.size.equalTo(22)
|
|
}
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.top.trailing.equalToSuperview()
|
|
make.leading.equalTo(iconBackground.snp.trailing).offset(12)
|
|
titleHeight = make.height.equalTo(24).constraint
|
|
}
|
|
messageLabel.snp.makeConstraints { make in
|
|
make.top.equalTo(titleLabel.snp.bottom).offset(6)
|
|
make.leading.trailing.equalTo(titleLabel)
|
|
messageHeight = make.height.equalTo(34).constraint
|
|
}
|
|
materialsButton.snp.makeConstraints { make in
|
|
make.top.equalTo(messageLabel.snp.bottom).offset(16)
|
|
make.leading.trailing.bottom.equalToSuperview()
|
|
buttonHeight = make.height.equalTo(50).constraint
|
|
}
|
|
}
|
|
|
|
@objc private func viewMaterials() {
|
|
guard !isHidden, materialsButton.isEnabled else { return }
|
|
onViewMaterials?()
|
|
}
|
|
}
|