import SwiftUI #if canImport(UIKit) import UIKit #elseif canImport(AppKit) import AppKit #endif private enum AIPalette { #if canImport(UIKit) private static func dynamicColor(light: UIColor, dark: UIColor) -> Color { Color( UIColor { traits in traits.userInterfaceStyle == .dark ? dark : light }) } private static func rgba( _ red: CGFloat, _ green: CGFloat, _ blue: CGFloat, _ alpha: CGFloat ) -> UIColor { UIColor(red: red / 255, green: green / 255, blue: blue / 255, alpha: alpha) } private static func color(light: UIColor, dark: UIColor) -> Color { dynamicColor(light: light, dark: dark) } // 浅色:中性冷灰底 + 纯白卡 + 极浅内嵌面,避免"灰蓝蒙层"把层级糊成一团。 static let canvas = color(light: rgba(242, 244, 248, 1), dark: rgba(7, 10, 16, 1)) static let surface = color(light: rgba(255, 255, 255, 1), dark: rgba(20, 26, 36, 1)) static let surfaceRaised = color(light: rgba(255, 255, 255, 1), dark: rgba(26, 35, 49, 1)) static let control = color(light: rgba(237, 241, 247, 1), dark: rgba(34, 44, 60, 1)) static let tile = color(light: rgba(247, 249, 252, 1), dark: rgba(255, 255, 255, 0.05)) static let tileLine = color(light: rgba(233, 239, 247, 1), dark: rgba(255, 255, 255, 0.08)) static let chrome = color(light: rgba(255, 255, 255, 0.90), dark: rgba(12, 17, 25, 0.86)) static let ink = color(light: rgba(15, 23, 41, 1), dark: rgba(241, 245, 249, 1)) static let muted = color(light: rgba(92, 106, 128, 1), dark: rgba(154, 167, 184, 1)) static let faint = color(light: rgba(141, 152, 170, 1), dark: rgba(112, 127, 148, 1)) static let line = color(light: rgba(224, 231, 240, 1), dark: rgba(255, 255, 255, 0.10)) static let brand = color(light: rgba(11, 27, 51, 1), dark: rgba(7, 10, 16, 1)) static let primary = color(light: rgba(18, 96, 214, 1), dark: rgba(96, 165, 250, 1)) static let onPrimary = color(light: rgba(255, 255, 255, 1), dark: rgba(5, 22, 43, 1)) static let danger = color(light: rgba(199, 44, 44, 1), dark: rgba(248, 113, 113, 1)) static let onDanger = color(light: rgba(255, 255, 255, 1), dark: rgba(24, 7, 7, 1)) static let warning = color(light: rgba(176, 84, 12, 1), dark: rgba(245, 158, 11, 1)) static let success = color(light: rgba(16, 124, 90, 1), dark: rgba(74, 222, 128, 1)) static let segmentTrack = color(light: rgba(236, 240, 246, 1), dark: rgba(12, 17, 25, 1)) static let segmentSelected = color(light: rgba(255, 255, 255, 1), dark: rgba(48, 61, 81, 1)) static let cardShadow = color(light: rgba(15, 30, 60, 0.07), dark: rgba(0, 0, 0, 0.55)) #elseif canImport(AppKit) static let canvas = Color(red: 0.914, green: 0.933, blue: 0.961) static let surface = Color.white static let control = Color(red: 0.941, green: 0.957, blue: 0.980) static let ink = Color(red: 0.035, green: 0.086, blue: 0.169) static let muted = Color(red: 0.275, green: 0.341, blue: 0.435) static let line = Color(red: 0.827, green: 0.867, blue: 0.918) static let brand = Color(red: 0.035, green: 0.086, blue: 0.169) static let surfaceRaised = Color.white static let chrome = Color.white.opacity(0.86) static let onPrimary = Color.white static let onDanger = Color.white static let primary = Color(red: 0.145, green: 0.388, blue: 0.922) static let danger = Color(red: 0.784, green: 0.118, blue: 0.118) static let warning = Color(red: 0.706, green: 0.325, blue: 0.035) static let success = Color(red: 0.071, green: 0.502, blue: 0.361) static let tile = Color(red: 0.969, green: 0.976, blue: 0.988) static let tileLine = Color(red: 0.914, green: 0.937, blue: 0.969) static let faint = Color(red: 0.553, green: 0.596, blue: 0.667) static let segmentTrack = Color(red: 0.925, green: 0.941, blue: 0.965) static let segmentSelected = Color.white static let cardShadow = Color(red: 0.059, green: 0.118, blue: 0.235).opacity(0.07) #else private static func color(_ red: CGFloat, _ green: CGFloat, _ blue: CGFloat) -> Color { Color(red: red / 255, green: green / 255, blue: blue / 255) } static let canvas = color(243, 245, 248) static let surface = color(255, 255, 255) static let control = color(247, 249, 251) static let ink = color(28, 39, 56) static let muted = color(111, 124, 143) static let line = color(224, 229, 235) static let brand = color(19, 30, 48) static let surfaceRaised = color(251, 252, 253) static let chrome = color(255, 255, 255, 0.82) static let onPrimary = color(255, 255, 255) static let onDanger = color(255, 255, 255) static let primary = color(17, 20, 25) static let danger = color(190, 65, 57) static let warning = color(170, 111, 23) static let success = color(50, 150, 101) static let tile = color(247, 249, 252) static let tileLine = color(233, 239, 247) static let faint = color(141, 152, 170) static let segmentTrack = color(236, 240, 246) static let segmentSelected = color(255, 255, 255) static let cardShadow = color(15, 30, 60) #endif } public enum AITheme { public static let canvas = AIPalette.canvas public static let surface = AIPalette.surface public static let surfaceRaised = AIPalette.surfaceRaised public static let control = AIPalette.control public static let tile = AIPalette.tile public static let tileLine = AIPalette.tileLine public static let chrome = AIPalette.chrome public static let ink = AIPalette.ink public static let muted = AIPalette.muted public static let faint = AIPalette.faint public static let line = AIPalette.line public static let brand = AIPalette.brand public static let primary = AIPalette.primary public static let onPrimary = AIPalette.onPrimary public static let danger = AIPalette.danger public static let onDanger = AIPalette.onDanger public static let warning = AIPalette.warning public static let success = AIPalette.success public static let segmentTrack = AIPalette.segmentTrack public static let segmentSelected = AIPalette.segmentSelected public static let cardShadow = AIPalette.cardShadow public static let buttonHeight: CGFloat = 48 public static let compactButtonHeight: CGFloat = 44 public static let largeButtonHeight: CGFloat = 56 public static let toolbarButtonHeight: CGFloat = 44 // 导航栏只给约 38pt 高度,44pt 的方块会被上下裁切,所以工具栏图标按钮单独取 34。 public static let iconButtonSize: CGFloat = 34 public static let iconButtonRadius: CGFloat = 11 public static let buttonRadius: CGFloat = 16 public static let cardRadius: CGFloat = 22 public static let inputRadius: CGFloat = 16 public static let inputHeight: CGFloat = 52 public static let segmentedControlHeight: CGFloat = 44 public static let tileRadius: CGFloat = 14 public static let chipHeight: CGFloat = 34 public static let compactControlHeight: CGFloat = 44 public static let compactButtonMinWidth: CGFloat = 72 public static let regularButtonMinWidth: CGFloat = 88 public static let toolbarButtonMinWidth: CGFloat = 96 public static let toolbarButtonWidth: CGFloat = 104 public static let footerSecondaryButtonWidth: CGFloat = 104 public static let listActionButtonWidth: CGFloat = 84 }