482 lines
23 KiB
Swift
482 lines
23 KiB
Swift
import SnapKit
|
|
import UIKit
|
|
|
|
/// 当前任务页面的导航意图;返回始终由工作台协调器处理。
|
|
@MainActor
|
|
protocol DroneShootingTaskViewControllerDelegate: AnyObject {
|
|
/// 直接回工作台,保留原任务,不弹离页确认。
|
|
func shootingTaskViewControllerDidRequestWorkbench(_ controller: DroneShootingTaskViewController)
|
|
/// 任务确认结束且仍有余次后,进入准备页恢复有效选择。
|
|
func shootingTaskViewController(_ controller: DroneShootingTaskViewController, didRequestPreparationFor order: DroneShootingOrder)
|
|
/// 查看当前订单的素材;首轮由入口协调器提供占位。
|
|
func shootingTaskViewController(_ controller: DroneShootingTaskViewController, didRequestMaterialsFor order: DroneShootingOrder)
|
|
}
|
|
|
|
/// 原任务控制页:独立展示飞行、拍摄结果、连接及指令确认状态。
|
|
@MainActor
|
|
final class DroneShootingTaskViewController: BaseViewController {
|
|
/// 协调工作台、重新准备与素材入口,不在页面内创建新任务。
|
|
weak var delegate: (any DroneShootingTaskViewControllerDelegate)?
|
|
|
|
private let viewModel: DroneShootingTaskViewModel
|
|
private let demoBar = UIView()
|
|
private let scrollView = UIScrollView()
|
|
private let contentStack = UIStackView()
|
|
private let summaryView = UIView()
|
|
private let taskTitleLabel = DroneDockStyle.label(size: 17, weight: .semibold)
|
|
private let subtitleLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
|
private let feedView = DroneShootingTaskFeedView()
|
|
private let telemetryView = DroneShootingTaskTelemetryView()
|
|
private let controlPanel = UIView()
|
|
private let controlStack = UIStackView()
|
|
private let statusIconBackground = UIView()
|
|
private let statusIconView = UIImageView()
|
|
private let statusTitleLabel = DroneDockStyle.label(size: 21, weight: .semibold)
|
|
private let statusMessageLabel = DroneDockStyle.label(size: 12, color: DroneDockStyle.secondary)
|
|
private let commandView = UIView()
|
|
private let commandTitleLabel = DroneDockStyle.label(size: 12, weight: .semibold, color: DroneDockStyle.warning)
|
|
private let commandMessageLabel = DroneDockStyle.label(size: 11, color: DroneDockStyle.secondary)
|
|
private let refreshTaskButton = UIButton(type: .system)
|
|
private let primaryButton = UIButton(type: .system)
|
|
private let preparationButton = UIButton(type: .system)
|
|
private let materialsButton = UIButton(type: .system)
|
|
private let pauseButton = DroneShootingTaskSafetyButton(symbol: "pause.circle", color: UIColor(hex: 0xEC982A), filled: true)
|
|
private let returnButton = DroneShootingTaskSafetyButton(symbol: "arrow.uturn.backward", color: UIColor(hex: 0xD85762), filled: false)
|
|
private var displayedResultNoticeID: String?
|
|
private var interactivePopWasEnabled: Bool?
|
|
|
|
/// 注入共享数据源上的原任务 ViewModel;构造及页面出现不会发起召唤。
|
|
init(viewModel: DroneShootingTaskViewModel) {
|
|
self.viewModel = viewModel
|
|
super.init(nibName: nil, bundle: nil)
|
|
hidesBottomBarWhenPushed = true
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
/// 重进时只读取原任务,等待明确状态,不重发控制指令。
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
if interactivePopWasEnabled == nil {
|
|
interactivePopWasEnabled = navigationController?.interactivePopGestureRecognizer?.isEnabled
|
|
}
|
|
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
|
|
viewModel.refresh()
|
|
applySnapshot()
|
|
}
|
|
|
|
/// 页面完整呈现后才显示本次结果提示,用户可以稍后查看素材。
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
super.viewDidAppear(animated)
|
|
presentResultNoticeIfNeeded()
|
|
}
|
|
|
|
/// 恢复其他页面原有返回手势;本页返回统一直接回工作台。
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
if let interactivePopWasEnabled {
|
|
navigationController?.interactivePopGestureRecognizer?.isEnabled = interactivePopWasEnabled
|
|
self.interactivePopWasEnabled = nil
|
|
}
|
|
}
|
|
|
|
/// 配置直接返回工作台的导航入口。
|
|
override func setupNavigationBar() {
|
|
title = "拍摄任务"
|
|
navigationItem.hidesBackButton = true
|
|
let back = UIBarButtonItem(image: UIImage(systemName: "chevron.left"), style: .plain, target: self, action: #selector(backTapped))
|
|
back.tintColor = DroneDockStyle.text
|
|
back.accessibilityLabel = "返回机巢工作台"
|
|
back.accessibilityIdentifier = "drone.task.back"
|
|
navigationItem.leftBarButtonItem = back
|
|
}
|
|
|
|
/// 依原型布局摘要、演示画面、遥测与固定控制区。
|
|
override func setupUI() {
|
|
view.backgroundColor = .white
|
|
setupDemoBar()
|
|
scrollView.showsVerticalScrollIndicator = false
|
|
scrollView.alwaysBounceVertical = false
|
|
scrollView.accessibilityIdentifier = "drone.task.overview"
|
|
view.addSubview(scrollView)
|
|
contentStack.axis = .vertical
|
|
contentStack.spacing = 0
|
|
scrollView.addSubview(contentStack)
|
|
contentStack.addArrangedSubview(summaryView)
|
|
summaryView.addSubview(taskTitleLabel)
|
|
summaryView.addSubview(subtitleLabel)
|
|
taskTitleLabel.numberOfLines = 2
|
|
subtitleLabel.numberOfLines = 1
|
|
subtitleLabel.adjustsFontSizeToFitWidth = true
|
|
subtitleLabel.minimumScaleFactor = 0.8
|
|
contentStack.addArrangedSubview(feedView)
|
|
contentStack.addArrangedSubview(telemetryView)
|
|
setupControlPanel()
|
|
}
|
|
|
|
/// 上部内容允许在小屏滚动,安全控制始终保持可见。
|
|
override func setupConstraints() {
|
|
demoBar.snp.makeConstraints { make in
|
|
make.top.equalTo(view.safeAreaLayoutGuide)
|
|
make.leading.trailing.equalToSuperview()
|
|
make.height.equalTo(29)
|
|
}
|
|
scrollView.snp.makeConstraints { make in
|
|
make.top.equalTo(demoBar.snp.bottom)
|
|
make.leading.trailing.equalToSuperview()
|
|
make.bottom.equalTo(controlPanel.snp.top)
|
|
}
|
|
contentStack.snp.makeConstraints { make in
|
|
make.edges.equalTo(scrollView.contentLayoutGuide)
|
|
make.width.equalTo(scrollView.frameLayoutGuide)
|
|
}
|
|
taskTitleLabel.snp.makeConstraints { make in
|
|
make.top.equalToSuperview().offset(10)
|
|
make.leading.trailing.equalToSuperview().inset(16)
|
|
}
|
|
subtitleLabel.snp.makeConstraints { make in
|
|
make.top.equalTo(taskTitleLabel.snp.bottom).offset(5)
|
|
make.leading.trailing.equalToSuperview().inset(16)
|
|
make.bottom.equalToSuperview().inset(10)
|
|
}
|
|
feedView.snp.makeConstraints { make in
|
|
make.height.equalTo(feedView.snp.width).multipliedBy(9.0 / 16.0)
|
|
}
|
|
controlPanel.snp.makeConstraints { make in
|
|
make.leading.trailing.bottom.equalToSuperview()
|
|
}
|
|
controlStack.snp.makeConstraints { make in
|
|
make.top.equalToSuperview().offset(17)
|
|
make.leading.trailing.equalToSuperview().inset(16)
|
|
make.bottom.equalTo(view.safeAreaLayoutGuide).inset(12)
|
|
}
|
|
}
|
|
|
|
/// 将按钮操作交给 ViewModel,提交后主动刷新当前快照。
|
|
override func bindActions() {
|
|
primaryButton.addTarget(self, action: #selector(primaryTapped), for: .touchUpInside)
|
|
preparationButton.addTarget(self, action: #selector(preparationTapped), for: .touchUpInside)
|
|
materialsButton.addTarget(self, action: #selector(materialsTapped), for: .touchUpInside)
|
|
pauseButton.addTarget(self, action: #selector(pauseTapped), for: .touchUpInside)
|
|
returnButton.addTarget(self, action: #selector(returnTapped), for: .touchUpInside)
|
|
refreshTaskButton.addTarget(self, action: #selector(refreshTaskTapped), for: .touchUpInside)
|
|
feedView.onExpand = { [weak self] in
|
|
let expanded = DroneShootingTaskExpandedFeedViewController()
|
|
expanded.modalPresentationStyle = .fullScreen
|
|
self?.present(expanded, animated: true)
|
|
}
|
|
feedView.onReconnect = { [weak self] in
|
|
guard let self else { return }
|
|
if self.viewModel.phoneConnection == .disconnected {
|
|
self.viewModel.reconnectPhone()
|
|
} else if self.viewModel.phoneConnection == .connected {
|
|
self.viewModel.reconnectFeed()
|
|
}
|
|
self.applySnapshot()
|
|
}
|
|
}
|
|
|
|
private func setupDemoBar() {
|
|
demoBar.backgroundColor = UIColor(hex: 0xF3F6FC)
|
|
view.addSubview(demoBar)
|
|
let label = DroneDockStyle.label("本地界面演示 · 无真实操作", size: 10, color: DroneDockStyle.secondary)
|
|
demoBar.addSubview(label)
|
|
label.snp.makeConstraints { make in
|
|
make.leading.equalToSuperview().offset(16)
|
|
make.centerY.equalToSuperview()
|
|
}
|
|
#if DEBUG
|
|
let scenarioButton = UIButton(type: .system)
|
|
var configuration = UIButton.Configuration.plain()
|
|
configuration.title = "模拟状态"
|
|
configuration.image = UIImage(systemName: "slider.horizontal.3")
|
|
configuration.imagePadding = 4
|
|
configuration.baseForegroundColor = DroneDockStyle.primary
|
|
configuration.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 11)
|
|
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
|
var outgoing = incoming
|
|
outgoing.font = .systemFont(ofSize: 10)
|
|
return outgoing
|
|
}
|
|
scenarioButton.configuration = configuration
|
|
scenarioButton.showsMenuAsPrimaryAction = true
|
|
scenarioButton.menu = UIMenu(title: "本地模拟事件 · 不自动推进", children: DroneShootingTaskScenario.allCases.map { scenario in
|
|
UIAction(title: scenario.title) { [weak self] _ in
|
|
self?.viewModel.applyScenario(scenario)
|
|
self?.applySnapshot()
|
|
self?.presentResultNoticeIfNeeded()
|
|
}
|
|
})
|
|
scenarioButton.accessibilityIdentifier = "drone.task.scenarios"
|
|
demoBar.addSubview(scenarioButton)
|
|
scenarioButton.snp.makeConstraints { make in
|
|
make.trailing.equalToSuperview().inset(12)
|
|
make.top.bottom.equalToSuperview()
|
|
}
|
|
#endif
|
|
}
|
|
|
|
private func setupControlPanel() {
|
|
controlPanel.backgroundColor = .white
|
|
view.addSubview(controlPanel)
|
|
controlStack.axis = .vertical
|
|
controlStack.spacing = 11
|
|
controlPanel.addSubview(controlStack)
|
|
|
|
let statusRow = UIStackView()
|
|
statusRow.axis = .horizontal
|
|
statusRow.spacing = 12
|
|
statusRow.alignment = .top
|
|
statusIconBackground.layer.cornerRadius = 19
|
|
statusIconBackground.addSubview(statusIconView)
|
|
statusIconView.contentMode = .scaleAspectFit
|
|
statusIconView.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
make.size.equalTo(22)
|
|
}
|
|
statusIconBackground.snp.makeConstraints { make in make.size.equalTo(38) }
|
|
let statusTexts = UIStackView(arrangedSubviews: [statusTitleLabel, statusMessageLabel])
|
|
statusTexts.axis = .vertical
|
|
statusTexts.spacing = 6
|
|
statusTitleLabel.numberOfLines = 2
|
|
statusTitleLabel.accessibilityTraits = .header
|
|
statusTitleLabel.accessibilityIdentifier = "drone.task.statusTitle"
|
|
statusMessageLabel.numberOfLines = 0
|
|
statusMessageLabel.accessibilityIdentifier = "drone.task.statusMessage"
|
|
statusRow.addArrangedSubview(statusIconBackground)
|
|
statusRow.addArrangedSubview(statusTexts)
|
|
controlStack.addArrangedSubview(statusRow)
|
|
setupCommandView()
|
|
controlStack.addArrangedSubview(commandView)
|
|
controlStack.addArrangedSubview(primaryButton)
|
|
primaryButton.accessibilityIdentifier = "drone.task.primary"
|
|
primaryButton.snp.makeConstraints { make in make.height.equalTo(49) }
|
|
|
|
materialsButton.accessibilityIdentifier = "drone.task.materials"
|
|
materialsButton.setTitle("查看素材", for: .normal)
|
|
materialsButton.setTitleColor(DroneDockStyle.primary, for: .normal)
|
|
materialsButton.titleLabel?.font = .systemFont(ofSize: 13, weight: .medium)
|
|
materialsButton.snp.makeConstraints { make in make.height.equalTo(30).priority(999) }
|
|
controlStack.addArrangedSubview(materialsButton)
|
|
|
|
preparationButton.accessibilityIdentifier = "drone.task.prepareAgain"
|
|
preparationButton.setTitle("继续准备拍摄", for: .normal)
|
|
preparationButton.setTitleColor(DroneDockStyle.primary, for: .normal)
|
|
preparationButton.titleLabel?.font = .systemFont(ofSize: 13, weight: .medium)
|
|
preparationButton.snp.makeConstraints { make in make.height.equalTo(27).priority(999) }
|
|
controlStack.addArrangedSubview(preparationButton)
|
|
|
|
let safetyHeader = UIView()
|
|
let safetyLabel = DroneDockStyle.label("安全控制", size: 10, color: DroneDockStyle.secondary)
|
|
let leftLine = UIView()
|
|
let rightLine = UIView()
|
|
leftLine.backgroundColor = DroneDockStyle.border
|
|
rightLine.backgroundColor = DroneDockStyle.border
|
|
safetyHeader.addSubview(leftLine)
|
|
safetyHeader.addSubview(rightLine)
|
|
safetyHeader.addSubview(safetyLabel)
|
|
safetyLabel.snp.makeConstraints { make in make.center.equalToSuperview() }
|
|
leftLine.snp.makeConstraints { make in
|
|
make.leading.centerY.equalToSuperview()
|
|
make.trailing.equalTo(safetyLabel.snp.leading).offset(-9)
|
|
make.height.equalTo(0.5)
|
|
}
|
|
rightLine.snp.makeConstraints { make in
|
|
make.trailing.centerY.equalToSuperview()
|
|
make.leading.equalTo(safetyLabel.snp.trailing).offset(9)
|
|
make.height.equalTo(0.5)
|
|
}
|
|
safetyHeader.snp.makeConstraints { make in make.height.equalTo(13) }
|
|
controlStack.addArrangedSubview(safetyHeader)
|
|
controlStack.setCustomSpacing(5, after: primaryButton)
|
|
controlStack.setCustomSpacing(5, after: safetyHeader)
|
|
let safetyButtons = UIStackView(arrangedSubviews: [pauseButton, returnButton])
|
|
safetyButtons.axis = .horizontal
|
|
safetyButtons.spacing = 8
|
|
safetyButtons.distribution = .fillEqually
|
|
safetyButtons.snp.makeConstraints { make in make.height.equalTo(62) }
|
|
pauseButton.accessibilityIdentifier = "drone.task.pause"
|
|
returnButton.accessibilityIdentifier = "drone.task.return"
|
|
controlStack.addArrangedSubview(safetyButtons)
|
|
}
|
|
|
|
private func setupCommandView() {
|
|
commandView.backgroundColor = UIColor(hex: 0xFFF8EB)
|
|
commandView.layer.cornerRadius = 8
|
|
commandView.layer.borderColor = UIColor(hex: 0xF4E5C7).cgColor
|
|
commandView.layer.borderWidth = 1
|
|
let commandStack = UIStackView(arrangedSubviews: [commandTitleLabel, commandMessageLabel, refreshTaskButton])
|
|
commandStack.axis = .vertical
|
|
commandStack.spacing = 5
|
|
commandTitleLabel.numberOfLines = 0
|
|
commandMessageLabel.numberOfLines = 0
|
|
commandView.addSubview(commandStack)
|
|
commandStack.snp.makeConstraints { make in
|
|
make.top.leading.trailing.equalToSuperview().inset(10)
|
|
make.bottom.equalToSuperview().inset(10).priority(999)
|
|
}
|
|
var configuration = UIButton.Configuration.bordered()
|
|
configuration.title = "刷新任务状态"
|
|
configuration.image = UIImage(systemName: "arrow.clockwise")
|
|
configuration.imagePadding = 6
|
|
configuration.baseForegroundColor = DroneDockStyle.primary
|
|
configuration.background.backgroundColor = .clear
|
|
configuration.background.strokeColor = DroneDockStyle.primary.withAlphaComponent(0.5)
|
|
configuration.background.strokeWidth = 1
|
|
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
|
var outgoing = incoming
|
|
outgoing.font = .systemFont(ofSize: 12)
|
|
return outgoing
|
|
}
|
|
refreshTaskButton.configuration = configuration
|
|
refreshTaskButton.accessibilityIdentifier = "drone.task.sync"
|
|
refreshTaskButton.snp.makeConstraints { make in make.height.equalTo(34).priority(999) }
|
|
}
|
|
|
|
private func applySnapshot() {
|
|
guard isViewLoaded else { return }
|
|
taskTitleLabel.text = viewModel.title
|
|
subtitleLabel.text = viewModel.subtitle
|
|
feedView.apply(phone: viewModel.phoneConnection, feed: viewModel.feedConnection, isFlightFinished: viewModel.session?.isFlightFinished == true)
|
|
telemetryView.apply(telemetry: viewModel.telemetry, isStale: viewModel.phoneConnection != .connected)
|
|
statusTitleLabel.text = viewModel.statusTitle
|
|
statusMessageLabel.text = viewModel.statusMessage
|
|
let statusColor = DroneDockStyle.color(for: viewModel.statusTone)
|
|
statusIconBackground.backgroundColor = statusColor.withAlphaComponent(0.1)
|
|
statusIconView.tintColor = statusColor
|
|
statusIconView.image = UIImage(systemName: statusSymbol)
|
|
commandView.isHidden = viewModel.commandTitle == nil
|
|
commandTitleLabel.text = viewModel.commandTitle
|
|
commandMessageLabel.text = viewModel.commandMessage
|
|
refreshTaskButton.isHidden = !viewModel.shouldShowCommandRefresh
|
|
configurePrimaryButton()
|
|
materialsButton.isHidden = !(viewModel.session?.result == .succeeded && viewModel.primaryAction != .viewMaterials)
|
|
preparationButton.isHidden = !(viewModel.session?.isFlightFinished == true && (viewModel.order?.remainingShootingCount ?? 0) > 0 && viewModel.primaryAction == .viewMaterials)
|
|
pauseButton.apply(title: viewModel.pauseTitle, subtitle: viewModel.pauseSubtitle, enabled: viewModel.canPause)
|
|
returnButton.apply(title: viewModel.returnTitle, subtitle: viewModel.returnSubtitle, enabled: viewModel.canReturn)
|
|
}
|
|
|
|
private var statusSymbol: String {
|
|
if viewModel.phoneConnection != .connected { return "questionmark.circle.fill" }
|
|
if viewModel.session?.result == .succeeded { return "checkmark.circle.fill" }
|
|
if viewModel.session?.result == .failed { return "exclamationmark.circle.fill" }
|
|
switch viewModel.phase {
|
|
case .navigating: return "paperplane.fill"
|
|
case .arrived: return "checkmark.circle.fill"
|
|
case .shooting: return "video.fill"
|
|
case .shootingPaused, .returnPaused: return "pause.fill"
|
|
case .returning: return "arrow.uturn.backward"
|
|
case .unconfirmed, .none: return "questionmark.circle.fill"
|
|
}
|
|
}
|
|
|
|
private func configurePrimaryButton() {
|
|
var configuration = UIButton.Configuration.filled()
|
|
configuration.title = viewModel.primaryTitle
|
|
configuration.image = UIImage(systemName: primarySymbol)
|
|
configuration.imagePadding = 9
|
|
configuration.baseBackgroundColor = DroneDockStyle.primary
|
|
configuration.baseForegroundColor = .white
|
|
configuration.cornerStyle = .medium
|
|
let command = viewModel.session?.command
|
|
configuration.showsActivityIndicator = command?.status == .processing && (
|
|
(viewModel.primaryAction == .start && command?.kind == .start)
|
|
|| (viewModel.primaryAction == .resume && command?.kind == .resume)
|
|
)
|
|
configuration.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 20)
|
|
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
|
|
var outgoing = incoming
|
|
outgoing.font = .systemFont(ofSize: 17, weight: .semibold)
|
|
return outgoing
|
|
}
|
|
primaryButton.configuration = configuration
|
|
primaryButton.isEnabled = viewModel.primaryEnabled
|
|
primaryButton.alpha = viewModel.primaryEnabled ? 1 : 0.46
|
|
}
|
|
|
|
private var primarySymbol: String {
|
|
switch viewModel.primaryAction {
|
|
case .start: "camera"
|
|
case .resume: "play.fill"
|
|
case .viewMaterials: "photo.on.rectangle"
|
|
case .prepareAgain: "arrow.clockwise"
|
|
case .none: "camera"
|
|
}
|
|
}
|
|
|
|
private func presentResultNoticeIfNeeded() {
|
|
guard viewIfLoaded?.window != nil, presentedViewController == nil,
|
|
let notice = viewModel.resultNotice, displayedResultNoticeID != notice.id else { return }
|
|
displayedResultNoticeID = notice.id
|
|
let alert = UIAlertController(title: notice.title, message: notice.message, preferredStyle: .alert)
|
|
if notice.isSuccess {
|
|
alert.addAction(UIAlertAction(title: "稍后再去", style: .cancel) { [weak self] _ in self?.viewModel.dismissResultNotice() })
|
|
alert.addAction(UIAlertAction(title: "去查看", style: .default) { [weak self] _ in
|
|
guard let self else { return }
|
|
self.viewModel.dismissResultNotice()
|
|
self.requestMaterials()
|
|
})
|
|
} else {
|
|
alert.addAction(UIAlertAction(title: "知道了", style: .default) { [weak self] _ in self?.viewModel.dismissResultNotice() })
|
|
}
|
|
present(alert, animated: true)
|
|
}
|
|
|
|
private func requestMaterials() {
|
|
guard let order = viewModel.order else { return }
|
|
if let delegate {
|
|
delegate.shootingTaskViewController(self, didRequestMaterialsFor: order)
|
|
} else {
|
|
showAlert(title: "素材库", message: "本地界面预览:素材入口将在后续接入。")
|
|
}
|
|
}
|
|
|
|
@objc private func materialsTapped() { requestMaterials() }
|
|
|
|
@objc private func backTapped() {
|
|
if let delegate {
|
|
delegate.shootingTaskViewControllerDidRequestWorkbench(self)
|
|
} else if let workbench = navigationController?.viewControllers.first(where: { $0 is DroneDockWorkbenchViewController }) {
|
|
navigationController?.popToViewController(workbench, animated: true)
|
|
} else {
|
|
navigationController?.popToRootViewController(animated: true)
|
|
}
|
|
}
|
|
|
|
@objc private func primaryTapped() {
|
|
guard viewModel.primaryEnabled else { return }
|
|
switch viewModel.primaryAction {
|
|
case .start: _ = viewModel.startShooting()
|
|
case .resume: _ = viewModel.resume()
|
|
case .viewMaterials: requestMaterials()
|
|
case .prepareAgain: preparationTapped()
|
|
case .none: break
|
|
}
|
|
applySnapshot()
|
|
}
|
|
|
|
@objc private func preparationTapped() {
|
|
guard let order = viewModel.order, order.remainingShootingCount > 0, viewModel.session?.isFlightFinished == true else { return }
|
|
delegate?.shootingTaskViewController(self, didRequestPreparationFor: order)
|
|
}
|
|
|
|
@objc private func pauseTapped() {
|
|
guard viewModel.canPause else { return }
|
|
_ = viewModel.pause()
|
|
applySnapshot()
|
|
}
|
|
|
|
@objc private func returnTapped() {
|
|
guard viewModel.canReturn else { return }
|
|
_ = viewModel.requestReturn()
|
|
applySnapshot()
|
|
}
|
|
|
|
@objc private func refreshTaskTapped() {
|
|
viewModel.refreshTaskStatus()
|
|
applySnapshot()
|
|
presentResultNoticeIfNeeded()
|
|
}
|
|
}
|