feat: 完善机巢模拟调试与素材交付交互
增加禁飞期间的设备指令拦截及本地模拟拍摄流程;适配订单素材库和景区空境库,完善素材筛选、预览与下载;订单交付入口改为方式选择弹窗并复用云端上传。补充单元测试、接口记录和模拟器截图。
This commit is contained in:
@@ -83,7 +83,7 @@ final class DroneMaterialsViewController: BaseViewController {
|
||||
}
|
||||
|
||||
override func setupNavigationBar() {
|
||||
title = "订单素材库"
|
||||
title = "订单素材库 · 演示"
|
||||
navigationItem.backButtonDisplayMode = .minimal
|
||||
let back = UIBarButtonItem(image: UIImage(systemName: "chevron.left"), style: .plain,
|
||||
target: self, action: #selector(backTapped))
|
||||
@@ -170,6 +170,10 @@ final class DroneMaterialsViewController: BaseViewController {
|
||||
footerView.onPrimaryTap = { [weak self] in self?.performFooterAction() }
|
||||
footerView.onSecondaryTap = { [weak self] in
|
||||
guard let self else { return }
|
||||
if self.viewModel.downloadPhase == .completed {
|
||||
self.chooseCompletedDelivery()
|
||||
return
|
||||
}
|
||||
self.viewModel.clearBatch()
|
||||
self.applySnapshot(animated: true)
|
||||
}
|
||||
@@ -373,37 +377,41 @@ final class DroneMaterialsViewController: BaseViewController {
|
||||
footerAction = .permission
|
||||
footerView.apply(title: "无法保存到手机相册", detail: "演示相册权限未开启,恢复后请手动继续。",
|
||||
primaryTitle: "检查相册权限", primarySymbol: "lock", enabled: true,
|
||||
identifier: "drone.materials.permission", progress: nil, tone: .orange)
|
||||
identifier: "drone.materials.permission", progress: nil, tone: .blue, resultSymbol: "lock")
|
||||
return
|
||||
}
|
||||
switch viewModel.downloadPhase {
|
||||
case .idle:
|
||||
footerAction = .download
|
||||
footerView.apply(title: "已选择\(viewModel.selectedCount)项", detail: "仅可选择已上传素材 · 本次为本地演示",
|
||||
footerView.apply(title: "已选择\(viewModel.selectedCount)项", detail: "",
|
||||
primaryTitle: "下载所选素材", primarySymbol: "arrow.down.to.line", enabled: viewModel.canStartDownload,
|
||||
identifier: "drone.materials.download", progress: nil)
|
||||
identifier: "drone.materials.download", progress: nil, trailingText: "仅可选择已上传素材")
|
||||
case .downloading, .awaitingSave, .saving:
|
||||
footerAction = .none
|
||||
footerView.apply(title: "本次下载\(viewModel.batchTotalCount)项 · 已完成\(viewModel.completedCount)/\(viewModel.batchTotalCount)项",
|
||||
footerView.apply(title: "本次下载\(viewModel.batchTotalCount)项",
|
||||
detail: "请保持本页开启,下载期间不可更改选择",
|
||||
primaryTitle: viewModel.downloadButtonTitle, primarySymbol: "arrow.triangle.2.circlepath", enabled: false,
|
||||
identifier: "drone.materials.download", progress: viewModel.batchProgress, tone: .blue)
|
||||
identifier: "drone.materials.download", progress: viewModel.batchProgress, tone: .blue,
|
||||
trailingText: "已完成\(viewModel.completedCount)/\(viewModel.batchTotalCount)项")
|
||||
case .paused:
|
||||
footerAction = .resume
|
||||
footerView.apply(title: "下载已暂停 · 已完成\(viewModel.completedCount)/\(viewModel.batchTotalCount)项",
|
||||
footerView.apply(title: "下载已暂停",
|
||||
detail: "已完成项会保留;继续时仅处理未完成文件。",
|
||||
primaryTitle: "继续下载", primarySymbol: "play.fill", enabled: true,
|
||||
identifier: "drone.materials.continue", progress: viewModel.batchProgress, tone: .orange)
|
||||
identifier: "drone.materials.continue", progress: viewModel.batchProgress, tone: .orange,
|
||||
trailingText: "已完成\(viewModel.completedCount)/\(viewModel.batchTotalCount)项", resultSymbol: "pause.circle")
|
||||
case .partialFailure:
|
||||
footerAction = .retry
|
||||
footerView.apply(title: "部分素材下载失败", detail: "演示完成\(viewModel.completedCount)项 · 失败\(viewModel.failedCount)项,重试仅处理失败项",
|
||||
footerView.apply(title: "部分素材下载失败", detail: "演示成功\(viewModel.completedCount)项 · 失败\(viewModel.failedCount)项,已完成的无需重复下载",
|
||||
primaryTitle: "重试失败素材(\(viewModel.failedCount))", primarySymbol: "arrow.clockwise", enabled: viewModel.failedCount > 0,
|
||||
identifier: "drone.materials.retry", progress: nil, secondaryTitle: "选择其他素材", tone: .orange)
|
||||
identifier: "drone.materials.retry", progress: nil, secondaryTitle: "选择其他素材", tone: .orange,
|
||||
resultSymbol: "exclamationmark.triangle")
|
||||
case .completed:
|
||||
footerAction = .selectMore
|
||||
footerView.apply(title: "本次素材演示完成", detail: "\(viewModel.completedCount)项演示完成,未写入系统相册",
|
||||
primaryTitle: "继续选择素材", primarySymbol: "checkmark.circle", enabled: true,
|
||||
identifier: "drone.materials.continueSelecting", progress: nil, tone: .green)
|
||||
footerView.apply(title: "本次素材下载完成(演示)", detail: "\(viewModel.completedCount)项演示完成,未写入系统相册",
|
||||
primaryTitle: "继续选择素材", primarySymbol: "", enabled: true,
|
||||
identifier: "drone.materials.continueSelecting", progress: nil, secondaryTitle: "交付成片", tone: .green,
|
||||
resultSymbol: "checkmark.circle", secondaryOutlined: true, secondaryEnabled: delegate != nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +427,7 @@ final class DroneMaterialsViewController: BaseViewController {
|
||||
case .selectMore:
|
||||
viewModel.clearBatch()
|
||||
case .permission:
|
||||
showAlert(title: "相册权限演示", message: "当前为本地演示,不读取或修改系统相册权限。可在右上角演示状态中选择“模拟相册权限恢复”,再手动继续下载。")
|
||||
showPermissionSimulation()
|
||||
case .none:
|
||||
return
|
||||
}
|
||||
@@ -432,6 +440,37 @@ final class DroneMaterialsViewController: BaseViewController {
|
||||
transferDriver.start(viewModel: viewModel) { [weak self] in self?.applySnapshot(animated: true) }
|
||||
}
|
||||
|
||||
/// 权限说明与恢复只作用于演示状态,不打开系统设置或请求真实 Photos 授权。
|
||||
private func showPermissionSimulation() {
|
||||
let alert = UIAlertController(title: "无法保存到手机相册",
|
||||
message: "相册权限未开启。当前为本地演示,不读取或修改系统相册权限;模拟恢复后请手动继续下载。", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "暂不下载", style: .cancel))
|
||||
alert.addAction(UIAlertAction(title: "模拟恢复权限", style: .default) { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.viewModel.setPhotoPermission(.allowed)
|
||||
self.applySnapshot(animated: true)
|
||||
})
|
||||
present(alert, animated: true)
|
||||
}
|
||||
|
||||
/// 完成底栏的交付入口先明确拍摄记录,不根据下载批次猜测目标点位。
|
||||
private func chooseCompletedDelivery() {
|
||||
guard delegate != nil, !viewModel.sections.isEmpty else { return }
|
||||
if viewModel.sections.count == 1, let record = viewModel.sections.first {
|
||||
delegate?.materialsViewController(self, didRequestDelivery: record)
|
||||
return
|
||||
}
|
||||
let sheet = UIAlertController(title: "选择拍摄记录", message: "选择需要交付成片的拍摄记录", preferredStyle: .actionSheet)
|
||||
for record in viewModel.sections {
|
||||
sheet.addAction(UIAlertAction(title: "\(record.pointName) · 记录\(record.sequenceNumber)", style: .default) { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.delegate?.materialsViewController(self, didRequestDelivery: record)
|
||||
})
|
||||
}
|
||||
sheet.addAction(UIAlertAction(title: "取消", style: .cancel))
|
||||
present(sheet, animated: true)
|
||||
}
|
||||
|
||||
private func updateInteractivePopGesture() {
|
||||
guard let gesture = navigationController?.interactivePopGestureRecognizer else { return }
|
||||
if hasRunningDownload {
|
||||
|
||||
Reference in New Issue
Block a user