feat: 完善机巢模拟调试与素材交付交互
增加禁飞期间的设备指令拦截及本地模拟拍摄流程;适配订单素材库和景区空境库,完善素材筛选、预览与下载;订单交付入口改为方式选择弹窗并复用云端上传。补充单元测试、接口记录和模拟器截图。
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import Kingfisher
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 景区素材模块的局部样式,可独立于机巢业务使用。
|
||||
@MainActor
|
||||
enum ScenicMaterialsStyle {
|
||||
static let primary = UIColor(hex: 0x3164FF)
|
||||
static let primary = UIColor(hex: 0x066BFF)
|
||||
static let background = UIColor.white
|
||||
static let text = UIColor(hex: 0x20242C)
|
||||
static let secondary = UIColor(hex: 0x9297A1)
|
||||
static let border = UIColor(hex: 0xECEEF2)
|
||||
static let text = UIColor(hex: 0x151515)
|
||||
static let secondary = UIColor(hex: 0x8490A5)
|
||||
static let border = UIColor(hex: 0xE7E9EF)
|
||||
static let success = UIColor(hex: 0x17986A)
|
||||
static let warning = UIColor(hex: 0xD98926)
|
||||
|
||||
@@ -79,8 +80,11 @@ final class ScenicMaterialClipCell: UICollectionViewCell {
|
||||
/// 显示片段及本机演示传输状态;首段大图额外显示分辨率和体积。
|
||||
func configure(clip: ScenicMaterialClip, selected: Bool, isSelectionEnabled: Bool,
|
||||
statusText: String? = nil, progress: Double? = nil, isHero: Bool = false) {
|
||||
cover.image = UIImage(named: clip.coverAssetName)
|
||||
ordinalLabel.text = String(format: "片段 %02d", clip.ordinal)
|
||||
cover.kf.cancelDownloadTask()
|
||||
if clip.isRemote {
|
||||
cover.kf.setImage(with: clip.coverURL, placeholder: UIImage(systemName: "photo"))
|
||||
} else { cover.image = UIImage(named: clip.coverAssetName) }
|
||||
ordinalLabel.text = clip.fileLabel ?? String(format: "片段 %02d", clip.ordinal)
|
||||
metadataLabel.text = isHero ? "\(clip.durationText) · \(clip.resolution) · \(clip.sizeText)" : clip.durationText
|
||||
metadataLabel.font = .monospacedDigitSystemFont(ofSize: isHero ? 11 : 10, weight: .regular)
|
||||
selectionButton.setImage(UIImage(systemName: selected ? "checkmark.circle.fill" : "circle",
|
||||
@@ -269,27 +273,46 @@ final class ScenicMaterialExpandCell: UICollectionViewCell {
|
||||
@objc private func tapped() { onToggleExpanded?() }
|
||||
}
|
||||
|
||||
/// 固定底部的选择/下载摘要,不直接持有 ViewModel 或执行文件操作。
|
||||
/// 固定底部的选择/下载摘要,由页面显式传入布局和状态,不执行文件操作。
|
||||
@MainActor
|
||||
final class ScenicMaterialsFooterView: UIView {
|
||||
/// 选择态左右排列;传输态显示摘要、进度和通栏按钮;结果态显示摘要和操作行。
|
||||
enum Layout { case selection, progress, result }
|
||||
|
||||
/// 当前阶段的主要操作,例如下载、继续或重试。
|
||||
var onPrimaryTap: (() -> Void)?
|
||||
/// 当前阶段的次要操作,例如取消或继续选择。
|
||||
var onSecondaryTap: (() -> Void)?
|
||||
private let titleLabel = ScenicMaterialsStyle.label(size: 14, weight: .medium)
|
||||
private let detailLabel = ScenicMaterialsStyle.label(size: 10, color: ScenicMaterialsStyle.secondary)
|
||||
private let titleLabel = ScenicMaterialsStyle.label(size: 14)
|
||||
private let detailLabel = ScenicMaterialsStyle.label(size: 11, color: ScenicMaterialsStyle.secondary)
|
||||
private let primaryButton = UIButton(type: .custom)
|
||||
private let secondaryButton = UIButton(type: .custom)
|
||||
private let progressView = UIProgressView(progressViewStyle: .bar)
|
||||
private let activity = UIActivityIndicatorView(style: .medium)
|
||||
private let summaryRow = UIStackView()
|
||||
private let actionRow = UIStackView()
|
||||
private let stack = UIStackView()
|
||||
private var currentLayout: Layout?
|
||||
private var hasSecondaryAction = false
|
||||
|
||||
/// 创建随安全区延伸的白色底栏。
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setupUI()
|
||||
setupConstraints()
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
private func setupUI() {
|
||||
backgroundColor = .white
|
||||
titleLabel.numberOfLines = 2
|
||||
titleLabel.accessibilityIdentifier = "scenic.materials.footer.title"
|
||||
detailLabel.numberOfLines = 2
|
||||
primaryButton.titleLabel?.font = .systemFont(ofSize: 14, weight: .semibold)
|
||||
primaryButton.titleLabel?.numberOfLines = 2
|
||||
detailLabel.accessibilityIdentifier = "scenic.materials.footer.detail"
|
||||
primaryButton.titleLabel?.font = .systemFont(ofSize: 15, weight: .semibold)
|
||||
primaryButton.titleLabel?.numberOfLines = 1
|
||||
primaryButton.titleLabel?.textAlignment = .center
|
||||
primaryButton.setTitleColor(.white, for: .normal)
|
||||
primaryButton.setTitleColor(.white, for: .disabled)
|
||||
@@ -297,64 +320,137 @@ final class ScenicMaterialsFooterView: UIView {
|
||||
primaryButton.clipsToBounds = true
|
||||
primaryButton.accessibilityIdentifier = "scenic.materials.primary"
|
||||
primaryButton.addTarget(self, action: #selector(primaryTapped), for: .touchUpInside)
|
||||
secondaryButton.tintColor = ScenicMaterialsStyle.primary
|
||||
secondaryButton.setTitleColor(ScenicMaterialsStyle.primary, for: .normal)
|
||||
secondaryButton.titleLabel?.font = .systemFont(ofSize: 13)
|
||||
secondaryButton.setTitleColor(ScenicMaterialsStyle.secondary, for: .normal)
|
||||
secondaryButton.titleLabel?.font = .systemFont(ofSize: 15)
|
||||
secondaryButton.titleLabel?.numberOfLines = 1
|
||||
secondaryButton.titleLabel?.textAlignment = .center
|
||||
secondaryButton.layer.cornerRadius = 10
|
||||
secondaryButton.accessibilityIdentifier = "scenic.materials.secondary"
|
||||
secondaryButton.addTarget(self, action: #selector(secondaryTapped), for: .touchUpInside)
|
||||
progressView.progressTintColor = ScenicMaterialsStyle.primary
|
||||
progressView.trackTintColor = ScenicMaterialsStyle.border
|
||||
let labels = UIStackView(arrangedSubviews: [titleLabel, detailLabel])
|
||||
labels.axis = .vertical
|
||||
labels.spacing = 5
|
||||
let row = UIStackView(arrangedSubviews: [labels, primaryButton])
|
||||
row.axis = .horizontal
|
||||
row.spacing = 12
|
||||
row.alignment = .center
|
||||
let stack = UIStackView(arrangedSubviews: [row, progressView, secondaryButton])
|
||||
progressView.trackTintColor = UIColor(hex: 0xE7EDF7)
|
||||
progressView.accessibilityIdentifier = "scenic.materials.footer.progress"
|
||||
activity.color = .white
|
||||
activity.hidesWhenStopped = true
|
||||
activity.isUserInteractionEnabled = false
|
||||
activity.accessibilityIdentifier = "scenic.materials.footer.activity"
|
||||
primaryButton.addSubview(activity)
|
||||
summaryRow.axis = .horizontal
|
||||
summaryRow.alignment = .center
|
||||
summaryRow.spacing = 8
|
||||
actionRow.axis = .horizontal
|
||||
actionRow.alignment = .center
|
||||
actionRow.spacing = 16
|
||||
stack.axis = .vertical
|
||||
stack.spacing = 10
|
||||
let separator = UIView()
|
||||
separator.backgroundColor = ScenicMaterialsStyle.border
|
||||
addSubview(separator)
|
||||
stack.spacing = 8
|
||||
addSubview(stack)
|
||||
separator.snp.makeConstraints { $0.top.leading.trailing.equalToSuperview(); $0.height.equalTo(0.5) }
|
||||
stack.snp.makeConstraints {
|
||||
$0.top.equalToSuperview().offset(14)
|
||||
$0.leading.trailing.equalToSuperview().inset(20)
|
||||
$0.bottom.equalTo(safeAreaLayoutGuide).inset(12)
|
||||
}
|
||||
primaryButton.snp.makeConstraints { $0.width.equalTo(158); $0.height.equalTo(46) }
|
||||
progressView.snp.makeConstraints { $0.height.equalTo(3).priority(999) }
|
||||
secondaryButton.snp.makeConstraints { $0.height.equalTo(32).priority(999) }
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
private func setupConstraints() {
|
||||
stack.snp.makeConstraints {
|
||||
$0.top.equalToSuperview().offset(14)
|
||||
$0.leading.trailing.equalToSuperview().inset(18)
|
||||
$0.bottom.equalTo(safeAreaLayoutGuide).inset(14)
|
||||
}
|
||||
primaryButton.snp.makeConstraints { $0.height.equalTo(46) }
|
||||
progressView.snp.makeConstraints { $0.height.equalTo(3).priority(999) }
|
||||
activity.snp.makeConstraints {
|
||||
$0.centerY.equalToSuperview()
|
||||
$0.centerX.equalToSuperview()
|
||||
$0.size.equalTo(18)
|
||||
}
|
||||
}
|
||||
|
||||
/// 由当前页面状态显式刷新底栏,始终保留禁用按钮的可读标题。
|
||||
/// 按产品页面的状态布局刷新底栏,忙碌按钮保持蓝色但不可重复触发。
|
||||
func configure(title: String, detail: String?, primaryTitle: String, primaryEnabled: Bool,
|
||||
secondaryTitle: String? = nil, progress: Float? = nil) {
|
||||
secondaryTitle: String? = nil, progress: Float? = nil,
|
||||
layout: Layout = .selection, isBusy: Bool = false) {
|
||||
UIView.performWithoutAnimation {
|
||||
if currentLayout != layout || hasSecondaryAction != (secondaryTitle != nil) {
|
||||
arrange(layout, hasSecondary: secondaryTitle != nil)
|
||||
}
|
||||
titleLabel.attributedText = nil
|
||||
titleLabel.text = title
|
||||
if layout == .selection, let range = title.range(of: #"\d+"#, options: .regularExpression) {
|
||||
let attributed = NSMutableAttributedString(string: title)
|
||||
attributed.addAttributes([.foregroundColor: ScenicMaterialsStyle.primary,
|
||||
.font: UIFont.systemFont(ofSize: 20, weight: .bold)],
|
||||
range: NSRange(range, in: title))
|
||||
titleLabel.attributedText = attributed
|
||||
}
|
||||
detailLabel.text = detail
|
||||
detailLabel.isHidden = detail == nil
|
||||
if primaryButton.title(for: .normal) != primaryTitle {
|
||||
primaryButton.setTitle(primaryTitle, for: .normal)
|
||||
primaryButton.setTitle(primaryTitle, for: .disabled)
|
||||
}
|
||||
primaryButton.backgroundColor = primaryEnabled ? ScenicMaterialsStyle.primary : ScenicMaterialsStyle.primary.withAlphaComponent(0.25)
|
||||
detailLabel.isHidden = detail == nil || layout == .progress
|
||||
primaryButton.accessibilityHint = detail
|
||||
primaryButton.setTitle(primaryTitle, for: .normal)
|
||||
primaryButton.setTitle(primaryTitle, for: .disabled)
|
||||
let titleFont = primaryButton.titleLabel?.font ?? .systemFont(ofSize: 15, weight: .semibold)
|
||||
let titleWidth = ceil(primaryTitle.size(withAttributes: [.font: titleFont]).width) + 2
|
||||
activity.snp.updateConstraints { $0.centerX.equalToSuperview().offset(-titleWidth / 2 - 4) }
|
||||
primaryButton.backgroundColor = primaryEnabled || isBusy ? ScenicMaterialsStyle.primary : UIColor(hex: 0xCDDFFF)
|
||||
primaryButton.isEnabled = primaryEnabled
|
||||
if secondaryButton.title(for: .normal) != secondaryTitle {
|
||||
secondaryButton.setTitle(secondaryTitle, for: .normal)
|
||||
}
|
||||
secondaryButton.setTitle(secondaryTitle, for: .normal)
|
||||
secondaryButton.isHidden = secondaryTitle == nil
|
||||
secondaryButton.isEnabled = secondaryTitle != nil
|
||||
progressView.isHidden = progress == nil
|
||||
progressView.progress = min(max(progress ?? 0, 0), 1)
|
||||
if isBusy { activity.startAnimating() } else { activity.stopAnimating() }
|
||||
layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func primaryTapped() { onPrimaryTap?() }
|
||||
@objc private func secondaryTapped() { onSecondaryTap?() }
|
||||
private func arrange(_ layout: Layout, hasSecondary: Bool) {
|
||||
for container in [stack, summaryRow, actionRow] {
|
||||
container.arrangedSubviews.forEach { container.removeArrangedSubview($0); $0.removeFromSuperview() }
|
||||
}
|
||||
titleLabel.snp.removeConstraints()
|
||||
detailLabel.snp.removeConstraints()
|
||||
secondaryButton.snp.removeConstraints()
|
||||
actionRow.distribution = .fill
|
||||
titleLabel.font = .systemFont(ofSize: layout == .selection ? 17 : 12)
|
||||
detailLabel.textAlignment = layout == .selection ? .left : .right
|
||||
secondaryButton.backgroundColor = layout == .result ? UIColor(hex: 0xF2F4F7) : .clear
|
||||
secondaryButton.titleLabel?.font = .systemFont(ofSize: layout == .progress ? 12 : 15)
|
||||
switch layout {
|
||||
case .selection:
|
||||
actionRow.addArrangedSubview(titleLabel)
|
||||
actionRow.addArrangedSubview(primaryButton)
|
||||
titleLabel.snp.makeConstraints { $0.width.equalTo(126).priority(999) }
|
||||
stack.addArrangedSubview(actionRow)
|
||||
stack.addArrangedSubview(detailLabel)
|
||||
case .progress:
|
||||
summaryRow.addArrangedSubview(titleLabel)
|
||||
if hasSecondary {
|
||||
summaryRow.addArrangedSubview(secondaryButton)
|
||||
secondaryButton.snp.makeConstraints { $0.width.equalTo(44); $0.height.equalTo(28) }
|
||||
}
|
||||
actionRow.addArrangedSubview(primaryButton)
|
||||
stack.addArrangedSubview(summaryRow)
|
||||
stack.addArrangedSubview(progressView)
|
||||
stack.addArrangedSubview(actionRow)
|
||||
case .result:
|
||||
summaryRow.addArrangedSubview(titleLabel)
|
||||
summaryRow.addArrangedSubview(detailLabel)
|
||||
titleLabel.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
|
||||
detailLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||
if hasSecondary {
|
||||
actionRow.addArrangedSubview(secondaryButton)
|
||||
secondaryButton.snp.makeConstraints { $0.height.equalTo(46) }
|
||||
actionRow.distribution = .fillEqually
|
||||
}
|
||||
actionRow.addArrangedSubview(primaryButton)
|
||||
stack.addArrangedSubview(summaryRow)
|
||||
stack.addArrangedSubview(actionRow)
|
||||
}
|
||||
currentLayout = layout
|
||||
hasSecondaryAction = hasSecondary
|
||||
}
|
||||
|
||||
@objc private func primaryTapped() {
|
||||
guard primaryButton.isEnabled else { return }
|
||||
onPrimaryTap?()
|
||||
}
|
||||
@objc private func secondaryTapped() {
|
||||
guard secondaryButton.isEnabled, !secondaryButton.isHidden else { return }
|
||||
onSecondaryTap?()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user