引入统一设计令牌并迁移首页、订单和数据 UI

This commit is contained in:
2026-07-06 17:58:18 +08:00
parent 71ab38af8d
commit 28dc004110
31 changed files with 737 additions and 213 deletions

View File

@ -0,0 +1,82 @@
//
// AppStatusBadge.swift
// suixinkan
//
import SnapKit
import UIKit
/// / badge
final class AppStatusBadge: UIView {
///
enum Tone {
case info
case success
case warning
case danger
case neutral
}
private let label = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
AppFont.captionMedium.apply(to: label)
label.textAlignment = .center
addSubview(label)
label.snp.makeConstraints { make in
make.edges.equalToSuperview().inset(
UIEdgeInsets(
top: AppSpacing.xxs,
left: AppSpacing.xs,
bottom: AppSpacing.xxs,
right: AppSpacing.xs
)
)
}
layer.cornerRadius = AppRadius.xs
clipsToBounds = true
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
///
func apply(tone: Tone, text: String) {
label.text = text
switch tone {
case .info:
label.textColor = AppColor.info
backgroundColor = AppColor.infoBackground
case .success:
label.textColor = AppColor.success
backgroundColor = AppColor.successBackground
case .warning:
label.textColor = AppColor.warning
backgroundColor = AppColor.warningBackground
case .danger:
label.textColor = AppColor.danger
backgroundColor = AppColor.dangerBackground
case .neutral:
label.textColor = AppColor.textTabInactive
backgroundColor = AppColor.inputBackground
}
}
/// Android OrderView
func applyOrderStatus(_ status: Int, text: String) {
switch status {
case 18, 20:
apply(tone: .info, text: text)
case 30:
apply(tone: .success, text: text)
case 50:
apply(tone: .danger, text: text)
default:
apply(tone: .warning, text: text)
}
}
}