No Description

CVResumeAppearance.swift 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // CVResumeAppearance.swift
  3. // App for Indeed
  4. //
  5. // Shared résumé colours for gallery thumbnails and filled CV preview/export.
  6. // Tracks app light / dark mode so the selected template looks the same everywhere.
  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. static var isDark: Bool { AppAppearanceManager.shared.isDark }
  22. static func colors(isDark dark: Bool? = nil) -> Colors {
  23. let dark = dark ?? isDark
  24. if dark {
  25. return Colors(
  26. paper: NSColor(srgbRed: 28 / 255, green: 30 / 255, blue: 36 / 255, alpha: 1),
  27. ink: NSColor(srgbRed: 0.94, green: 0.95, blue: 0.97, alpha: 1),
  28. muted: NSColor(srgbRed: 0.62, green: 0.66, blue: 0.72, alpha: 1),
  29. rule: NSColor(srgbRed: 0.38, green: 0.40, blue: 0.46, alpha: 1),
  30. cardBackground: NSColor(srgbRed: 32 / 255, green: 34 / 255, blue: 40 / 255, alpha: 1),
  31. sidebarTint: NSColor(srgbRed: 40 / 255, green: 42 / 255, blue: 48 / 255, alpha: 1),
  32. accentRed: NSColor(srgbRed: 235 / 255, green: 88 / 255, blue: 72 / 255, alpha: 1),
  33. accentBlue: AppDashboardTheme.brandBlue
  34. )
  35. }
  36. return Colors(
  37. paper: NSColor.white,
  38. ink: NSColor(srgbRed: 38 / 255, green: 50 / 255, blue: 71 / 255, alpha: 1),
  39. muted: NSColor(srgbRed: 110 / 255, green: 118 / 255, blue: 132 / 255, alpha: 1),
  40. rule: NSColor(srgbRed: 228 / 255, green: 232 / 255, blue: 240 / 255, alpha: 1),
  41. cardBackground: NSColor.white,
  42. sidebarTint: AppDashboardTheme.cvMakerPreviewSidebarTint,
  43. accentRed: NSColor(srgbRed: 207 / 255, green: 67 / 255, blue: 50 / 255, alpha: 1),
  44. accentBlue: AppDashboardTheme.brandBlue
  45. )
  46. }
  47. /// Slight paper tint by layout variant (gallery + filled CV use the same rule).
  48. static func paperBackground(variant: Int, base: NSColor) -> NSColor {
  49. guard !isDark else { return base }
  50. switch variant % 5 {
  51. case 0: return base
  52. case 1: return NSColor(srgbRed: 0.995, green: 0.992, blue: 0.985, alpha: 1)
  53. case 2: return NSColor(srgbRed: 0.96, green: 0.99, blue: 1, alpha: 1)
  54. case 3: return NSColor(srgbRed: 0.99, green: 0.99, blue: 0.99, alpha: 1)
  55. default: return NSColor(srgbRed: 0.99, green: 0.98, blue: 0.995, alpha: 1)
  56. }
  57. }
  58. static func accentColor(for template: CVTemplate) -> NSColor {
  59. let palette = colors()
  60. switch template.accent {
  61. case .redUnderline, .redBar:
  62. return palette.accentRed
  63. case .blueBar:
  64. return template.themeColor
  65. case .none:
  66. return template.themeColor.blended(withFraction: 0.5, of: palette.ink) ?? template.themeColor
  67. }
  68. }
  69. static func sectionHeadingColor(for template: CVTemplate) -> NSColor {
  70. accentColor(for: template)
  71. }
  72. }