feat: 优化线下收款日历交互与选中态

This commit is contained in:
2026-08-26 14:19:02 +08:00
parent 4351c26e74
commit 9fce6ef713
5 changed files with 262 additions and 58 deletions
@@ -370,7 +370,13 @@ final class OfflinePaymentMethodButton: UIControl {
private let iconView = UIImageView()
private let titleLabel = UILabel()
private let checkmarkView = UIImageView(image: UIImage(systemName: "checkmark"))
private let selectionBadge = UIView()
private let checkmarkView = UIImageView(
image: UIImage(
systemName: "checkmark",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 10, weight: .bold)
)
)
init(method: OfflineCollectionPaymentMethod) {
self.method = method
@@ -386,7 +392,7 @@ final class OfflinePaymentMethodButton: UIControl {
backgroundColor = selected ? UIColor(hex: 0xF1F7FF) : .white
layer.borderColor = (selected ? UIColor(hex: 0x1684FC) : UIColor(hex: 0xE2E7EF)).cgColor
layer.borderWidth = selected ? 1.5 : 1
checkmarkView.isHidden = !selected
selectionBadge.isHidden = !selected
titleLabel.textColor = UIColor(hex: 0x081739)
accessibilityTraits = selected ? [.button, .selected] : .button
}
@@ -400,11 +406,14 @@ final class OfflinePaymentMethodButton: UIControl {
titleLabel.text = method.displayName
titleLabel.font = .systemFont(ofSize: 16, weight: .semibold)
titleLabel.textAlignment = .center
selectionBadge.backgroundColor = UIColor(hex: 0x1684FC)
selectionBadge.layer.cornerRadius = 10
selectionBadge.layer.borderColor = UIColor.white.cgColor
selectionBadge.layer.borderWidth = 2
selectionBadge.isHidden = true
selectionBadge.isUserInteractionEnabled = false
checkmarkView.tintColor = .white
checkmarkView.backgroundColor = UIColor(hex: 0x1684FC)
checkmarkView.layer.cornerRadius = 11
checkmarkView.contentMode = .center
checkmarkView.isHidden = true
checkmarkView.contentMode = .scaleAspectFit
let stack = UIStackView(arrangedSubviews: [iconView, titleLabel])
stack.axis = .vertical
@@ -412,12 +421,17 @@ final class OfflinePaymentMethodButton: UIControl {
stack.spacing = 12
stack.isUserInteractionEnabled = false
addSubview(stack)
addSubview(checkmarkView)
addSubview(selectionBadge)
selectionBadge.addSubview(checkmarkView)
stack.snp.makeConstraints { make in make.center.equalToSuperview() }
iconView.snp.makeConstraints { make in make.width.height.equalTo(46) }
selectionBadge.snp.makeConstraints { make in
make.width.height.equalTo(20)
make.top.trailing.equalToSuperview().inset(6)
}
checkmarkView.snp.makeConstraints { make in
make.width.height.equalTo(22)
make.top.trailing.equalToSuperview().inset(-2)
make.center.equalToSuperview()
make.width.height.equalTo(11)
}
setSelected(false)
}