Add scenic selection and cooperation order flows aligned with Android.
Upgrade scenic picker with search, location sorting, permission apply/status, and blocking home dialog; add cooperation order module and order source picker improvements with unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
112
suixinkan/UI/Orders/Views/OrderSourceEntryView.swift
Normal file
112
suixinkan/UI/Orders/Views/OrderSourceEntryView.swift
Normal file
@ -0,0 +1,112 @@
|
||||
//
|
||||
// OrderSourceEntryView.swift
|
||||
// suixinkan
|
||||
//
|
||||
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 订单卡片内「订单来源」入口,对齐 Android `OrderSourcePicker` 折叠态。
|
||||
final class OrderSourceEntryView: UIControl {
|
||||
|
||||
var onImageTap: (([String], Int) -> Void)?
|
||||
|
||||
private let titleLabel = UILabel()
|
||||
private let chevronView = UIImageView()
|
||||
private let hintLabel = UILabel()
|
||||
private let personRow = UIStackView()
|
||||
private let personNameLabel = UILabel()
|
||||
private let personPhoneLabel = UILabel()
|
||||
private let divider = UIView()
|
||||
private let leadContentView = OrderSourceLeadContentView()
|
||||
private var currentImages: [String] = []
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setupUI()
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
/// 应用订单来源展示状态。
|
||||
func apply(selection: OrderSourceSelection?) {
|
||||
if let selection {
|
||||
hintLabel.isHidden = true
|
||||
personRow.isHidden = false
|
||||
divider.isHidden = false
|
||||
leadContentView.isHidden = false
|
||||
|
||||
personNameLabel.text = selection.person.name
|
||||
let phone = selection.person.phone.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
personPhoneLabel.text = phone
|
||||
personPhoneLabel.isHidden = phone.isEmpty
|
||||
|
||||
currentImages = selection.lead.images
|
||||
leadContentView.apply(lead: selection.lead, compact: true, enablePhoneCall: false)
|
||||
leadContentView.onImageTap = { [weak self] _, index in
|
||||
guard let self else { return }
|
||||
self.onImageTap?(self.currentImages, index)
|
||||
}
|
||||
} else {
|
||||
hintLabel.isHidden = false
|
||||
personRow.isHidden = true
|
||||
divider.isHidden = true
|
||||
leadContentView.isHidden = true
|
||||
currentImages = []
|
||||
}
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
backgroundColor = OrderTokens.sourceBackground
|
||||
layer.cornerRadius = AppRadius.sm
|
||||
layer.borderWidth = 1
|
||||
layer.borderColor = OrderTokens.sourceBorder.cgColor
|
||||
|
||||
titleLabel.text = "订单来源"
|
||||
titleLabel.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
titleLabel.textColor = OrderTokens.label563
|
||||
|
||||
chevronView.image = UIImage(systemName: "chevron.right")
|
||||
chevronView.tintColor = AppColor.primary
|
||||
chevronView.contentMode = .scaleAspectFit
|
||||
|
||||
hintLabel.text = "选择获客员及其创建的带客单"
|
||||
hintLabel.font = .systemFont(ofSize: 13)
|
||||
hintLabel.textColor = AppColor.text666
|
||||
hintLabel.numberOfLines = 0
|
||||
|
||||
personRow.axis = .horizontal
|
||||
personRow.alignment = .center
|
||||
personRow.spacing = 10
|
||||
personNameLabel.font = .systemFont(ofSize: 13, weight: .medium)
|
||||
personNameLabel.textColor = AppColor.text333
|
||||
personPhoneLabel.font = .systemFont(ofSize: 13)
|
||||
personPhoneLabel.textColor = AppColor.text666
|
||||
personRow.addArrangedSubview(personNameLabel)
|
||||
personRow.addArrangedSubview(personPhoneLabel)
|
||||
|
||||
divider.backgroundColor = OrderTokens.sourceDivider
|
||||
|
||||
let headerRow = UIStackView(arrangedSubviews: [titleLabel, UIView(), chevronView])
|
||||
headerRow.axis = .horizontal
|
||||
headerRow.alignment = .center
|
||||
|
||||
let stack = UIStackView(arrangedSubviews: [headerRow, hintLabel, personRow, divider, leadContentView])
|
||||
stack.axis = .vertical
|
||||
stack.spacing = 10
|
||||
stack.isUserInteractionEnabled = false
|
||||
addSubview(stack)
|
||||
stack.snp.makeConstraints { make in
|
||||
make.edges.equalToSuperview().inset(AppSpacing.sm)
|
||||
}
|
||||
chevronView.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(20)
|
||||
}
|
||||
divider.snp.makeConstraints { make in
|
||||
make.height.equalTo(OrderTokens.dividerHeight)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user