对齐 Android 无权限强制弹窗、角色下拉与申请页交互,补充 UIButton configuration 适配,并增强景区排队 TTS 与相关单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
1.9 KiB
Swift
60 lines
1.9 KiB
Swift
//
|
|
// HomeScenicHeaderView.swift
|
|
// suixinkan
|
|
//
|
|
|
|
import SnapKit
|
|
import UIKit
|
|
|
|
/// 首页顶部景区选择条。
|
|
final class HomeScenicHeaderView: UIView {
|
|
|
|
var onTap: (() -> Void)?
|
|
|
|
private let titleLabel = UILabel()
|
|
private let arrowView = UIImageView(image: UIImage(systemName: "chevron.down"))
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
backgroundColor = AppColor.cardBackground
|
|
titleLabel.font = .app(.subtitle)
|
|
titleLabel.textColor = AppColor.textPrimary
|
|
titleLabel.lineBreakMode = .byTruncatingTail
|
|
titleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
|
arrowView.tintColor = AppColor.textSecondary
|
|
arrowView.contentMode = .scaleAspectFit
|
|
arrowView.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
|
|
addSubview(titleLabel)
|
|
addSubview(arrowView)
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.leading.equalTo(safeAreaLayoutGuide).offset(AppSpacing.screenHorizontalInset)
|
|
make.centerY.equalTo(safeAreaLayoutGuide)
|
|
}
|
|
arrowView.snp.makeConstraints { make in
|
|
make.leading.equalTo(titleLabel.snp.trailing).offset(AppSpacing.xs)
|
|
make.trailing.lessThanOrEqualTo(safeAreaLayoutGuide).offset(-AppSpacing.screenHorizontalInset)
|
|
make.centerY.equalTo(safeAreaLayoutGuide)
|
|
make.width.height.equalTo(16)
|
|
}
|
|
|
|
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
|
|
addGestureRecognizer(tap)
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
func apply(scenicName: String) {
|
|
let trimmed = scenicName.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
titleLabel.text = trimmed.isEmpty ? "请选择景区" : trimmed
|
|
}
|
|
|
|
@objc private func handleTap() {
|
|
onTap?()
|
|
}
|
|
}
|