feat(drone-dock): 对接我的拍摄订单筛选与分页

This commit is contained in:
2026-10-28 17:38:48 +08:00
parent 2793f6b113
commit 06460fe7e6
17 changed files with 1827 additions and 34 deletions
@@ -190,6 +190,7 @@ final class DroneDockHomeViewController: BaseViewController {
let header = collection.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: path) as! DroneDockHomeHeader
let isOrders = Section(rawValue: path.section) == .orders
let orderTitle = self.viewModel.orderTotal.map { "我的拍摄订单(\($0))" } ?? "我的拍摄订单"
header.onViewAll = isOrders ? { [weak self] in self?.openAllOrders() } : nil
header.apply(title: isOrders ? orderTitle : "今日统计", isOrders: isOrders)
return header
}
@@ -289,6 +290,23 @@ final class DroneDockHomeViewController: BaseViewController {
showAlert(title: feature, message: "该功能暂未开放")
}
private func openAllOrders() {
let controller = DroneDockOrdersViewController(
viewModel: viewModel.makeOrdersViewModel(), preparationControllerFactory: preparationFactory)
navigationController?.pushViewController(controller, animated: true)
}
/// 首页和全部订单页沿用同一真实拍摄准备入口。
private var preparationFactory: (DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController {
preparationControllerFactory ?? { order, context in
DroneDockRemotePreparationViewController(viewModel: DroneDockPreparationViewModel(
context: context, order: order,
service: DroneDockPreparationAPI(client: NetworkServices.shared.apiClient),
currentContext: { Self.currentContext() }
))
}
}
private func openPreparation(orderID: String) {
guard !isRefreshing, let order = viewModel.orders.first(where: { $0.orderID == orderID }) else { return }
guard order.primaryAction == "start_shoot" else {
@@ -300,12 +318,7 @@ final class DroneDockHomeViewController: BaseViewController {
return
}
let context = viewModel.context
let controller = preparationControllerFactory?(order, context) ?? DroneDockRemotePreparationViewController(
viewModel: DroneDockPreparationViewModel(
context: context, order: order,
service: DroneDockPreparationAPI(client: NetworkServices.shared.apiClient),
currentContext: { Self.currentContext() }
))
let controller = preparationFactory(order, context)
navigationController?.pushViewController(controller, animated: true)
}
@@ -467,12 +480,31 @@ private final class DroneDockHomeContentCell: UICollectionViewCell {
/// 首页分区标题,订单数量使用接口 total,不使用当前页条数。
private final class DroneDockHomeHeader: UICollectionReusableView {
/// 用户请求打开当前景区的全部真实拍摄订单。
var onViewAll: (() -> Void)?
private let label = DroneDockStyle.label(size: 17, weight: .semibold)
private let viewAllButton = UIButton(type: .system)
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(label)
label.snp.makeConstraints { $0.leading.trailing.centerY.equalToSuperview() }
viewAllButton.setTitle("查看全部 ›", for: .normal)
viewAllButton.titleLabel?.font = .systemFont(ofSize: 13)
viewAllButton.tintColor = DroneDockStyle.primary
viewAllButton.accessibilityIdentifier = "drone.home.allOrders"
viewAllButton.addTarget(self, action: #selector(viewAllTapped), for: .touchUpInside)
addSubview(viewAllButton)
viewAllButton.setContentCompressionResistancePriority(.required, for: .horizontal)
label.adjustsFontSizeToFitWidth = true
label.minimumScaleFactor = 0.75
label.snp.makeConstraints { make in
make.leading.centerY.equalToSuperview()
make.trailing.lessThanOrEqualTo(viewAllButton.snp.leading).offset(-8)
}
viewAllButton.snp.makeConstraints { make in
make.trailing.centerY.equalToSuperview()
make.height.equalTo(44)
}
}
@available(*, unavailable)
@@ -482,5 +514,13 @@ private final class DroneDockHomeHeader: UICollectionReusableView {
func apply(title: String, isOrders: Bool) {
label.text = title
label.accessibilityIdentifier = isOrders ? "drone.home.orderCount" : nil
viewAllButton.isHidden = !isOrders
}
override func prepareForReuse() {
super.prepareForReuse()
onViewAll = nil
}
@objc private func viewAllTapped() { onViewAll?() }
}