feat: 优化账号注销流程
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 注销申请明确受理后的退出态结果页;不持有会话、凭证或注销接口。
|
||||
@MainActor
|
||||
final class StoreAccountDeregistrationSubmittedViewController: BaseViewController {
|
||||
private typealias Style = StoreAccountDeregistrationStyle
|
||||
private let identityName: String
|
||||
private let coolingUntil: String?
|
||||
private let onDone: () -> Void
|
||||
private let scrollView = UIScrollView()
|
||||
private let contentStack = UIStackView()
|
||||
private let bottomBar = UIView()
|
||||
private let doneButton = Style.button("完成", id: "deregister.submitted.done")
|
||||
private var didFinish = false
|
||||
|
||||
/// 使用提交时冻结的展示信息创建页面;点击完成后由 Scene 进入登录页。
|
||||
init(identityName: String, coolingUntil: String?, onDone: @escaping () -> Void) {
|
||||
let normalizedName = identityName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
self.identityName = normalizedName.isEmpty ? "当前门店身份" : normalizedName
|
||||
self.coolingUntil = coolingUntil?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
self.onDone = onDone
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
override func setupNavigationBar() {
|
||||
title = "注销账号"
|
||||
navigationItem.hidesBackButton = true
|
||||
}
|
||||
|
||||
override func setupUI() {
|
||||
view.backgroundColor = Style.pageBackground
|
||||
view.addSubview(scrollView)
|
||||
scrollView.alwaysBounceVertical = true
|
||||
scrollView.addSubview(contentStack)
|
||||
contentStack.axis = .vertical
|
||||
contentStack.spacing = 18
|
||||
|
||||
let badge = Style.iconBadge("lock", iconSize: 36)
|
||||
let badgeRow = UIView()
|
||||
badgeRow.addSubview(badge)
|
||||
badge.snp.makeConstraints { $0.top.bottom.centerX.equalToSuperview() }
|
||||
|
||||
let titleLabel = Style.label("注销申请已提交", size: 24, weight: .semibold)
|
||||
titleLabel.textAlignment = .center
|
||||
titleLabel.accessibilityIdentifier = "deregister.submitted.title"
|
||||
let identityLabel = Style.label("当前身份:\(identityName)", size: 15, color: Style.textSecondary)
|
||||
identityLabel.textAlignment = .center
|
||||
identityLabel.accessibilityIdentifier = "deregister.submitted.identity"
|
||||
contentStack.addArrangedSubview(Style.stack([badgeRow, titleLabel, identityLabel], spacing: 12))
|
||||
|
||||
let deadlineIcon = Style.icon("calendar", size: 22)
|
||||
deadlineIcon.snp.makeConstraints { $0.width.equalTo(28) }
|
||||
let deadlineTextValue = coolingUntil.flatMap { $0.isEmpty ? nil : $0 } ?? "以服务端状态为准"
|
||||
let deadlineLabel = Style.label(deadlineTextValue, size: 19, weight: .semibold)
|
||||
deadlineLabel.accessibilityIdentifier = "deregister.submitted.deadline"
|
||||
let deadlineText = Style.stack([
|
||||
Style.label("冷静期截止时间", size: 13, color: Style.textSecondary),
|
||||
deadlineLabel
|
||||
], spacing: 8)
|
||||
let deadlineRow = UIStackView(arrangedSubviews: [deadlineIcon, deadlineText])
|
||||
deadlineRow.axis = .horizontal
|
||||
deadlineRow.alignment = .center
|
||||
deadlineRow.spacing = 12
|
||||
contentStack.addArrangedSubview(Style.card(deadlineRow))
|
||||
|
||||
let infoIcon = Style.icon("info.circle", size: 17)
|
||||
infoIcon.snp.makeConstraints { $0.width.equalTo(22) }
|
||||
let infoLabel = Style.label("重新登录该身份自动撤销申请", size: 13, color: Style.textSecondary)
|
||||
let infoRow = UIStackView(arrangedSubviews: [infoIcon, infoLabel])
|
||||
infoRow.axis = .horizontal
|
||||
infoRow.alignment = .center
|
||||
infoRow.spacing = 8
|
||||
contentStack.addArrangedSubview(Style.card(infoRow, background: Style.infoBackground))
|
||||
|
||||
view.addSubview(bottomBar)
|
||||
bottomBar.backgroundColor = .white
|
||||
bottomBar.addSubview(doneButton)
|
||||
doneButton.addTarget(self, action: #selector(doneTapped), for: .touchUpInside)
|
||||
doneButton.snp.makeConstraints {
|
||||
$0.top.equalToSuperview().offset(12)
|
||||
$0.leading.trailing.equalToSuperview().inset(16)
|
||||
$0.bottom.equalToSuperview().inset(12)
|
||||
}
|
||||
}
|
||||
|
||||
override func setupConstraints() {
|
||||
bottomBar.snp.makeConstraints {
|
||||
$0.leading.trailing.equalToSuperview()
|
||||
$0.bottom.equalTo(view.safeAreaLayoutGuide)
|
||||
}
|
||||
scrollView.snp.makeConstraints {
|
||||
$0.top.leading.trailing.equalTo(view.safeAreaLayoutGuide)
|
||||
$0.bottom.equalTo(bottomBar.snp.top)
|
||||
}
|
||||
contentStack.snp.makeConstraints {
|
||||
$0.top.equalTo(scrollView.contentLayoutGuide).offset(32)
|
||||
$0.leading.trailing.bottom.equalTo(scrollView.contentLayoutGuide).inset(16)
|
||||
$0.width.equalTo(scrollView.frameLayoutGuide).offset(-32)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
navigationItem.hidesBackButton = true
|
||||
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
|
||||
}
|
||||
|
||||
@objc private func doneTapped() {
|
||||
guard !didFinish else { return }
|
||||
didFinish = true
|
||||
doneButton.isEnabled = false
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user