Establish AppColor/AppFont/AppSpacing/AppRadius theming, shared components, and design-system docs so pilot screens align with Android while keeping iOS-native spacing and touch targets. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.1 KiB
Swift
44 lines
1.1 KiB
Swift
//
|
||
// StatisticsPeriodButton.swift
|
||
// suixinkan
|
||
//
|
||
|
||
import SnapKit
|
||
import UIKit
|
||
|
||
/// 数据统计周期 pill 按钮,对齐 Android `PeriodButton`。
|
||
final class StatisticsPeriodButton: UIButton {
|
||
|
||
var periodTitle: String = "" {
|
||
didSet { setTitle(periodTitle, for: .normal) }
|
||
}
|
||
|
||
override var isSelected: Bool {
|
||
didSet { updateAppearance() }
|
||
}
|
||
|
||
override init(frame: CGRect) {
|
||
super.init(frame: frame)
|
||
setupUI()
|
||
}
|
||
|
||
@available(*, unavailable)
|
||
required init?(coder: NSCoder) {
|
||
fatalError("init(coder:) has not been implemented")
|
||
}
|
||
|
||
private func setupUI() {
|
||
titleLabel?.font = .app(.bodyMedium)
|
||
layer.cornerRadius = AppRadius.pill
|
||
clipsToBounds = true
|
||
contentEdgeInsets = UIEdgeInsets(top: 6, left: 20, bottom: 6, right: 20)
|
||
updateAppearance()
|
||
}
|
||
|
||
private func updateAppearance() {
|
||
backgroundColor = isSelected ? AppColor.primary : AppColor.inputBackground
|
||
setTitleColor(isSelected ? .white : AppColor.textSecondary, for: .normal)
|
||
titleLabel?.font = .systemFont(ofSize: 14, weight: isSelected ? .semibold : .medium)
|
||
}
|
||
}
|