KMConvertCollectionViewHeader.swift 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // KMConvertCollectionViewHeader.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by kdanmobile on 2023/11/1.
  6. //
  7. import Cocoa
  8. typealias convertCollectionViewHeaderClickedCallBack = () -> ()
  9. class KMConvertCollectionViewHeader: KMBaseXibView{
  10. @IBOutlet var indicateLabel: NSTextField!
  11. @IBOutlet var imageView: NSImageView!
  12. @IBOutlet var infoLabel: NSTextField!
  13. @IBOutlet var containerView: NSView!
  14. var convertHeaderClickedCallBack: convertCollectionViewHeaderClickedCallBack?
  15. deinit {
  16. NotificationCenter.default.removeObserver(self)
  17. }
  18. override func draw(_ dirtyRect: NSRect) {
  19. super.draw(dirtyRect)
  20. }
  21. override func awakeFromNib() {
  22. super.awakeFromNib()
  23. containerView.wantsLayer = true
  24. // containerView.layer?.cornerRadius = 12
  25. // if IAPProductsManager.defaultManager().isAvailableAdvancedPDFToOffice {
  26. // containerView.isHidden = true
  27. // }
  28. // 购买状态变化通知
  29. NotificationCenter.default.addObserver(self, selector: #selector(IAPProductRestoreFinishedNotification(notification:)), name: NSNotification.Name(rawValue: "KMIAPProductPurchasedNotification"), object: nil)
  30. NotificationCenter.default.addObserver(self, selector: #selector(IAPProductRestoreFinishedNotification(notification:)), name: NSNotification.Name(rawValue: "KMIAPProductRestoreFinishedNotification"), object: nil)
  31. }
  32. override func setup() {
  33. indicateLabel.font = NSFont.boldSystemFont(ofSize: 14)
  34. indicateLabel.textColor = KMAppearance.Layout.h0Color()
  35. indicateLabel.stringValue = NSLocalizedString("Convert", comment: "")
  36. infoLabel.font = NSFont.boldSystemFont(ofSize: 11)
  37. infoLabel.textColor = KMAppearance.Interactive.m0Color()
  38. infoLabel.stringValue = NSLocalizedString("Upgrade to Pro", comment: "")
  39. infoLabel.toolTip = NSLocalizedString("Upgrade to Pro", comment: "")
  40. }
  41. override func mouseUp(with event: NSEvent) {
  42. super.mouseUp(with: event)
  43. let point = event.locationInWindow
  44. let newPoint = convert(point, from: nil)
  45. // if let data = self.containerView?.frame.contains(newPoint), data {
  46. // if !IAPProductsManager.defaultManager().isAvailableAdvancedPDFToOffice {
  47. // self.convertHeaderClickedCallBack?()
  48. // }
  49. // }
  50. }
  51. @objc func IAPProductPurchasedNotification(notification: Notification) {
  52. // containerView.isHidden = true
  53. }
  54. @objc func IAPProductRestoreFinishedNotification(notification: Notification) {
  55. // containerView.isHidden = true
  56. }
  57. }