添加景区选择与合作订单流程并对齐 Android

This commit is contained in:
2026-07-07 10:48:43 +08:00
parent ef1d3b4af5
commit c4057537d2
50 changed files with 5603 additions and 191 deletions

View File

@ -22,6 +22,10 @@ final class ProfileInfoRowView: UIControl {
private let divider = UIView()
private let badgeContainer = UIView()
private var badgeView: ProfileStatusBadgeView?
private let rightStack = UIStackView()
private let stackNameLabel = UILabel()
private let stackTypeTag = UILabel()
private var rowHeightConstraint: Constraint?
var showsDivider = true {
didSet { divider.isHidden = !showsDivider }
@ -44,6 +48,8 @@ final class ProfileInfoRowView: UIControl {
accessory: AccessoryStyle = .none,
badge: ProfileStatusBadgeView.Style? = nil
) {
setStackedModeEnabled(false)
valueLabel.text = value
valueLabel.textColor = valueColor
valueLabel.isHidden = badge != nil
@ -73,6 +79,84 @@ final class ProfileInfoRowView: UIControl {
accessoryLabel.isHidden = false
chevronView.isHidden = false
}
updateContentConstraints(for: accessory)
}
///
func configureAccountInfo(
storeName: String,
accountTypeLabel: String,
isStoreAccount: Bool,
showsChevron: Bool = true
) {
setStackedModeEnabled(true, showsChevron: showsChevron)
stackNameLabel.text = storeName
stackTypeTag.text = accountTypeLabel
if isStoreAccount {
stackTypeTag.textColor = UIColor(hex: 0x0F9F6E)
stackTypeTag.backgroundColor = UIColor(hex: 0xE8F8F1)
} else {
stackTypeTag.textColor = UIColor(hex: 0x7C3AED)
stackTypeTag.backgroundColor = UIColor(hex: 0xF3ECFF)
}
updateStackedConstraints(showsChevron: showsChevron)
}
private func setStackedModeEnabled(_ enabled: Bool, showsChevron: Bool = false) {
rightStack.isHidden = !enabled
accessoryLabel.isHidden = true
chevronView.isHidden = !enabled || !showsChevron
if enabled {
valueLabel.isHidden = true
badgeContainer.isHidden = true
rowHeightConstraint?.update(offset: 64)
} else {
rowHeightConstraint?.update(offset: 52)
}
}
private func updateStackedConstraints(showsChevron: Bool) {
rightStack.snp.remakeConstraints { make in
make.centerY.equalToSuperview()
make.leading.greaterThanOrEqualTo(titleLabel.snp.trailing).offset(8)
if showsChevron {
make.trailing.equalTo(chevronView.snp.leading).offset(-4)
} else {
make.trailing.equalToSuperview()
}
}
}
private func updateContentConstraints(for accessory: AccessoryStyle) {
valueLabel.snp.remakeConstraints { make in
make.leading.greaterThanOrEqualTo(titleLabel.snp.trailing).offset(8)
make.centerY.equalToSuperview()
switch accessory {
case .action:
make.trailing.equalTo(accessoryLabel.snp.leading).offset(-8)
case .chevron:
make.trailing.equalTo(chevronView.snp.leading).offset(-4)
case .none:
make.trailing.equalToSuperview()
}
}
badgeContainer.snp.remakeConstraints { make in
make.leading.equalTo(titleLabel.snp.trailing).offset(8)
make.centerY.equalToSuperview()
switch accessory {
case .action:
make.trailing.lessThanOrEqualTo(accessoryLabel.snp.leading).offset(-8)
case .chevron:
make.trailing.lessThanOrEqualTo(chevronView.snp.leading).offset(-8)
case .none:
make.trailing.lessThanOrEqualToSuperview()
}
}
}
private func setupUI() {
@ -83,13 +167,36 @@ final class ProfileInfoRowView: UIControl {
valueLabel.font = .systemFont(ofSize: 14)
valueLabel.textAlignment = .right
valueLabel.numberOfLines = 1
valueLabel.lineBreakMode = .byTruncatingTail
valueLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
accessoryLabel.font = .systemFont(ofSize: 14)
accessoryLabel.textColor = AppColor.primary
accessoryLabel.setContentHuggingPriority(.required, for: .horizontal)
accessoryLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
chevronView.image = UIImage(systemName: "chevron.right")
chevronView.tintColor = AppColor.text666
chevronView.contentMode = .scaleAspectFit
chevronView.setContentHuggingPriority(.required, for: .horizontal)
stackNameLabel.font = .systemFont(ofSize: 14)
stackNameLabel.textColor = AppColor.text333
stackNameLabel.textAlignment = .right
stackNameLabel.numberOfLines = 1
stackNameLabel.lineBreakMode = .byTruncatingTail
stackTypeTag.font = .systemFont(ofSize: 11, weight: .semibold)
stackTypeTag.textAlignment = .center
stackTypeTag.layer.cornerRadius = 4
stackTypeTag.clipsToBounds = true
rightStack.axis = .vertical
rightStack.alignment = .trailing
rightStack.spacing = 4
rightStack.addArrangedSubview(stackNameLabel)
rightStack.addArrangedSubview(stackTypeTag)
rightStack.isHidden = true
divider.backgroundColor = UIColor(hex: 0xE5E7EB)
@ -98,10 +205,11 @@ final class ProfileInfoRowView: UIControl {
addSubview(badgeContainer)
addSubview(accessoryLabel)
addSubview(chevronView)
addSubview(rightStack)
addSubview(divider)
snp.makeConstraints { make in
make.height.equalTo(52)
rowHeightConstraint = make.height.equalTo(52).constraint
}
titleLabel.snp.makeConstraints { make in
make.leading.equalToSuperview()
@ -117,16 +225,16 @@ final class ProfileInfoRowView: UIControl {
make.trailing.equalTo(chevronView.snp.leading).offset(-4)
make.centerY.equalToSuperview()
}
valueLabel.snp.makeConstraints { make in
rightStack.snp.makeConstraints { make in
make.trailing.equalToSuperview()
make.centerY.equalToSuperview()
make.leading.greaterThanOrEqualTo(titleLabel.snp.trailing).offset(8)
make.trailing.equalTo(chevronView.snp.leading).offset(-4)
make.centerY.equalToSuperview()
}
badgeContainer.snp.makeConstraints { make in
make.leading.equalTo(titleLabel.snp.trailing).offset(8)
make.centerY.equalToSuperview()
make.trailing.lessThanOrEqualTo(chevronView.snp.leading).offset(-8)
stackTypeTag.snp.makeConstraints { make in
make.height.equalTo(22)
make.width.greaterThanOrEqualTo(56)
}
updateContentConstraints(for: .none)
divider.snp.makeConstraints { make in
make.leading.trailing.bottom.equalToSuperview()
make.height.equalTo(0.5)

View File

@ -31,6 +31,7 @@ final class ProfileViewController: BaseViewController {
private let statusRow = ProfileInfoRowView(title: "账号状态")
private let scenicRow = ProfileInfoRowView(title: "当前景区")
private let logoutButton = UIButton(type: .system)
private var hasLoadedProfileOnce = false
override func setupNavigationBar() {
title = "我的"
@ -101,7 +102,13 @@ final class ProfileViewController: BaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Task { await reloadProfile(showGlobalLoading: true) }
let showLoading = !hasLoadedProfileOnce
Task {
await reloadProfile(showGlobalLoading: showLoading)
if showLoading {
hasLoadedProfileOnce = true
}
}
}
private let headerContainer = UIView()
@ -194,9 +201,10 @@ final class ProfileViewController: BaseViewController {
avatarImageView.loadRemoteImage(urlString: viewModel.displayAvatarURL)
nameRow.configure(value: viewModel.displayRealName)
accountRow.configure(
value: viewModel.accountDisplayName,
accessory: .action("切换账号")
accountRow.configureAccountInfo(
storeName: viewModel.accountDisplayName,
accountTypeLabel: viewModel.accountTypeLabel,
isStoreAccount: viewModel.isStoreAccount
)
phoneRow.configure(value: viewModel.displayPhone)