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>
This commit is contained in:
@ -47,27 +47,27 @@ final class StatisticsDailyListView: UIView {
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
backgroundColor = .white
|
||||
layer.cornerRadius = 12
|
||||
backgroundColor = AppColor.cardBackground
|
||||
layer.cornerRadius = AppRadius.lg
|
||||
clipsToBounds = true
|
||||
|
||||
titleLabel.text = "时间范围"
|
||||
titleLabel.font = .systemFont(ofSize: 14, weight: .bold)
|
||||
titleLabel.textColor = .black
|
||||
titleLabel.font = .app(.bodyMedium)
|
||||
titleLabel.textColor = AppColor.textPrimary
|
||||
|
||||
rangeButton.backgroundColor = UIColor(hex: 0xF4F4F4)
|
||||
rangeButton.layer.cornerRadius = 4
|
||||
rangeButton.backgroundColor = AppColor.inputBackground
|
||||
rangeButton.layer.cornerRadius = AppRadius.xs
|
||||
rangeButton.addTarget(self, action: #selector(rangeTapped), for: .touchUpInside)
|
||||
|
||||
rangeLabel.font = .systemFont(ofSize: 14)
|
||||
rangeLabel.textColor = UIColor(hex: 0x4B5563)
|
||||
rangeLabel.font = .app(.body)
|
||||
rangeLabel.textColor = AppColor.textSecondary
|
||||
rangeLabel.text = "今日"
|
||||
|
||||
arrowView.image = UIImage(systemName: "chevron.down")
|
||||
arrowView.tintColor = UIColor(hex: 0x4B5563)
|
||||
arrowView.tintColor = AppColor.textSecondary
|
||||
arrowView.contentMode = .scaleAspectFit
|
||||
|
||||
divider.backgroundColor = UIColor(hex: 0xF4F4F4)
|
||||
divider.backgroundColor = AppColor.inputBackground
|
||||
|
||||
tableView.backgroundColor = .clear
|
||||
tableView.separatorStyle = .none
|
||||
|
||||
@ -28,16 +28,16 @@ final class StatisticsPeriodButton: UIButton {
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
layer.cornerRadius = 18
|
||||
titleLabel?.font = .app(.bodyMedium)
|
||||
layer.cornerRadius = AppRadius.pill
|
||||
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)
|
||||
backgroundColor = isSelected ? AppColor.primary : AppColor.inputBackground
|
||||
setTitleColor(isSelected ? .white : AppColor.textSecondary, for: .normal)
|
||||
titleLabel?.font = .systemFont(ofSize: 14, weight: isSelected ? .semibold : .medium)
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,13 +32,13 @@ final class StatisticsStatCardView: UIView {
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
layer.cornerRadius = 12
|
||||
layer.cornerRadius = AppRadius.lg
|
||||
clipsToBounds = true
|
||||
|
||||
titleLabel.font = .systemFont(ofSize: 14)
|
||||
titleLabel.textColor = UIColor.black.withAlphaComponent(0.6)
|
||||
titleLabel.font = .app(.body)
|
||||
titleLabel.textColor = AppColor.textPrimary.withAlphaComponent(0.6)
|
||||
|
||||
valueLabel.font = .systemFont(ofSize: 18, weight: .bold)
|
||||
valueLabel.font = .app(.metric)
|
||||
valueLabel.numberOfLines = 1
|
||||
valueLabel.adjustsFontSizeToFitWidth = true
|
||||
valueLabel.minimumScaleFactor = 0.8
|
||||
@ -50,16 +50,16 @@ final class StatisticsStatCardView: UIView {
|
||||
addSubview(iconView)
|
||||
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.leading.equalToSuperview().inset(12)
|
||||
make.trailing.lessThanOrEqualTo(iconView.snp.leading).offset(-8)
|
||||
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(12)
|
||||
make.trailing.lessThanOrEqualTo(iconView.snp.leading).offset(-8)
|
||||
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(8)
|
||||
make.trailing.equalToSuperview().inset(AppSpacing.xs)
|
||||
make.centerY.equalToSuperview()
|
||||
make.size.equalTo(48)
|
||||
}
|
||||
|
||||
@ -18,8 +18,8 @@ final class StatisticsSummaryCardView: UIView {
|
||||
|
||||
private let totalAmountCard = StatisticsStatCardView(
|
||||
title: "订单总金额",
|
||||
valueColor: UIColor(hex: 0x22C55E),
|
||||
backgroundColor: UIColor(hex: 0xF0FDF4),
|
||||
valueColor: AppColor.online,
|
||||
backgroundColor: AppColor.successBackground,
|
||||
iconName: "icon_data_statistics_total_amount"
|
||||
)
|
||||
private let totalOrderCard = StatisticsStatCardView(
|
||||
@ -30,20 +30,20 @@ final class StatisticsSummaryCardView: UIView {
|
||||
)
|
||||
private let receivedCard = StatisticsStatCardView(
|
||||
title: "实收金额",
|
||||
valueColor: UIColor(hex: 0x22C55E),
|
||||
backgroundColor: UIColor(hex: 0xFFF0E2),
|
||||
valueColor: AppColor.online,
|
||||
backgroundColor: AppColor.warningBackground,
|
||||
iconName: "icon_data_statistics_get_amount"
|
||||
)
|
||||
private let averageCard = StatisticsStatCardView(
|
||||
title: "客单价",
|
||||
valueColor: UIColor(hex: 0x0073FF),
|
||||
backgroundColor: UIColor(hex: 0xEFF6FF),
|
||||
valueColor: AppColor.primary,
|
||||
backgroundColor: AppColor.primaryLight,
|
||||
iconName: "icon_data_statistics_average_amount"
|
||||
)
|
||||
private let refundCard = StatisticsStatCardView(
|
||||
title: "退款金额",
|
||||
valueColor: UIColor(hex: 0xEF4444),
|
||||
backgroundColor: UIColor(hex: 0xFFE7E7),
|
||||
valueColor: AppColor.danger,
|
||||
backgroundColor: AppColor.dangerBackground,
|
||||
iconName: "icon_data_statistics_refund_amount"
|
||||
)
|
||||
|
||||
@ -69,15 +69,15 @@ final class StatisticsSummaryCardView: UIView {
|
||||
}
|
||||
|
||||
private func setupUI() {
|
||||
backgroundColor = .white
|
||||
layer.cornerRadius = 12
|
||||
backgroundColor = AppColor.cardBackground
|
||||
layer.cornerRadius = AppRadius.lg
|
||||
clipsToBounds = true
|
||||
|
||||
datePrefixLabel.text = "已选日期:"
|
||||
datePrefixLabel.font = .systemFont(ofSize: 14)
|
||||
datePrefixLabel.textColor = AppColor.text333
|
||||
datePrefixLabel.font = .app(.body)
|
||||
datePrefixLabel.textColor = AppColor.textPrimary
|
||||
|
||||
dateValueLabel.font = .systemFont(ofSize: 14)
|
||||
dateValueLabel.font = .app(.body)
|
||||
dateValueLabel.textColor = AppColor.primary
|
||||
dateValueLabel.numberOfLines = 1
|
||||
|
||||
@ -95,17 +95,17 @@ final class StatisticsSummaryCardView: UIView {
|
||||
|
||||
let row1 = UIStackView(arrangedSubviews: [totalOrderCard, receivedCard])
|
||||
row1.axis = .horizontal
|
||||
row1.spacing = 12
|
||||
row1.spacing = AppSpacing.sm
|
||||
row1.distribution = .fillEqually
|
||||
|
||||
let row2 = UIStackView(arrangedSubviews: [averageCard, refundCard])
|
||||
row2.axis = .horizontal
|
||||
row2.spacing = 12
|
||||
row2.spacing = AppSpacing.sm
|
||||
row2.distribution = .fillEqually
|
||||
|
||||
let cardStack = UIStackView(arrangedSubviews: [totalAmountCard, row1, row2])
|
||||
cardStack.axis = .vertical
|
||||
cardStack.spacing = 12
|
||||
cardStack.spacing = AppSpacing.sm
|
||||
|
||||
let dateRow = UIStackView(arrangedSubviews: [datePrefixLabel, dateValueLabel, UIView()])
|
||||
dateRow.axis = .horizontal
|
||||
@ -114,11 +114,11 @@ final class StatisticsSummaryCardView: UIView {
|
||||
|
||||
let contentStack = UIStackView(arrangedSubviews: [dateRow, periodStack, cardStack])
|
||||
contentStack.axis = .vertical
|
||||
contentStack.spacing = 12
|
||||
contentStack.spacing = AppSpacing.sm
|
||||
|
||||
addSubview(contentStack)
|
||||
contentStack.snp.makeConstraints { make in
|
||||
make.edges.equalToSuperview().inset(16)
|
||||
make.edges.equalToSuperview().inset(AppSpacing.md)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ final class StatisticsViewController: BaseViewController {
|
||||
}
|
||||
|
||||
override func setupUI() {
|
||||
view.backgroundColor = UIColor(hex: 0xF7FAFF)
|
||||
view.backgroundColor = AppColor.pageBackgroundSoft
|
||||
|
||||
view.addSubview(summaryCardView)
|
||||
view.addSubview(dailyListView)
|
||||
@ -31,13 +31,13 @@ final class StatisticsViewController: BaseViewController {
|
||||
|
||||
override func setupConstraints() {
|
||||
summaryCardView.snp.makeConstraints { make in
|
||||
make.top.equalTo(view.safeAreaLayoutGuide).offset(16)
|
||||
make.leading.trailing.equalToSuperview().inset(16)
|
||||
make.top.equalTo(view.safeAreaLayoutGuide).offset(AppSpacing.md)
|
||||
make.leading.trailing.equalToSuperview().inset(AppSpacing.screenHorizontalInset)
|
||||
}
|
||||
dailyListView.snp.makeConstraints { make in
|
||||
make.top.equalTo(summaryCardView.snp.bottom).offset(16)
|
||||
make.leading.trailing.equalToSuperview().inset(16)
|
||||
make.bottom.equalTo(view.safeAreaLayoutGuide).inset(16)
|
||||
make.top.equalTo(summaryCardView.snp.bottom).offset(AppSpacing.md)
|
||||
make.leading.trailing.equalToSuperview().inset(AppSpacing.screenHorizontalInset)
|
||||
make.bottom.equalTo(view.safeAreaLayoutGuide).inset(AppSpacing.md)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user