完善实名认证、钱包与打卡点模块 UI 与业务逻辑。
对齐 Android 实名认证流程与审核页、钱包提现/积分兑换界面,优化打卡点列表与详情交互,并补充相关资源、主题 token 与单元测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -15,7 +15,7 @@ final class PunchPointListViewController: BaseViewController {
|
||||
private let filterContainer = UIView()
|
||||
private let filterButton = UIButton(type: .system)
|
||||
private let filterTitleLabel = UILabel()
|
||||
private let filterChevronView = UIImageView(image: UIImage(systemName: "chevron.down"))
|
||||
private let filterChevronView = UIImageView(image: UIImage(named: "punch_point_dropdown"))
|
||||
private let filterDropdownView = UIView()
|
||||
private let filterDropdownStack = UIStackView()
|
||||
private let tableView = UITableView(frame: .zero, style: .plain)
|
||||
@ -43,18 +43,22 @@ final class PunchPointListViewController: BaseViewController {
|
||||
|
||||
override func setupNavigationBar() {
|
||||
title = "打卡点列表"
|
||||
navigationController?.navigationBar.titleTextAttributes = [
|
||||
.font: UIFont.systemFont(ofSize: 18, weight: .regular),
|
||||
.foregroundColor: UIColor(hex: 0x333333),
|
||||
]
|
||||
}
|
||||
|
||||
override func setupUI() {
|
||||
view.backgroundColor = AppColor.pageBackground
|
||||
view.backgroundColor = UIColor(hex: 0xF4F4F4)
|
||||
|
||||
filterContainer.backgroundColor = .white
|
||||
filterButton.backgroundColor = UIColor(hex: 0xF5F5F5)
|
||||
filterButton.layer.cornerRadius = 8
|
||||
filterButton.accessibilityLabel = "筛选打卡点状态"
|
||||
filterTitleLabel.text = PunchPointFilterType.all.title
|
||||
filterTitleLabel.font = .systemFont(ofSize: 14)
|
||||
filterTitleLabel.textColor = AppColor.textPrimary
|
||||
filterChevronView.tintColor = AppColor.textSecondary
|
||||
filterChevronView.contentMode = .scaleAspectFit
|
||||
|
||||
filterDropdownView.backgroundColor = .white
|
||||
@ -66,7 +70,7 @@ final class PunchPointListViewController: BaseViewController {
|
||||
filterDropdownView.isHidden = true
|
||||
filterDropdownStack.axis = .vertical
|
||||
|
||||
tableView.backgroundColor = AppColor.pageBackground
|
||||
tableView.backgroundColor = UIColor(hex: 0xF4F4F4)
|
||||
tableView.separatorStyle = .none
|
||||
tableView.delegate = self
|
||||
tableView.rowHeight = UITableView.automaticDimension
|
||||
@ -91,6 +95,7 @@ final class PunchPointListViewController: BaseViewController {
|
||||
addButton.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
addButton.backgroundColor = AppColor.primary
|
||||
addButton.layer.cornerRadius = 8
|
||||
addButton.accessibilityLabel = "添加打卡点"
|
||||
|
||||
emptyView.isHidden = true
|
||||
emptyView.onAction = { [weak self] in self?.addTapped() }
|
||||
@ -166,6 +171,9 @@ final class PunchPointListViewController: BaseViewController {
|
||||
viewModel.onShowQRCode = { [weak self] url in
|
||||
Task { @MainActor in self?.showQRCodeDialog(url: url) }
|
||||
}
|
||||
viewModel.onBeginDeleteAnimation = { [weak self] id in
|
||||
Task { @MainActor in self?.animateRemoval(id: id) }
|
||||
}
|
||||
tableView.refreshControl?.addTarget(self, action: #selector(refreshPulled), for: .valueChanged)
|
||||
filterButton.addTarget(self, action: #selector(filterTapped), for: .touchUpInside)
|
||||
addButton.addTarget(self, action: #selector(addTapped), for: .touchUpInside)
|
||||
@ -222,35 +230,49 @@ final class PunchPointListViewController: BaseViewController {
|
||||
}
|
||||
|
||||
private func confirmDelete(_ item: PunchPointItem) {
|
||||
let alert = UIAlertController(
|
||||
let alert = PunchPointMaterialDialogController.confirmation(
|
||||
title: "删除打卡点",
|
||||
message: "确定删除\(item.name)打卡点吗?",
|
||||
preferredStyle: .alert
|
||||
)
|
||||
alert.addAction(UIAlertAction(title: "取消", style: .cancel))
|
||||
alert.addAction(UIAlertAction(title: "确定", style: .destructive) { [weak self] _ in
|
||||
guard let self else { return }
|
||||
Task { await self.viewModel.delete(item: item, api: self.api) }
|
||||
})
|
||||
confirmTitle: "确定",
|
||||
onConfirm: { [weak self] in
|
||||
self?.dismiss(animated: true)
|
||||
guard let self else { return }
|
||||
Task { await self.viewModel.delete(item: item, api: self.api) }
|
||||
}
|
||||
) { [weak self] in
|
||||
self?.dismiss(animated: true)
|
||||
}
|
||||
present(alert, animated: true)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func animateRemoval(id: Int64) {
|
||||
guard let index = viewModel.items.firstIndex(where: { $0.id == id }) else {
|
||||
viewModel.completeDeleteAnimation(id: id)
|
||||
return
|
||||
}
|
||||
let indexPath = IndexPath(row: index, section: 0)
|
||||
guard let cell = tableView.cellForRow(at: indexPath) else {
|
||||
viewModel.completeDeleteAnimation(id: id)
|
||||
return
|
||||
}
|
||||
UIView.animate(
|
||||
withDuration: 0.3,
|
||||
delay: 0,
|
||||
options: [.curveEaseIn, .allowUserInteraction]
|
||||
) {
|
||||
cell.contentView.transform = CGAffineTransform(translationX: self.tableView.bounds.width, y: 0)
|
||||
cell.contentView.alpha = 0
|
||||
} completion: { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.viewModel.completeDeleteAnimation(id: id)
|
||||
}
|
||||
}
|
||||
|
||||
private func showQRCodeDialog(url: String) {
|
||||
let controller = UIAlertController(title: nil, message: "\n\n\n\n\n\n\n\n", preferredStyle: .alert)
|
||||
let imageView = UIImageView()
|
||||
imageView.contentMode = .scaleAspectFill
|
||||
imageView.clipsToBounds = true
|
||||
imageView.layer.cornerRadius = 12
|
||||
if let imageURL = URL(string: url) {
|
||||
imageView.kf.setImage(with: imageURL)
|
||||
let controller = PunchPointMaterialDialogController.qrCode(url: url) { [weak self] in
|
||||
self?.dismiss(animated: true)
|
||||
}
|
||||
controller.view.addSubview(imageView)
|
||||
imageView.snp.makeConstraints { make in
|
||||
make.centerX.equalToSuperview()
|
||||
make.top.equalToSuperview().offset(52)
|
||||
make.size.equalTo(180)
|
||||
}
|
||||
controller.addAction(UIAlertAction(title: "确定", style: .default))
|
||||
present(controller, animated: true)
|
||||
}
|
||||
|
||||
@ -294,7 +316,7 @@ private final class PunchPointListCell: UITableViewCell {
|
||||
private let operatingTag = PunchPointStatusChip()
|
||||
private let creatorLabel = UILabel()
|
||||
private let createdAtLabel = UILabel()
|
||||
private let locationIcon = UIImageView(image: UIImage(systemName: "mappin.and.ellipse"))
|
||||
private let locationIcon = UIImageView(image: UIImage(named: "punch_point_location"))
|
||||
private let addressLabel = UILabel()
|
||||
private let reviewTag = PunchPointStatusChip()
|
||||
private let auditTimeLabel = UILabel()
|
||||
@ -324,14 +346,14 @@ private final class PunchPointListCell: UITableViewCell {
|
||||
$0.font = .systemFont(ofSize: 12)
|
||||
$0.textColor = AppColor.textSecondary
|
||||
}
|
||||
locationIcon.tintColor = UIColor(hex: 0x4B5563)
|
||||
locationIcon.contentMode = .scaleAspectFit
|
||||
addressLabel.font = .systemFont(ofSize: 12)
|
||||
addressLabel.textColor = UIColor(hex: 0x4B5563)
|
||||
addressLabel.numberOfLines = 2
|
||||
qrButton.setImage(UIImage(systemName: "qrcode"), for: .normal)
|
||||
qrButton.tintColor = AppColor.textPrimary
|
||||
deleteButton.setImage(UIImage(systemName: "trash"), for: .normal)
|
||||
deleteButton.tintColor = AppColor.textPrimary
|
||||
qrButton.setImage(UIImage(named: "punch_point_qr"), for: .normal)
|
||||
deleteButton.setImage(UIImage(named: "punch_point_delete"), for: .normal)
|
||||
qrButton.accessibilityLabel = "查看二维码"
|
||||
deleteButton.accessibilityLabel = "删除打卡点"
|
||||
|
||||
contentView.addSubview(cardView)
|
||||
[coverImageView, nameLabel, operatingTag, creatorLabel, createdAtLabel, locationIcon, addressLabel, reviewTag, auditTimeLabel, qrButton, deleteButton].forEach(cardView.addSubview)
|
||||
@ -341,7 +363,8 @@ private final class PunchPointListCell: UITableViewCell {
|
||||
make.leading.trailing.equalToSuperview().inset(15)
|
||||
}
|
||||
coverImageView.snp.makeConstraints { make in
|
||||
make.top.leading.equalToSuperview().offset(16)
|
||||
make.top.equalToSuperview().offset(14)
|
||||
make.leading.equalToSuperview().offset(16)
|
||||
make.size.equalTo(128)
|
||||
}
|
||||
nameLabel.snp.makeConstraints { make in
|
||||
@ -402,17 +425,19 @@ private final class PunchPointListCell: UITableViewCell {
|
||||
}
|
||||
|
||||
func apply(item: PunchPointItem) {
|
||||
contentView.transform = .identity
|
||||
contentView.alpha = 1
|
||||
nameLabel.text = item.name
|
||||
creatorLabel.text = "负责人:\(item.creator?.nonEmptyTrimmed ?? "--")"
|
||||
createdAtLabel.text = "创建时间:\(item.createdAt)"
|
||||
addressLabel.text = item.displayAddress.nonEmptyTrimmed ?? "--"
|
||||
auditTimeLabel.text = "审核时间:\(item.auditTime?.nonEmptyTrimmed ?? "--")"
|
||||
operatingTag.apply(text: item.statusLabel.nonEmptyTrimmed ?? "--", status: item.status)
|
||||
reviewTag.apply(text: item.statusLabel.nonEmptyTrimmed ?? "--", status: item.status)
|
||||
operatingTag.apply(PunchPointDisplayFormatter.operatingStatus(item.status), compact: true)
|
||||
reviewTag.apply(PunchPointDisplayFormatter.auditStatus(item.status), compact: false)
|
||||
if let url = item.guideImages.first.flatMap(URL.init(string:)) {
|
||||
coverImageView.kf.setImage(with: url, placeholder: UIImage(systemName: "photo"))
|
||||
coverImageView.kf.setImage(with: url, placeholder: UIImage(named: "SplashLogo"))
|
||||
} else {
|
||||
coverImageView.image = UIImage(systemName: "photo")
|
||||
coverImageView.image = UIImage(named: "SplashLogo")
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,14 +457,12 @@ final class PunchPointStatusChip: UIView {
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
layer.cornerRadius = 10
|
||||
layer.cornerRadius = 4
|
||||
clipsToBounds = true
|
||||
label.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
label.font = .systemFont(ofSize: 12)
|
||||
label.textAlignment = .center
|
||||
addSubview(label)
|
||||
label.snp.makeConstraints { make in
|
||||
make.edges.equalToSuperview().inset(UIEdgeInsets(top: 3, left: 8, bottom: 3, right: 8))
|
||||
}
|
||||
label.snp.makeConstraints { make in make.edges.equalToSuperview() }
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
@ -448,11 +471,15 @@ final class PunchPointStatusChip: UIView {
|
||||
}
|
||||
|
||||
/// 应用标签文案和状态色。
|
||||
func apply(text: String, status: Int) {
|
||||
label.text = text
|
||||
let colors = PunchPointDisplayFormatter.statusColors(status)
|
||||
backgroundColor = UIColor(hex: colors.background)
|
||||
label.textColor = UIColor(hex: colors.text)
|
||||
func apply(_ presentation: PunchPointStatusPresentation, compact: Bool = false) {
|
||||
label.text = presentation.title
|
||||
backgroundColor = UIColor(hex: presentation.backgroundColor)
|
||||
label.textColor = UIColor(hex: presentation.textColor)
|
||||
label.snp.remakeConstraints { make in
|
||||
make.edges.equalToSuperview().inset(
|
||||
UIEdgeInsets(top: compact ? 2 : 4, left: compact ? 8 : 10, bottom: compact ? 2 : 4, right: compact ? 8 : 10)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,11 +492,11 @@ private final class PunchPointEmptyView: UIView {
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
titleLabel.text = "暂无打卡点"
|
||||
titleLabel.font = .systemFont(ofSize: 15)
|
||||
titleLabel.text = "暂无打卡点,点击下方按钮即可添加"
|
||||
titleLabel.font = .systemFont(ofSize: 14)
|
||||
titleLabel.textColor = AppColor.textSecondary
|
||||
titleLabel.textAlignment = .center
|
||||
button.setTitle("添加打卡点", for: .normal)
|
||||
button.setTitle("立即添加", for: .normal)
|
||||
button.setTitleColor(.white, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.backgroundColor = AppColor.primary
|
||||
@ -482,7 +509,7 @@ private final class PunchPointEmptyView: UIView {
|
||||
button.snp.makeConstraints { make in
|
||||
make.top.equalTo(titleLabel.snp.bottom).offset(12)
|
||||
make.centerX.bottom.equalToSuperview()
|
||||
make.width.equalTo(128)
|
||||
make.width.greaterThanOrEqualTo(96)
|
||||
make.height.equalTo(40)
|
||||
}
|
||||
button.addTarget(self, action: #selector(actionTapped), for: .touchUpInside)
|
||||
@ -498,6 +525,151 @@ private final class PunchPointEmptyView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
/// Android Material3 风格的打卡点确认与二维码弹窗。
|
||||
private final class PunchPointMaterialDialogController: UIViewController {
|
||||
private enum Content {
|
||||
case confirmation(title: String, message: String, confirmTitle: String)
|
||||
case qrCode(url: String)
|
||||
}
|
||||
|
||||
private let content: Content
|
||||
private let onConfirm: () -> Void
|
||||
private let onCancel: (() -> Void)?
|
||||
|
||||
private init(content: Content, onConfirm: @escaping () -> Void, onCancel: (() -> Void)? = nil) {
|
||||
self.content = content
|
||||
self.onConfirm = onConfirm
|
||||
self.onCancel = onCancel
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
modalPresentationStyle = .overFullScreen
|
||||
modalTransitionStyle = .crossDissolve
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
static func confirmation(
|
||||
title: String,
|
||||
message: String,
|
||||
confirmTitle: String,
|
||||
onConfirm: @escaping () -> Void,
|
||||
onCancel: @escaping () -> Void
|
||||
) -> PunchPointMaterialDialogController {
|
||||
PunchPointMaterialDialogController(
|
||||
content: .confirmation(title: title, message: message, confirmTitle: confirmTitle),
|
||||
onConfirm: onConfirm,
|
||||
onCancel: onCancel
|
||||
)
|
||||
}
|
||||
|
||||
static func qrCode(url: String, onConfirm: @escaping () -> Void) -> PunchPointMaterialDialogController {
|
||||
PunchPointMaterialDialogController(content: .qrCode(url: url), onConfirm: onConfirm)
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
view.backgroundColor = UIColor.black.withAlphaComponent(0.32)
|
||||
view.accessibilityViewIsModal = true
|
||||
|
||||
let dialog = UIView()
|
||||
dialog.backgroundColor = .white
|
||||
dialog.layer.cornerRadius = 28
|
||||
dialog.clipsToBounds = true
|
||||
view.addSubview(dialog)
|
||||
dialog.snp.makeConstraints { make in
|
||||
make.center.equalToSuperview()
|
||||
make.leading.greaterThanOrEqualToSuperview().offset(32)
|
||||
make.trailing.lessThanOrEqualToSuperview().offset(-32)
|
||||
make.width.lessThanOrEqualTo(320)
|
||||
}
|
||||
|
||||
switch content {
|
||||
case let .confirmation(title, message, confirmTitle):
|
||||
configureConfirmation(dialog: dialog, title: title, message: message, confirmTitle: confirmTitle)
|
||||
case let .qrCode(url):
|
||||
configureQRCode(dialog: dialog, url: url)
|
||||
}
|
||||
}
|
||||
|
||||
private func configureConfirmation(dialog: UIView, title: String, message: String, confirmTitle: String) {
|
||||
let titleLabel = UILabel()
|
||||
titleLabel.text = title
|
||||
titleLabel.font = .systemFont(ofSize: 16, weight: .medium)
|
||||
titleLabel.textColor = UIColor(hex: 0x333333)
|
||||
let messageLabel = UILabel()
|
||||
messageLabel.text = message
|
||||
messageLabel.font = .systemFont(ofSize: 14)
|
||||
messageLabel.textColor = UIColor(hex: 0x666666)
|
||||
messageLabel.numberOfLines = 0
|
||||
let cancel = textButton(title: "取消", color: UIColor(hex: 0x666666), action: #selector(cancelTapped))
|
||||
let confirm = textButton(title: confirmTitle, color: AppColor.primary, action: #selector(confirmTapped))
|
||||
let actions = UIStackView(arrangedSubviews: [UIView(), cancel, confirm])
|
||||
actions.axis = .horizontal
|
||||
actions.spacing = 8
|
||||
|
||||
[titleLabel, messageLabel, actions].forEach(dialog.addSubview)
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.equalToSuperview().offset(24)
|
||||
make.leading.trailing.equalToSuperview().inset(24)
|
||||
}
|
||||
messageLabel.snp.makeConstraints { make in
|
||||
make.top.equalTo(titleLabel.snp.bottom).offset(16)
|
||||
make.leading.trailing.equalToSuperview().inset(24)
|
||||
}
|
||||
actions.snp.makeConstraints { make in
|
||||
make.top.equalTo(messageLabel.snp.bottom).offset(16)
|
||||
make.leading.trailing.equalToSuperview().inset(16)
|
||||
make.bottom.equalToSuperview().inset(12)
|
||||
make.height.equalTo(44)
|
||||
}
|
||||
}
|
||||
|
||||
private func configureQRCode(dialog: UIView, url: String) {
|
||||
let imageView = UIImageView()
|
||||
imageView.contentMode = .scaleAspectFill
|
||||
imageView.clipsToBounds = true
|
||||
imageView.layer.cornerRadius = 12
|
||||
if let imageURL = URL(string: url) {
|
||||
imageView.kf.setImage(with: imageURL)
|
||||
}
|
||||
let confirm = textButton(title: "确定", color: AppColor.primary, action: #selector(confirmTapped))
|
||||
dialog.addSubview(imageView)
|
||||
dialog.addSubview(confirm)
|
||||
imageView.snp.makeConstraints { make in
|
||||
make.top.equalToSuperview().offset(32)
|
||||
make.centerX.equalToSuperview()
|
||||
make.size.equalTo(180)
|
||||
make.leading.greaterThanOrEqualToSuperview().offset(32)
|
||||
}
|
||||
confirm.snp.makeConstraints { make in
|
||||
make.top.equalTo(imageView.snp.bottom).offset(12)
|
||||
make.trailing.equalToSuperview().inset(16)
|
||||
make.bottom.equalToSuperview().inset(12)
|
||||
make.width.equalTo(64)
|
||||
make.height.equalTo(44)
|
||||
}
|
||||
}
|
||||
|
||||
private func textButton(title: String, color: UIColor, action: Selector) -> UIButton {
|
||||
let button = UIButton(type: .system)
|
||||
button.setTitle(title, for: .normal)
|
||||
button.setTitleColor(color, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
button.addTarget(self, action: action, for: .touchUpInside)
|
||||
return button
|
||||
}
|
||||
|
||||
@objc private func confirmTapped() {
|
||||
onConfirm()
|
||||
}
|
||||
|
||||
@objc private func cancelTapped() {
|
||||
onCancel?()
|
||||
}
|
||||
}
|
||||
|
||||
private extension String {
|
||||
var nonEmptyTrimmed: String? {
|
||||
let text = trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
Reference in New Issue
Block a user