Files
suixinkan_uikit/suixinkan/UI/Statistics/StatisticsStatCardView.swift
汉秋 6492f80ef0 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>
2026-07-06 16:32:14 +08:00

68 lines
2.0 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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)
}
}
}