实现数据 Tab 并修复汇总数据解析

This commit is contained in:
2026-07-06 16:32:14 +08:00
parent be18ecd841
commit 9464e32a0a
32 changed files with 1769 additions and 10 deletions

View File

@ -0,0 +1,67 @@
//
// StatisticsStatCardView.swift
// suixinkan
//
import SnapKit
import UIKit
/// Android `StatCard`
final class StatisticsStatCardView: UIView {
private let titleLabel = UILabel()
private let valueLabel = UILabel()
private let iconView = UIImageView()
init(title: String, valueColor: UIColor, backgroundColor: UIColor, iconName: String) {
super.init(frame: .zero)
titleLabel.text = title
valueLabel.textColor = valueColor
self.backgroundColor = backgroundColor
iconView.image = UIImage(named: iconName)
setupUI()
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func configure(value: String) {
valueLabel.text = value
}
private func setupUI() {
layer.cornerRadius = 12
clipsToBounds = true
titleLabel.font = .systemFont(ofSize: 14)
titleLabel.textColor = UIColor.black.withAlphaComponent(0.6)
valueLabel.font = .systemFont(ofSize: 18, weight: .bold)
valueLabel.numberOfLines = 1
valueLabel.adjustsFontSizeToFitWidth = true
valueLabel.minimumScaleFactor = 0.8
iconView.contentMode = .scaleAspectFit
addSubview(titleLabel)
addSubview(valueLabel)
addSubview(iconView)
titleLabel.snp.makeConstraints { make in
make.top.leading.equalToSuperview().inset(12)
make.trailing.lessThanOrEqualTo(iconView.snp.leading).offset(-8)
}
valueLabel.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(3)
make.leading.bottom.equalToSuperview().inset(12)
make.trailing.lessThanOrEqualTo(iconView.snp.leading).offset(-8)
}
iconView.snp.makeConstraints { make in
make.trailing.equalToSuperview().inset(8)
make.centerY.equalToSuperview()
make.size.equalTo(48)
}
}
}