// Ported from the r7 mockups (native-mockups-r4, native/mockups/Shared/Theme.swift). import SwiftUI #if os(macOS) import AppKit #else import UIKit #endif // Colours transcribed from the web day theme (internal/equipo/static/theme.css). enum Palette { static let text = Color(light: 0x18181B, dark: 0xEDEDF0) static let secondary = Color(light: 0x52525C, dark: 0xA1A1AA) static let faint = Color(light: 0x6B6B75, dark: 0x8C8C96) static let background = Color(light: 0xFBFBFC, dark: 0x0C0D0F) static let surface = Color(light: 0xFFFFFF, dark: 0x141518) static let surface2 = Color(light: 0xF3F3F5, dark: 0x18191D) static let border = Color(light: 0xE6E6EA, dark: 0x26282E) static let accent = Color(light: 0x1F56D6, dark: 0x7AA2FF) static let soft = Color(light: 0xECF1FF, dark: 0x16234A) static let softBorder = Color(light: 0xC9D7FA, dark: 0x27397A) static let controlFace = Color(light: 0xFFFFFF, dark: 0x141518) static let controlFaceHover = Color(light: 0xF7F8FA, dark: 0x1B1D22) static let controlFacePressed = Color(light: 0xE6E9EE, dark: 0x202329) /// --rst-line-strong: hollow track dots. static let lineStrong = Color(light: 0x868691, dark: 0x71737C) /// --rst-light-rim: the edge of a raised card, accent mixed into the line. static let lightRim = Color(light: 0xB8C5E5, dark: 0x5D6986) static let controlText = Color(light: 0x18181B, dark: 0xEDEDF0) static let controlBorder = Color(light: 0xD0D4DC, dark: 0x343843) static let placeholder = Color(light: 0x6B6B75, dark: 0x8C8C96) static let primaryFill = Color(light: 0x2257DF, dark: 0x2F61E8) static let primaryFillHover = Color(light: 0x1D4DC8, dark: 0x2956D0) static let primaryEdge = Color(light: 0x153CA0, dark: 0x1F43A6) static let positive = Color(light: 0x166534, dark: 0x6EE7A8) static let positiveBackground = Color(light: 0xDCFCE7, dark: 0x10281C) static let warning = Color(light: 0x854D0E, dark: 0xF0C46A) /// Paused work's calm indigo (equipo.css --equipo-tone-paused-*). static let paused = Color(light: 0x4B44B3, dark: 0xB4ADF6) static let pausedBackground = Color(light: 0xEEEDFB, dark: 0x201E3B) static let warningBackground = Color(light: 0xFEF3C7, dark: 0x2C2110) static let negative = Color(light: 0xB91C1C, dark: 0xF79AA0) static let negativeBackground = Color(light: 0xFEE2E2, dark: 0x331819) static let neutral = Color(light: 0x374151, dark: 0xC3C9D1) static let neutralBackground = Color(light: 0xEEF0F2, dark: 0x262C34) static let contactShadow = Color(light: 0x101828, dark: 0x000000) } extension Color { init(light: UInt32, dark: UInt32) { #if os(macOS) self.init(nsColor: NSColor(name: nil) { appearance in let hex = appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua ? dark : light return NSColor(srgbRed: Double((hex >> 16) & 255) / 255, green: Double((hex >> 8) & 255) / 255, blue: Double(hex & 255) / 255, alpha: 1) }) #else self.init(uiColor: UIColor { traits in let hex = traits.userInterfaceStyle == .dark ? dark : light return UIColor(red: Double((hex >> 16) & 255) / 255, green: Double((hex >> 8) & 255) / 255, blue: Double(hex & 255) / 255, alpha: 1) }) #endif } } // One scale per platform: text styles on iPhone so Dynamic Type works, // fixed AppKit-sized type on the Mac. enum Typo { #if os(iOS) static let screenTitle = Font.title2.weight(.bold) static let question = Font.title3.weight(.semibold) static let cardTitle = Font.headline static let body = Font.body static let secondary = Font.subheadline static let secondaryStrong = Font.subheadline.weight(.semibold) static let caption = Font.footnote static let captionStrong = Font.footnote.weight(.semibold) static let button = Font.body.weight(.medium) static let stat = Font.system(.title2, design: .rounded).weight(.semibold) static let bylineName = Font.headline static let bylineVerb = Font.subheadline static let time = Font.footnote.monospacedDigit() static let eyebrow = Font.footnote.weight(.semibold) static let reportTitle = Font.title3.weight(.semibold) static let compactTitle = Font.body.weight(.semibold) static let cardLine = Font.body static let factLabel = Font.footnote static let factValue = Font.subheadline.weight(.semibold) static let code = Font.system(.footnote, design: .monospaced).weight(.semibold) static let thread = Font.subheadline static let threadWho = Font.caption.weight(.semibold) static let chip = Font.caption.weight(.bold) static let message = Font.body #else static let screenTitle = Font.system(size: 20, weight: .bold) static let question = Font.system(size: 15, weight: .semibold) static let cardTitle = Font.system(size: 13, weight: .semibold) static let body = Font.system(size: 13) static let secondary = Font.system(size: 12) static let secondaryStrong = Font.system(size: 12, weight: .semibold) static let caption = Font.system(size: 11) static let captionStrong = Font.system(size: 11, weight: .semibold) static let button = Font.system(size: 13, weight: .medium) static let stat = Font.system(size: 20, weight: .semibold, design: .rounded) static let bylineName = Font.system(size: 13, weight: .bold) static let bylineVerb = Font.system(size: 12) static let time = Font.system(size: 11).monospacedDigit() static let eyebrow = Font.system(size: 11, weight: .semibold) static let reportTitle = Font.system(size: 15, weight: .semibold) static let compactTitle = Font.system(size: 13, weight: .semibold) static let cardLine = Font.system(size: 14) static let factLabel = Font.system(size: 11) static let factValue = Font.system(size: 12, weight: .semibold) static let code = Font.system(size: 11, weight: .semibold, design: .monospaced) static let thread = Font.system(size: 13) static let threadWho = Font.system(size: 11, weight: .semibold) static let chip = Font.system(size: 10, weight: .bold) static let message = Font.system(size: 14) #endif } enum Metric { #if os(iOS) static let card: CGFloat = 14 static let control: CGFloat = 10 static let buttonHeight: CGFloat = 48 static let cardPadding: CGFloat = 16 static let target: CGFloat = 44 static let raised: CGFloat = 18 static let raisedPadding: CGFloat = 14 static let tile: CGFloat = 30 /// Where a report's content starts: past the byline tile. static let indent: CGFloat = 40 static let gap: CGFloat = 12 #else static let card: CGFloat = 10 static let control: CGFloat = 6 static let buttonHeight: CGFloat = 32 static let cardPadding: CGFloat = 14 static let target: CGFloat = 32 static let raised: CGFloat = 14 static let raisedPadding: CGFloat = 16 static let tile: CGFloat = 30 static let indent: CGFloat = 48 static let gap: CGFloat = 12 #endif } enum Tone { case neutral, accent, positive, warning, negative var foreground: Color { switch self { case .neutral: return Palette.neutral case .accent: return Palette.accent case .positive: return Palette.positive case .warning: return Palette.warning case .negative: return Palette.negative } } var background: Color { switch self { case .neutral: return Palette.neutralBackground case .accent: return Palette.soft case .positive: return Palette.positiveBackground case .warning: return Palette.warningBackground case .negative: return Palette.negativeBackground } } } /// A card: surface, full hairline border, and an optional tint. Never a coloured edge. struct Panel: View { var tinted = false var tone: Tone = .accent var padding: CGFloat = Metric.cardPadding var spacing: CGFloat = 12 @ViewBuilder var content: Content var body: some View { let shape = RoundedRectangle(cornerRadius: Metric.card, style: .continuous) VStack(alignment: .leading, spacing: spacing) { content } .frame(maxWidth: .infinity, alignment: .leading) .padding(padding) .background(shape.fill(tinted ? tone.background : Palette.surface)) .overlay(shape.strokeBorder(tinted ? (tone == .accent ? Palette.softBorder : tone.foreground.opacity(0.25)) : Palette.border, lineWidth: 1)) } } struct QuietLabel: View { let text: String var body: some View { Text(text).font(Typo.caption).foregroundStyle(Palette.secondary).fixedSize(horizontal: false, vertical: true) } } struct SectionTitle: View { let text: String var body: some View { Text(text).font(Typo.captionStrong).textCase(.uppercase).kerning(0.4) .foregroundStyle(Palette.secondary).accessibilityAddTraits(.isHeader) } } struct StatusPill: View { let text: String var tone: Tone = .neutral var icon: String? var body: some View { HStack(spacing: 4) { if let icon { Image(systemName: icon).imageScale(.small) } Text(text) } .font(Typo.captionStrong) .foregroundStyle(tone.foreground) .padding(.horizontal, 8).padding(.vertical, 3) .background(tone.background, in: Capsule()) } } struct CountBadge: View { let count: Int var body: some View { Text(count.formatted()).font(Typo.captionStrong).monospacedDigit() .foregroundStyle(Palette.warning) .padding(.horizontal, 7).frame(minWidth: 22, minHeight: 20) .background(Palette.warningBackground, in: Capsule()) .accessibilityLabel(Text(String(localized: "needs.count_spoken \(count)", bundle: .module))) } } /// A specialist is always an icon beside its name. No lettered squares. struct SpecialistLabel: View { let category: String var tone: Color = Palette.text var body: some View { HStack(spacing: 6) { let who = Specialist(category: category) Image(systemName: who.symbol).foregroundStyle(Palette.secondary) Text(who.name).foregroundStyle(tone) }.font(Typo.secondaryStrong) } } struct Meter: View { let value: Double var tone: Tone = .accent var body: some View { GeometryReader { proxy in ZStack(alignment: .leading) { Capsule().fill(Palette.neutralBackground) Capsule().fill(tone == .accent ? Palette.primaryFill : tone.foreground) .frame(width: max(6, proxy.size.width * min(1, max(0, value)))) } }.frame(height: 6).accessibilityElement().accessibilityValue("\(Int(value * 100)) percent") } } func specialistIcon(_ category: String) -> String { Specialist(category: category).symbol } func compact(_ value: Int64) -> String { Int(value).formatted(.number.notation(.compactName).precision(.fractionLength(0...1))) }