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:
2026-07-06 17:58:18 +08:00
parent 39186cfe25
commit 87696a4774
31 changed files with 737 additions and 213 deletions

View File

@ -0,0 +1,80 @@
//
// AppThemeTokensTests.swift
// suixinkanTests
//
import UIKit
import XCTest
@testable import suixinkan
/// Design Token Android
final class AppThemeTokensTests: XCTestCase {
func testPrimaryColorMatchesAndroid() {
XCTAssertEqual(AppColor.primary.hexRGB, 0x0073FF)
}
func testPageBackgroundColors() {
XCTAssertEqual(AppColor.pageBackground.hexRGB, 0xF5F5F5)
XCTAssertEqual(AppColor.pageBackgroundSoft.hexRGB, 0xF7FAFF)
}
func testTextColorsMatchAndroid() {
XCTAssertEqual(AppColor.textPrimary.hexRGB, 0x333333)
XCTAssertEqual(AppColor.textSecondary.hexRGB, 0x666666)
XCTAssertEqual(AppColor.textTertiary.hexRGB, 0x999999)
}
func testSemanticStatusColors() {
XCTAssertEqual(AppColor.success.hexRGB, 0x10B981)
XCTAssertEqual(AppColor.danger.hexRGB, 0xEF4444)
XCTAssertEqual(AppColor.warning.hexRGB, 0xFF7B00)
XCTAssertEqual(AppColor.info.hexRGB, 0x0073FF)
}
func testSpacingGrid() {
XCTAssertEqual(AppSpacing.xxs, 4)
XCTAssertEqual(AppSpacing.xs, 8)
XCTAssertEqual(AppSpacing.sm, 12)
XCTAssertEqual(AppSpacing.md, 16)
XCTAssertEqual(AppSpacing.lg, 24)
XCTAssertEqual(AppSpacing.screenHorizontalInset, AppSpacing.md)
XCTAssertEqual(AppSpacing.minTouchTarget, 44)
XCTAssertGreaterThanOrEqual(AppSpacing.buttonHeight, AppSpacing.minTouchTarget)
}
func testRadiusTokens() {
XCTAssertEqual(AppRadius.xs, 4)
XCTAssertEqual(AppRadius.md, 10)
XCTAssertEqual(AppRadius.lg, 12)
XCTAssertEqual(AppRadius.xl, 16)
}
func testAppFontSizes() {
XCTAssertEqual(UIFont.app(.body).pointSize, 14)
XCTAssertEqual(UIFont.app(.metric).pointSize, 18)
XCTAssertEqual(UIFont.app(.display).pointSize, 28)
}
func testStatusBadgeOrderMapping() {
let badge = AppStatusBadge()
badge.applyOrderStatus(30, text: "已完成")
// label
XCTAssertFalse(badge.isHidden)
}
}
private extension UIColor {
var hexRGB: UInt {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
var alpha: CGFloat = 0
getRed(&red, green: &green, blue: &blue, alpha: &alpha)
let r = Int(round(red * 255))
let g = Int(round(green * 255))
let b = Int(round(blue * 255))
return UInt(r << 16 | g << 8 | b)
}
}