重建订单列表 UI 并严格对齐 Android 订单卡片
This commit is contained in:
61
suixinkan/UI/Orders/Views/OrderGiftStepperView.swift
Normal file
61
suixinkan/UI/Orders/Views/OrderGiftStepperView.swift
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// OrderGiftStepperView.swift
|
||||
// suixinkan
|
||||
//
|
||||
|
||||
import SnapKit
|
||||
import UIKit
|
||||
|
||||
/// 修图/视频赠送步进控件,+/- 均触发赠送弹窗(对齐 Android)。
|
||||
final class OrderGiftStepperView: UIView {
|
||||
|
||||
var onMinusTap: (() -> Void)?
|
||||
var onPlusTap: (() -> Void)?
|
||||
|
||||
private let minusButton = UIButton(type: .system)
|
||||
private let plusButton = UIButton(type: .system)
|
||||
private let valueLabel = UILabel()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
[minusButton, plusButton].forEach { button in
|
||||
button.layer.cornerRadius = 12
|
||||
button.layer.borderWidth = 1
|
||||
button.layer.borderColor = OrderTokens.giftBorder.cgColor
|
||||
button.titleLabel?.font = .systemFont(ofSize: 16, weight: .bold)
|
||||
button.setTitleColor(OrderTokens.giftBorder, for: .normal)
|
||||
button.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(24)
|
||||
}
|
||||
}
|
||||
minusButton.setTitle("-", for: .normal)
|
||||
plusButton.setTitle("+", for: .normal)
|
||||
minusButton.addTarget(self, action: #selector(minusTapped), for: .touchUpInside)
|
||||
plusButton.addTarget(self, action: #selector(plusTapped), for: .touchUpInside)
|
||||
|
||||
valueLabel.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
valueLabel.textColor = OrderTokens.valueBlack
|
||||
valueLabel.textAlignment = .center
|
||||
|
||||
let stack = UIStackView(arrangedSubviews: [minusButton, valueLabel, plusButton])
|
||||
stack.axis = .horizontal
|
||||
stack.spacing = AppSpacing.xs
|
||||
stack.alignment = .center
|
||||
addSubview(stack)
|
||||
stack.snp.makeConstraints { make in
|
||||
make.edges.equalToSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func apply(text: String) {
|
||||
valueLabel.text = text
|
||||
}
|
||||
|
||||
@objc private func minusTapped() { onMinusTap?() }
|
||||
@objc private func plusTapped() { onPlusTap?() }
|
||||
}
|
||||
Reference in New Issue
Block a user