增加禁飞期间的设备指令拦截及本地模拟拍摄流程;适配订单素材库和景区空境库,完善素材筛选、预览与下载;订单交付入口改为方式选择弹窗并复用云端上传。补充单元测试、接口记录和模拟器截图。
74 lines
3.6 KiB
Swift
74 lines
3.6 KiB
Swift
import UIKit
|
|
|
|
/// 订单列表与素材库共用的真实成片交付页面工厂。
|
|
@MainActor
|
|
enum DroneDockDeliveryEntry {
|
|
/// 订单列表先展示方式选择,云端页面在同一弹窗内继续,关闭后再通知列表刷新。
|
|
static func makeMethodSheet(order: DroneDockHomeOrder, context: DroneDockHomeContext,
|
|
controllerFactory: @escaping (DroneDockHomeOrder, DroneDockHomeContext, Int?) -> UIViewController,
|
|
onDidCloseCloud: @escaping () -> Void = {}) -> UINavigationController {
|
|
let methods = DroneDockDeliveryMethodViewController(customerTitle: order.touristTitle)
|
|
let navigation = DroneDockDeliverySheetNavigationController(rootViewController: methods)
|
|
navigation.modalPresentationStyle = .pageSheet
|
|
navigation.onDidCloseCloud = onDidCloseCloud
|
|
methods.onClose = { [weak navigation] in navigation?.dismiss(animated: true) }
|
|
methods.onCloudUpload = { [weak navigation, weak methods] in
|
|
guard let navigation, let methods, navigation.topViewController === methods else { return }
|
|
let cloud = controllerFactory(order, context, nil)
|
|
if let cloud = cloud as? DroneDockDeliveryViewController {
|
|
cloud.configureSheetPresentation { [weak navigation] in navigation?.dismiss(animated: true) }
|
|
}
|
|
navigation.didOpenCloud = true
|
|
navigation.isModalInPresentation = true
|
|
navigation.sheetPresentationController?.animateChanges {
|
|
navigation.sheetPresentationController?.detents = [.large()]
|
|
navigation.sheetPresentationController?.selectedDetentIdentifier = .large
|
|
}
|
|
navigation.setNavigationBarHidden(false, animated: true)
|
|
navigation.pushViewController(cloud, animated: true)
|
|
}
|
|
return navigation
|
|
}
|
|
|
|
/// 同时传递订单与可选任务,进入页面后重新校验当前身份和上传权限。
|
|
static func makeController(order: DroneDockHomeOrder, context: DroneDockHomeContext, taskID: Int?) -> UIViewController {
|
|
let client = NetworkServices.shared.apiClient
|
|
return DroneDockDeliveryViewController(viewModel: DroneDockDeliveryViewModel(
|
|
context: context, order: order,
|
|
service: DroneDockDeliveryAPI(client: client),
|
|
uploader: DroneDockFilmUploader(configService: UploadAPI(client: client)),
|
|
initialTaskID: taskID,
|
|
currentContext: { DroneDockHomeViewController.currentContext() }
|
|
))
|
|
}
|
|
}
|
|
|
|
/// 统一处理手动关闭与下拉关闭,云端交付结束后只通知来源列表一次。
|
|
@MainActor
|
|
private final class DroneDockDeliverySheetNavigationController: UINavigationController, UIAdaptivePresentationControllerDelegate {
|
|
/// 云端页面已经进入,关闭弹窗后需要重读订单状态。
|
|
var didOpenCloud = false
|
|
/// 不因仅查看交付方式而刷新订单。
|
|
var onDidCloseCloud: (() -> Void)?
|
|
private var didNotifyClose = false
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
presentationController?.delegate = self
|
|
}
|
|
|
|
override func viewDidDisappear(_ animated: Bool) {
|
|
super.viewDidDisappear(animated)
|
|
if isBeingDismissed || presentingViewController == nil { notifyClose() }
|
|
}
|
|
|
|
/// 系统下拉关闭与按钮关闭使用同一去重通知。
|
|
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { notifyClose() }
|
|
|
|
private func notifyClose() {
|
|
guard !didNotifyClose else { return }
|
|
didNotifyClose = true
|
|
if didOpenCloud { onDidCloseCloud?() }
|
|
}
|
|
}
|