Files
suixinkan_uikit/suixinkan/UI/Statistics/StatisticsStatCardView.swift
汉秋 87696a4774 Introduce unified design tokens and migrate Home, Orders, and Statistics UI.
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>
2026-07-06 17:58:18 +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 = AppRadius.lg
clipsToBounds = true
titleLabel.font = .app(.body)
titleLabel.textColor = AppColor.textPrimary.withAlphaComponent(0.6)
valueLabel.font = .app(.metric)
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(AppSpacing.sm)
make.trailing.lessThanOrEqualTo(iconView.snp.leading).offset(-AppSpacing.xs)
}
valueLabel.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(3)
make.leading.bottom.equalToSuperview().inset(AppSpacing.sm)
make.trailing.lessThanOrEqualTo(iconView.snp.leading).offset(-AppSpacing.xs)
}
iconView.snp.makeConstraints { make in
make.trailing.equalToSuperview().inset(AppSpacing.xs)
make.centerY.equalToSuperview()
make.size.equalTo(48)
}
}
}