Implement statistics tab aligned with Android and fix summary decode.
Add role-based analyse APIs, summary/daily UI with date range sheet, and flexible parsing for string refund amounts from the backend. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
43
suixinkan/UI/Statistics/StatisticsPeriodButton.swift
Normal file
43
suixinkan/UI/Statistics/StatisticsPeriodButton.swift
Normal file
@ -0,0 +1,43 @@
|
||||
//
|
||||
// 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 = .systemFont(ofSize: 14, weight: .medium)
|
||||
layer.cornerRadius = 18
|
||||
clipsToBounds = true
|
||||
contentEdgeInsets = UIEdgeInsets(top: 6, left: 20, bottom: 6, right: 20)
|
||||
updateAppearance()
|
||||
}
|
||||
|
||||
private func updateAppearance() {
|
||||
backgroundColor = isSelected ? UIColor(hex: 0x3B82F6) : UIColor(hex: 0xF3F4F6)
|
||||
setTitleColor(isSelected ? .white : UIColor(hex: 0x4B5563), for: .normal)
|
||||
titleLabel?.font = .systemFont(ofSize: 14, weight: isSelected ? .semibold : .medium)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user