Implement orders tab aligned with Android, including scan verify flows.
Add role-based order/deposit lists, AVFoundation QR scanning, verify dialogs, and ViewModel tests so photographers, scenic admins, and store admins match Android behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
73
suixinkan/UI/Orders/OrderListView.swift
Normal file
73
suixinkan/UI/Orders/OrderListView.swift
Normal file
@ -0,0 +1,73 @@
|
||||
//
|
||||
// OrderListView.swift
|
||||
// suixinkan
|
||||
//
|
||||
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 订单列表容器,含下拉刷新与分页。
|
||||
final class OrderListView: UIView {
|
||||
|
||||
enum Mode {
|
||||
case photographer
|
||||
case store
|
||||
}
|
||||
|
||||
var onRefresh: (() -> Void)?
|
||||
var onLoadMore: ((Int) -> Void)?
|
||||
|
||||
let tableView = UITableView(frame: .zero, style: .plain)
|
||||
private let refreshControl = UIRefreshControl()
|
||||
private let footerLabel = UILabel()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
backgroundColor = UIColor(hex: 0xF5F5F5)
|
||||
tableView.backgroundColor = .clear
|
||||
tableView.separatorStyle = .none
|
||||
tableView.keyboardDismissMode = .onDrag
|
||||
tableView.refreshControl = refreshControl
|
||||
refreshControl.addTarget(self, action: #selector(refreshTriggered), for: .valueChanged)
|
||||
|
||||
footerLabel.font = .systemFont(ofSize: 12)
|
||||
footerLabel.textColor = UIColor(hex: 0x9CA3AF)
|
||||
footerLabel.textAlignment = .center
|
||||
footerLabel.text = "没有更多"
|
||||
|
||||
addSubview(tableView)
|
||||
tableView.snp.makeConstraints { make in
|
||||
make.edges.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func apply(isRefreshing: Bool, canLoadMore: Bool, isEmpty: Bool) {
|
||||
if isRefreshing {
|
||||
if !refreshControl.isRefreshing { refreshControl.beginRefreshing() }
|
||||
} else {
|
||||
refreshControl.endRefreshing()
|
||||
}
|
||||
footerLabel.text = isEmpty ? "暂无订单" : (canLoadMore ? "" : "没有更多")
|
||||
tableView.tableFooterView = footerLabelFrame(isEmpty: isEmpty, canLoadMore: canLoadMore)
|
||||
}
|
||||
|
||||
private func footerLabelFrame(isEmpty: Bool, canLoadMore: Bool) -> UIView? {
|
||||
guard !canLoadMore || isEmpty else { return nil }
|
||||
footerLabel.frame = CGRect(x: 0, y: 0, width: bounds.width, height: 44)
|
||||
return footerLabel
|
||||
}
|
||||
|
||||
@objc private func refreshTriggered() {
|
||||
onRefresh?()
|
||||
}
|
||||
|
||||
func notifyLoadMoreIfNeeded(at index: Int, shouldLoad: Bool) {
|
||||
guard shouldLoad else { return }
|
||||
onLoadMore?(index)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user