KMAppearance.swift 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // KMAppearance.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2023/4/17.
  6. //
  7. import Cocoa
  8. @objc class KMAppearance: NSObject {
  9. class func isDarkMode() -> Bool {
  10. var result = false
  11. if #available(macOS 10.14, *) {
  12. let appearanceName = NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua])
  13. if (appearanceName == .darkAqua) {
  14. return true
  15. }
  16. }
  17. return result
  18. }
  19. @objc class func titleColor() -> NSColor {
  20. if (!KMAppearance.isSupportNewColor()) {
  21. return NSColor.km_init(hex: "#252629")
  22. }
  23. if let _color = NSColor(named: "KMTitleColor") {
  24. return _color
  25. }
  26. return NSColor.km_init(hex: "#252629")
  27. }
  28. @objc class func subtitleColor() -> NSColor {
  29. if (!KMAppearance.isSupportNewColor()) {
  30. return NSColor.km_init(hex: "#616469")
  31. }
  32. if let _color = NSColor(named: "KMSubtitleColor") {
  33. return _color
  34. }
  35. return NSColor.km_init(hex: "#616469")
  36. }
  37. @objc class func view_bg_dis_color() -> NSColor {
  38. if (!KMAppearance.isSupportNewColor()) {
  39. return NSColor.km_init(hex: "#EDEEF0")
  40. }
  41. if let _color = NSColor(named: "KMBackgroundDisableColor") {
  42. return _color
  43. }
  44. return NSColor.km_init(hex: "#EDEEF0")
  45. }
  46. @objc class func view_border_dis_color() -> NSColor {
  47. if (!KMAppearance.isSupportNewColor()) {
  48. return NSColor.km_init(hex: "#DFE1E5")
  49. }
  50. if let _color = NSColor(named: "KMBorderDisableColor") {
  51. return _color
  52. }
  53. return NSColor.km_init(hex: "#DFE1E5")
  54. }
  55. class func isSupportNewColor() -> Bool {
  56. if #available(macOS 10.14, *) {
  57. return true
  58. }
  59. return false
  60. }
  61. }