import SnapKit import UIKit /// 与任务原型一致的录制完成提示;只引导查看素材,不宣告上传成功或扣减次数。 @MainActor final class DroneDockRecordingCompletionView: UIView { /// 关闭提示并继续留在任务页。 var onLater: (() -> Void)? /// 前往当前订单素材库。 var onViewMaterials: (() -> Void)? /// 创建居中结果卡片,覆盖任务页但不触发生命周期或暂停只读状态更新。 override init(frame: CGRect) { super.init(frame: frame) setupUI() } @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func setupUI() { backgroundColor = .black.withAlphaComponent(0.5) accessibilityViewIsModal = true accessibilityIdentifier = "drone.task.recordingCompletion" let card = UIView() card.backgroundColor = .white card.layer.cornerRadius = 14 addSubview(card) let symbol = UIImageView(image: UIImage(systemName: "checkmark.circle.fill")) symbol.tintColor = DroneDockStyle.success symbol.contentMode = .scaleAspectFit let title = DroneDockStyle.label(size: 20, weight: .semibold) title.text = "拍摄已完成" title.textAlignment = .center let message = DroneDockStyle.label(size: 14, color: DroneDockStyle.secondary) message.text = "本次拍摄已完成,\n可前往订单素材库查看上传进度和素材。" message.numberOfLines = 0 message.textAlignment = .center let later = button("稍后再去", primary: false, action: #selector(laterTapped)) let materials = button("去查看", primary: true, action: #selector(materialsTapped)) later.accessibilityIdentifier = "drone.task.recordingCompletion.later" materials.accessibilityIdentifier = "drone.task.recordingCompletion.materials" let actions = UIStackView(arrangedSubviews: [later, materials]) actions.spacing = 10 actions.distribution = .fillEqually [symbol, title, message, actions].forEach { card.addSubview($0) } card.snp.makeConstraints { make in make.center.equalToSuperview() make.width.equalTo(320).priority(.high) make.leading.greaterThanOrEqualToSuperview().offset(24) make.trailing.lessThanOrEqualToSuperview().offset(-24) } symbol.snp.makeConstraints { make in make.top.equalToSuperview().offset(24) make.centerX.equalToSuperview() make.size.equalTo(50) } title.snp.makeConstraints { make in make.top.equalTo(symbol.snp.bottom).offset(16) make.leading.trailing.equalToSuperview().inset(20) } message.snp.makeConstraints { make in make.top.equalTo(title.snp.bottom).offset(12) make.leading.trailing.equalToSuperview().inset(20) } actions.snp.makeConstraints { make in make.top.equalTo(message.snp.bottom).offset(24) make.leading.trailing.bottom.equalToSuperview().inset(16) make.height.equalTo(46) } } private func button(_ title: String, primary: Bool, action: Selector) -> UIButton { let button = UIButton(type: .system) button.setTitle(title, for: .normal) button.setTitleColor(primary ? .white : DroneDockStyle.text, for: .normal) button.titleLabel?.font = .systemFont(ofSize: 15, weight: .semibold) button.backgroundColor = primary ? DroneDockStyle.primary : UIColor(hex: 0xEEF0F6) button.layer.cornerRadius = 7 button.addTarget(self, action: action, for: .touchUpInside) return button } @objc private func laterTapped() { onLater?() } @objc private func materialsTapped() { onViewMaterials?() } }