|
| 1 | +import SwiftUI |
| 2 | +import Infrastructure |
| 3 | +import Domain |
| 4 | + |
| 5 | +// MARK: - RGBColor → SwiftUI Color |
| 6 | + |
| 7 | +public extension TerminalColorScheme.RGBColor { |
| 8 | + /// Convert to SwiftUI `Color`. |
| 9 | + var color: Color { |
| 10 | + Color(red: red, green: green, blue: blue).opacity(alpha) |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +// MARK: - ImportedTerminalTheme |
| 15 | + |
| 16 | +/// An ``AppThemeProvider`` implementation generated from an imported terminal color scheme. |
| 17 | +/// |
| 18 | +/// Created by ``TerminalThemeGenerator`` and backed by pre-computed ``GeneratedThemeProperties``. |
| 19 | +/// All SwiftUI colors are derived from the canonical ``TerminalColorScheme/RGBColor`` values. |
| 20 | +public struct ImportedTerminalTheme: AppThemeProvider { |
| 21 | + private let props: GeneratedThemeProperties |
| 22 | + private let scheme: TerminalColorScheme |
| 23 | + |
| 24 | + /// Create a theme from generated properties and the original color scheme. |
| 25 | + public init(props: GeneratedThemeProperties, scheme: TerminalColorScheme) { |
| 26 | + self.props = props |
| 27 | + self.scheme = scheme |
| 28 | + } |
| 29 | + |
| 30 | + // MARK: - Identity |
| 31 | + |
| 32 | + public var id: String { props.id } |
| 33 | + public var displayName: String { props.displayName } |
| 34 | + public var icon: String { "terminal.fill" } |
| 35 | + public var subtitle: String? { "Imported" } |
| 36 | + public var statusBarIconName: String? { nil } |
| 37 | + |
| 38 | + // MARK: - Color Scheme Preference |
| 39 | + |
| 40 | + /// Whether this imported theme prefers a dark color scheme (derived from background luminance). |
| 41 | + public var prefersDarkColorScheme: Bool { props.isDark } |
| 42 | + |
| 43 | + // MARK: - Background |
| 44 | + |
| 45 | + public var backgroundGradient: LinearGradient { |
| 46 | + LinearGradient( |
| 47 | + colors: [props.background.color, props.cardBackground.color], |
| 48 | + startPoint: .topLeading, |
| 49 | + endPoint: .bottomTrailing |
| 50 | + ) |
| 51 | + } |
| 52 | + |
| 53 | + public var showBackgroundOrbs: Bool { false } |
| 54 | + |
| 55 | + // MARK: - Cards & Glass |
| 56 | + |
| 57 | + public var cardGradient: LinearGradient { |
| 58 | + LinearGradient( |
| 59 | + colors: [props.cardBackground.color, props.cardBackground.color.opacity(0.95)], |
| 60 | + startPoint: .topLeading, |
| 61 | + endPoint: .bottomTrailing |
| 62 | + ) |
| 63 | + } |
| 64 | + |
| 65 | + public var glassBackground: Color { props.glassBackground.color } |
| 66 | + public var glassBorder: Color { props.glassBorder.color } |
| 67 | + public var glassHighlight: Color { props.glassHighlight.color } |
| 68 | + public var cardCornerRadius: CGFloat { 10 } |
| 69 | + public var pillCornerRadius: CGFloat { 12 } |
| 70 | + |
| 71 | + // MARK: - Typography |
| 72 | + |
| 73 | + public var textPrimary: Color { props.textPrimary.color } |
| 74 | + public var textSecondary: Color { props.textSecondary.color } |
| 75 | + public var textTertiary: Color { props.textTertiary.color } |
| 76 | + public var fontDesign: Font.Design { .monospaced } |
| 77 | + public var customFontName: String? { nil } |
| 78 | + |
| 79 | + // MARK: - Status Colors |
| 80 | + |
| 81 | + public var statusHealthy: Color { props.statusHealthy.color } |
| 82 | + public var statusWarning: Color { props.statusWarning.color } |
| 83 | + public var statusCritical: Color { props.statusCritical.color } |
| 84 | + public var statusDepleted: Color { props.statusDepleted.color } |
| 85 | + |
| 86 | + // MARK: - Accents |
| 87 | + |
| 88 | + public var accentPrimary: Color { props.accentPrimary.color } |
| 89 | + public var accentSecondary: Color { props.accentSecondary.color } |
| 90 | + |
| 91 | + public var accentGradient: LinearGradient { |
| 92 | + LinearGradient( |
| 93 | + colors: [accentPrimary, accentSecondary], |
| 94 | + startPoint: .leading, |
| 95 | + endPoint: .trailing |
| 96 | + ) |
| 97 | + } |
| 98 | + |
| 99 | + public var pillGradient: LinearGradient { |
| 100 | + LinearGradient( |
| 101 | + colors: [accentPrimary.opacity(0.25), accentSecondary.opacity(0.15)], |
| 102 | + startPoint: .topLeading, |
| 103 | + endPoint: .bottomTrailing |
| 104 | + ) |
| 105 | + } |
| 106 | + |
| 107 | + public var shareGradient: LinearGradient { |
| 108 | + LinearGradient( |
| 109 | + colors: [scheme.yellow.color, scheme.brightYellow.color], |
| 110 | + startPoint: .leading, |
| 111 | + endPoint: .trailing |
| 112 | + ) |
| 113 | + } |
| 114 | + |
| 115 | + // MARK: - Interactive States |
| 116 | + |
| 117 | + public var hoverOverlay: Color { accentPrimary.opacity(0.1) } |
| 118 | + public var pressedOverlay: Color { accentPrimary.opacity(0.15) } |
| 119 | + |
| 120 | + // MARK: - Progress Bar |
| 121 | + |
| 122 | + public var progressTrack: Color { props.progressTrack.color } |
| 123 | +} |
0 commit comments