KMUnbindAlertViewController.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // KMUnbindAlertViewController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/8/7.
  6. //
  7. import Cocoa
  8. @objc class KMUnbindAlertViewController: NSViewController {
  9. @IBOutlet var contendView: NSView!
  10. @IBOutlet var titleLabel: NSTextField!
  11. @IBOutlet var contactButton: KMCustomButton!
  12. @objc var unbundHandle: ((_ controller: KMUnbindAlertViewController)->Void)?
  13. override func viewDidLoad() {
  14. super.viewDidLoad()
  15. // Do view setup here.
  16. self.contendView.wantsLayer = true
  17. self.titleLabel.font = NSFont.SFProTextRegularFont(16)
  18. self.titleLabel.stringValue = NSLocalizedString("You have reached the maximum number of unbindings, please contact us.", comment: "")
  19. self.contactButton.font = NSFont.SFProTextRegularFont(13)
  20. self.contactButton.wantsLayer = true
  21. self.contactButton.layer?.masksToBounds = true
  22. self.contactButton.layer?.cornerRadius = 1
  23. self.contactButton.title = NSLocalizedString("Contact Support", comment: "")
  24. self.contactButton.setTitleColor(NSColor.white)
  25. self.updateViewColor()
  26. }
  27. @objc func updateViewColor() {
  28. if KMAppearance.isDarkMode() {
  29. self.contendView.layer?.backgroundColor = NSColor(red: 33/255, green: 33/255, blue: 33/255, alpha: 1).cgColor
  30. self.titleLabel.textColor = NSColor.white
  31. self.contactButton.layer?.backgroundColor = NSColor(red: 78/255, green: 127/255, blue: 219/255, alpha: 1).cgColor
  32. } else {
  33. self.contendView.layer?.backgroundColor = NSColor.white.cgColor
  34. self.titleLabel.textColor = NSColor.black
  35. self.contactButton.layer?.backgroundColor = NSColor(red: 39/255, green: 60/255, blue: 98/255, alpha: 1).cgColor
  36. }
  37. }
  38. //MARK: - IBAction
  39. @IBAction func contactAction(_ sender: KMCustomButton) {
  40. guard let callBack = self.unbundHandle else {
  41. return
  42. }
  43. callBack(self)
  44. }
  45. }