完善首页权限申请流程与队列播报体验。

对齐 Android 无权限强制弹窗、角色下拉与申请页交互,补充 UIButton configuration 适配,并增强景区排队 TTS 与相关单元测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-14 13:46:45 +08:00
parent c083f1d4b3
commit efb3925257
50 changed files with 2585 additions and 455 deletions

View File

@ -0,0 +1,118 @@
//
// PermissionRequiredDialogViewController.swift
// suixinkan
//
import SnapKit
import UIKit
/// Android
@MainActor
final class PermissionRequiredDialogViewController: UIViewController {
private let onExitApp: () -> Void
private let onGoToApply: () -> Void
private let dimView = UIView()
private let cardView = UIView()
///
init(onExitApp: @escaping () -> Void, onGoToApply: @escaping () -> Void) {
self.onExitApp = onExitApp
self.onGoToApply = onGoToApply
super.init(nibName: nil, bundle: nil)
modalPresentationStyle = .overFullScreen
modalTransitionStyle = .crossDissolve
isModalInPresentation = true
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .clear
dimView.backgroundColor = UIColor.black.withAlphaComponent(0.32)
cardView.backgroundColor = .white
cardView.layer.cornerRadius = 16
let titleLabel = UILabel()
titleLabel.text = "提示"
titleLabel.font = .systemFont(ofSize: 18, weight: .bold)
titleLabel.textColor = UIColor(hex: 0x333333)
titleLabel.textAlignment = .center
let messageLabel = UILabel()
messageLabel.text = "您还没有权限,请先申请权限"
messageLabel.font = .systemFont(ofSize: 16)
messageLabel.textColor = UIColor(hex: 0x4B5563)
messageLabel.textAlignment = .center
messageLabel.numberOfLines = 0
let exitButton = makeButton(
title: "退出app",
titleColor: UIColor(hex: 0x333333),
backgroundColor: .white,
borderColor: UIColor(hex: 0xE5E5E5)
)
exitButton.addTarget(self, action: #selector(exitTapped), for: .touchUpInside)
let applyButton = makeButton(
title: "去申请",
titleColor: .white,
backgroundColor: AppColor.primary,
borderColor: nil
)
applyButton.addTarget(self, action: #selector(applyTapped), for: .touchUpInside)
let buttons = UIStackView(arrangedSubviews: [exitButton, applyButton])
buttons.axis = .horizontal
buttons.spacing = 12
buttons.distribution = .fillEqually
let stack = UIStackView(arrangedSubviews: [titleLabel, messageLabel, buttons])
stack.axis = .vertical
stack.alignment = .fill
stack.spacing = 16
stack.setCustomSpacing(24, after: messageLabel)
view.addSubview(dimView)
view.addSubview(cardView)
cardView.addSubview(stack)
dimView.snp.makeConstraints { make in make.edges.equalToSuperview() }
cardView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.leading.trailing.equalToSuperview().inset(32)
}
stack.snp.makeConstraints { make in make.edges.equalToSuperview().inset(24) }
buttons.snp.makeConstraints { make in make.height.equalTo(44) }
}
private func makeButton(
title: String,
titleColor: UIColor,
backgroundColor: UIColor,
borderColor: UIColor?
) -> UIButton {
let button = UIButton(type: .system)
button.setTitle(title, for: .normal)
button.setTitleColor(titleColor, for: .normal)
button.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
button.backgroundColor = backgroundColor
button.layer.cornerRadius = 8
button.layer.borderWidth = borderColor == nil ? 0 : 1
button.layer.borderColor = borderColor?.cgColor
button.accessibilityLabel = title
return button
}
@objc private func exitTapped() {
onExitApp()
}
@objc private func applyTapped() {
dismiss(animated: true) { [onGoToApply] in onGoToApply() }
}
}