feat: 完善机巢图传、拍摄阶段与任务交互
- 完善双路 RTC 接收、首帧切换及拍摄结束后的本地播放释放 - 对齐无人机状态枚举与正常拍完返航标记,新增到达后本地倒计时 - 补充准备页电量与前往回执,进入任务时移除准备页路由 - 对齐拍摄中和拍摄完成原型布局,移除详情按钮 - 补充隔离测试、接口记录与项目约定 验证:最近 157 项相关模拟器隔离测试通过,Release 无签名编译通过;未调用真实飞控或图传。
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import AVFoundation
|
||||
import Kingfisher
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
@@ -14,6 +15,8 @@ final class DroneDockTaskLiveView: UIView {
|
||||
private let titleLabel = DroneDockStyle.label(size: 15, weight: .medium, color: .white)
|
||||
private let messageLabel = DroneDockStyle.label(size: 12, color: .lightGray)
|
||||
private let sourceLabel = DroneDockStyle.label(size: 11, weight: .medium, color: .white)
|
||||
private let sourceBadge = UIStackView()
|
||||
private let liveDot = UIView()
|
||||
private let requestButton = UIButton(type: .system)
|
||||
private let labels = UIStackView()
|
||||
private var player: AVQueuePlayer?
|
||||
@@ -22,6 +25,12 @@ final class DroneDockTaskLiveView: UIView {
|
||||
private var activeURL: URL?
|
||||
private var isPlaybackActive = false
|
||||
private let rtcView = UIView()
|
||||
private let coverView = UIImageView()
|
||||
private let coverShade = UIView()
|
||||
private let coverIcon = UIImageView(image: UIImage(systemName: "photo.on.rectangle.angled"))
|
||||
private var labelsCenterY: Constraint?
|
||||
private var isShowingCover = false
|
||||
private var coverURL: URL?
|
||||
private let rtcPlayer: any DroneDockLivePlaying
|
||||
private var requestedRTC: [DroneDockVolcLiveConfiguration] = []
|
||||
private var activeRTC: [DroneDockVolcLiveConfiguration] = []
|
||||
@@ -64,6 +73,7 @@ final class DroneDockTaskLiveView: UIView {
|
||||
|
||||
/// 在明确时机应用模型;远程 URL 即使错误传入也不会创建播放器。
|
||||
func apply(_ model: DroneDockLiveViewModel) {
|
||||
guard !isShowingCover else { return }
|
||||
titleLabel.text = model.title
|
||||
messageLabel.text = model.message
|
||||
requestButton.setTitle(model.actionTitle, for: .normal)
|
||||
@@ -74,8 +84,9 @@ final class DroneDockTaskLiveView: UIView {
|
||||
requestedSessionID = model.playbackSessionID
|
||||
let hasLocalPreview = requestedURL != nil
|
||||
let isPlaying = model.state == .playing
|
||||
sourceLabel.text = hasLocalPreview ? "本地模拟画面 · 未连接无人机" : (isPlaying ? model.message + " · 实时图传" : nil)
|
||||
sourceLabel.isHidden = !hasLocalPreview && !isPlaying
|
||||
sourceLabel.text = hasLocalPreview ? "本地模拟画面 · 未连接无人机" : "实时图传"
|
||||
sourceBadge.isHidden = !hasLocalPreview && !isPlaying
|
||||
liveDot.isHidden = hasLocalPreview
|
||||
titleLabel.isHidden = hasLocalPreview || isPlaying
|
||||
messageLabel.isHidden = hasLocalPreview || isPlaying
|
||||
accessibilityLabel = hasLocalPreview || isPlaying ? sourceLabel.text : "\(model.title),\(model.message)"
|
||||
@@ -84,10 +95,32 @@ final class DroneDockTaskLiveView: UIView {
|
||||
|
||||
/// 页面离开或进入后台立即释放播放器;重新获取图传参数由控制器协调。
|
||||
func setPlaybackActive(_ active: Bool) {
|
||||
isPlaybackActive = active
|
||||
isPlaybackActive = active && !isShowingCover
|
||||
updatePlayback()
|
||||
}
|
||||
|
||||
/// 录制结束后仅展示静态封面;隐藏实时标记和重试按钮,旧模型不能恢复播放。
|
||||
func showRecordingCover(_ show: Bool, url: URL?) {
|
||||
guard isShowingCover != show || coverURL != url else { return }
|
||||
isShowingCover = show
|
||||
coverURL = url
|
||||
coverView.isHidden = !show
|
||||
coverShade.isHidden = !show
|
||||
coverIcon.isHidden = !show || url != nil
|
||||
labelsCenterY?.update(offset: show ? 38 : -15)
|
||||
guard show else { coverView.kf.cancelDownloadTask(); return }
|
||||
setPlaybackActive(false)
|
||||
coverView.contentMode = .scaleAspectFill
|
||||
coverView.kf.setImage(with: url)
|
||||
titleLabel.text = "拍摄已完成"
|
||||
titleLabel.isHidden = false
|
||||
messageLabel.text = "拍摄封面 · 实时图传已结束"
|
||||
messageLabel.isHidden = false
|
||||
sourceBadge.isHidden = true
|
||||
requestButton.isHidden = true
|
||||
accessibilityLabel = "拍摄已完成,拍摄封面,实时图传已结束"
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
backgroundColor = UIColor(hex: 0x171B22)
|
||||
clipsToBounds = true
|
||||
@@ -95,6 +128,19 @@ final class DroneDockTaskLiveView: UIView {
|
||||
layer.addSublayer(playerLayer)
|
||||
rtcView.backgroundColor = .clear
|
||||
addSubview(rtcView)
|
||||
coverView.backgroundColor = UIColor(hex: 0x182A36)
|
||||
coverView.tintColor = UIColor.white.withAlphaComponent(0.22)
|
||||
coverView.clipsToBounds = true
|
||||
coverView.isHidden = true
|
||||
coverView.accessibilityIdentifier = "drone.task.remote.live.cover"
|
||||
addSubview(coverView)
|
||||
coverShade.backgroundColor = .black.withAlphaComponent(0.3)
|
||||
coverShade.isHidden = true
|
||||
addSubview(coverShade)
|
||||
coverIcon.contentMode = .scaleAspectFit
|
||||
coverIcon.tintColor = .white.withAlphaComponent(0.7)
|
||||
coverIcon.isHidden = true
|
||||
addSubview(coverIcon)
|
||||
playerLayer.videoGravity = .resizeAspect
|
||||
titleLabel.textAlignment = .center
|
||||
messageLabel.textAlignment = .center
|
||||
@@ -102,11 +148,16 @@ final class DroneDockTaskLiveView: UIView {
|
||||
messageLabel.accessibilityIdentifier = "drone.task.remote.live.status"
|
||||
titleLabel.accessibilityIdentifier = "drone.task.remote.live.title"
|
||||
sourceLabel.accessibilityIdentifier = "drone.task.remote.live.source"
|
||||
sourceLabel.backgroundColor = UIColor.black.withAlphaComponent(0.65)
|
||||
sourceLabel.textAlignment = .center
|
||||
sourceLabel.layer.cornerRadius = 4
|
||||
sourceLabel.clipsToBounds = true
|
||||
sourceLabel.isHidden = true
|
||||
sourceBadge.axis = .horizontal
|
||||
sourceBadge.alignment = .center
|
||||
sourceBadge.spacing = 6
|
||||
sourceBadge.isHidden = true
|
||||
sourceBadge.accessibilityIdentifier = "drone.task.remote.live.badge"
|
||||
liveDot.backgroundColor = DroneDockStyle.success
|
||||
liveDot.layer.cornerRadius = 3
|
||||
liveDot.accessibilityIdentifier = "drone.task.remote.live.dot"
|
||||
sourceBadge.addArrangedSubview(liveDot)
|
||||
sourceBadge.addArrangedSubview(sourceLabel)
|
||||
requestButton.tintColor = .white
|
||||
requestButton.titleLabel?.font = .systemFont(ofSize: 13, weight: .medium)
|
||||
requestButton.backgroundColor = UIColor.black.withAlphaComponent(0.45)
|
||||
@@ -119,14 +170,21 @@ final class DroneDockTaskLiveView: UIView {
|
||||
labels.addArrangedSubview(titleLabel)
|
||||
labels.addArrangedSubview(messageLabel)
|
||||
addSubview(labels)
|
||||
addSubview(sourceLabel)
|
||||
addSubview(sourceBadge)
|
||||
addSubview(requestButton)
|
||||
}
|
||||
|
||||
private func setupConstraints() {
|
||||
rtcView.snp.makeConstraints { $0.edges.equalToSuperview() }
|
||||
coverView.snp.makeConstraints { $0.edges.equalToSuperview() }
|
||||
coverShade.snp.makeConstraints { $0.edges.equalToSuperview() }
|
||||
coverIcon.snp.makeConstraints { make in
|
||||
make.centerX.equalToSuperview()
|
||||
make.centerY.equalToSuperview().offset(-28)
|
||||
make.size.equalTo(42)
|
||||
}
|
||||
labels.snp.makeConstraints { make in
|
||||
make.centerY.equalToSuperview().offset(-15)
|
||||
labelsCenterY = make.centerY.equalToSuperview().offset(-15).constraint
|
||||
make.leading.trailing.equalToSuperview().inset(20)
|
||||
}
|
||||
requestButton.snp.makeConstraints { make in
|
||||
@@ -135,10 +193,10 @@ final class DroneDockTaskLiveView: UIView {
|
||||
make.width.greaterThanOrEqualTo(150)
|
||||
make.height.equalTo(36)
|
||||
}
|
||||
sourceLabel.snp.makeConstraints { make in
|
||||
make.top.leading.equalToSuperview().inset(10)
|
||||
make.height.equalTo(24)
|
||||
make.width.equalTo(200)
|
||||
liveDot.snp.makeConstraints { $0.size.equalTo(6).priority(999) }
|
||||
sourceBadge.snp.makeConstraints { make in
|
||||
make.top.leading.equalToSuperview().inset(12)
|
||||
make.trailing.lessThanOrEqualToSuperview().inset(12)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user