HomeLynxGuideItem.swift 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // HomeLynxGuideItem.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/7/22.
  6. //
  7. import Cocoa
  8. class HomeLynxGuideItem: NSCollectionViewItem {
  9. @IBOutlet var contendBox: NSBox!
  10. @IBOutlet var contendView: NSView!
  11. @IBOutlet var iconImageview: NSImageView!
  12. @IBOutlet var titleLabel: NSTextField!
  13. @IBOutlet var subTitleLabel: NSTextField!
  14. @IBOutlet var clickBox: NSBox!
  15. @IBOutlet var clickBtn: KMButton!
  16. var model: HomeLynxGuideModel? {
  17. didSet {
  18. self.reloadData()
  19. }
  20. }
  21. override func viewDidLoad() {
  22. super.viewDidLoad()
  23. // Do view setup here.
  24. self.contendView.wantsLayer = true
  25. self.titleLabel.font = NSFont.SFProTextSemiboldFont(14)
  26. self.subTitleLabel.font = NSFont.SFProTextRegularFont(12)
  27. self.contendBox.borderWidth = 1.0;
  28. self.contendBox.borderColor = KMAppearance.Interactive.s0Color()
  29. self.clickBox.borderWidth = 0
  30. self.clickBox.cornerRadius = 4
  31. // self.clickBtn.mouseMoveCallback = {[weak self] mouseEntered in
  32. // if mouseEntered {
  33. // self?.clickBox.fillColor = NSColor(red: 255/255, green: 122/255, blue: 40/255, alpha: 1)
  34. // } else {
  35. // self?.clickBox.fillColor = KMAppearance.Interactive.a0Color()
  36. // }
  37. //
  38. // }
  39. }
  40. func reloadData() {
  41. guard let model = model else { return }
  42. self.titleLabel.stringValue = model.titleString()
  43. self.subTitleLabel.stringValue = model.subTitleString()
  44. self.iconImageview.image = model.iconImage()
  45. self.clickBtn.title = model.btnTitleString()
  46. if model.type == .AdminConsole {
  47. if (IAPProductsManager.default().isAvailableAllFunction()) {
  48. self.clickBtn.title = NSLocalizedString("Log in", comment: "")
  49. }
  50. }
  51. self.updateViewColor()
  52. }
  53. func updateViewColor() {
  54. if KMAppearance.isDarkMode() {
  55. self.titleLabel.textColor = NSColor.white
  56. self.subTitleLabel.textColor = NSColor(red: 200/255, green: 201/255, blue: 204/255, alpha: 1)
  57. } else {
  58. self.titleLabel.textColor = NSColor(red: 14/255, green: 17/255, blue: 20/255, alpha: 1)
  59. self.subTitleLabel.textColor = NSColor(red: 66/255, green: 70/255, blue: 77/255, alpha: 1)
  60. }
  61. self.clickBtn.setTitleColor(NSColor.white)
  62. guard let model = model else { return }
  63. if model.type == .AdminConsole {
  64. self.clickBox.fillColor = NSColor(red: 255/255, green: 122/255, blue: 40/255, alpha: 1)
  65. } else {
  66. self.clickBox.fillColor = KMAppearance.Interactive.a0Color()
  67. }
  68. }
  69. //IBAction
  70. @IBAction func btnClicked(_ sender: Any) {
  71. guard let model = model else { return }
  72. if model.type == .AdminConsole {
  73. FMTrackEventManager.defaultManager.lynxTrackEvent(event: "Home", withProperties: ["Home_Operations" : "admin_console_1"])
  74. if (IAPProductsManager.default().isAvailableAllFunction()) {
  75. let url = URL(string:"https://adminconsole.pdfreaderpro.com/login")!
  76. NSWorkspace.shared.open(url)
  77. } else {
  78. let url = URL(string:"https://www.pdfreaderpro.com/admin-console")!
  79. NSWorkspace.shared.open(url)
  80. }
  81. } else if model.type == .Onpremise {
  82. FMTrackEventManager.defaultManager.lynxTrackEvent(event: "Home", withProperties: ["Home_Operations" : "Serve_1"])
  83. let url = URL(string:"https://www.pdfreaderpro.com/lynxpdfeditor#premise")!
  84. NSWorkspace.shared.open(url)
  85. } else if model.type == .SSO {
  86. FMTrackEventManager.defaultManager.lynxTrackEvent(event: "Home", withProperties: ["Home_Operations" : "Serve_2"])
  87. let url = URL(string:"https://www.pdfreaderpro.com/lynxpdfeditor#sso")!
  88. NSWorkspace.shared.open(url)
  89. } else if model.type == .MultipleInstall {
  90. FMTrackEventManager.defaultManager.lynxTrackEvent(event: "Home", withProperties: ["Home_Operations" : "Serve_3"])
  91. let url = URL(string:"https://www.pdfreaderpro.com/lynxpdfeditor#various")!
  92. NSWorkspace.shared.open(url)
  93. } else if model.type == .CustomSolutions {
  94. FMTrackEventManager.defaultManager.lynxTrackEvent(event: "Home", withProperties: ["Home_Operations" : "Serve_4"])
  95. let (major, minor, bugFix) = KMTools.getSystemVersion()
  96. let versionInfoString = "\(KMTools.getRawSystemInfo()) - \(major).\(minor).\(bugFix)"
  97. let appVersion = KMTools.getAppVersion()
  98. let appName = KMTools.getAppNameForSupportEmail()
  99. let subjects = "\(appName) - \(appVersion);\(NSLocalizedString("Feedback", comment: ""));\(versionInfoString)"
  100. let email = "support@pdfreaderpro.com"
  101. KMMailHelper.newEmail(withContacts: email, andSubjects: subjects)
  102. } else if model.type == .BusinessFeature {
  103. FMTrackEventManager.defaultManager.lynxTrackEvent(event: "Home", withProperties: ["Home_Operations" : "Serve_5"])
  104. let url = URL(string:"https://www.pdfreaderpro.com/lynxpdfeditor#customized")!
  105. NSWorkspace.shared.open(url)
  106. }
  107. }
  108. }