Nenhuma descrição

CVResumeAppearance.swift 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // CVResumeAppearance.swift
  3. // App for Indeed
  4. //
  5. // Shared résumé colours for gallery thumbnails and filled CV preview/export.
  6. // Résumés always use a print-style light palette regardless of app light/dark mode.
  7. //
  8. import AppKit
  9. @MainActor
  10. enum CVResumeAppearance {
  11. struct Colors {
  12. let paper: NSColor
  13. let ink: NSColor
  14. let muted: NSColor
  15. let rule: NSColor
  16. let cardBackground: NSColor
  17. let sidebarTint: NSColor
  18. let accentRed: NSColor
  19. let accentBlue: NSColor
  20. }
  21. /// Print-style palette — always light, even when the app chrome is in dark mode.
  22. static func colors() -> Colors {
  23. Colors(
  24. paper: NSColor.white,
  25. ink: NSColor(srgbRed: 38 / 255, green: 50 / 255, blue: 71 / 255, alpha: 1),
  26. muted: NSColor(srgbRed: 110 / 255, green: 118 / 255, blue: 132 / 255, alpha: 1),
  27. rule: NSColor(srgbRed: 228 / 255, green: 232 / 255, blue: 240 / 255, alpha: 1),
  28. cardBackground: NSColor.white,
  29. sidebarTint: NSColor(srgbRed: 244 / 255, green: 246 / 255, blue: 250 / 255, alpha: 1),
  30. accentRed: NSColor(srgbRed: 207 / 255, green: 67 / 255, blue: 50 / 255, alpha: 1),
  31. accentBlue: AppDashboardTheme.brandBlue
  32. )
  33. }
  34. /// Slight paper tint by layout variant (gallery + filled CV use the same rule).
  35. static func paperBackground(variant: Int, base: NSColor) -> NSColor {
  36. switch variant % 5 {
  37. case 0: return base
  38. case 1: return NSColor(srgbRed: 0.995, green: 0.992, blue: 0.985, alpha: 1)
  39. case 2: return NSColor(srgbRed: 0.96, green: 0.99, blue: 1, alpha: 1)
  40. case 3: return NSColor(srgbRed: 0.99, green: 0.99, blue: 0.99, alpha: 1)
  41. default: return NSColor(srgbRed: 0.99, green: 0.98, blue: 0.995, alpha: 1)
  42. }
  43. }
  44. static func accentColor(for template: CVTemplate) -> NSColor {
  45. let palette = colors()
  46. switch template.accent {
  47. case .redUnderline, .redBar:
  48. return palette.accentRed
  49. case .blueBar:
  50. return template.themeColor
  51. case .none:
  52. return template.themeColor.blended(withFraction: 0.5, of: palette.ink) ?? template.themeColor
  53. }
  54. }
  55. static func sectionHeadingColor(for template: CVTemplate) -> NSColor {
  56. accentColor(for: template)
  57. }
  58. }