// // KMConvertCollectionViewHeader.swift // PDF Reader Pro // // Created by kdanmobile on 2023/11/1. // import Cocoa typealias convertCollectionViewHeaderClickedCallBack = () -> () class KMConvertCollectionViewHeader: KMBaseXibView{ @IBOutlet var indicateLabel: NSTextField! @IBOutlet var imageView: NSImageView! @IBOutlet var infoLabel: NSTextField! @IBOutlet var containerView: NSView! var convertHeaderClickedCallBack: convertCollectionViewHeaderClickedCallBack? deinit { NotificationCenter.default.removeObserver(self) } override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) } override func awakeFromNib() { super.awakeFromNib() containerView.wantsLayer = true // containerView.layer?.cornerRadius = 12 // if IAPProductsManager.defaultManager().isAvailableAdvancedPDFToOffice { // containerView.isHidden = true // } // 购买状态变化通知 NotificationCenter.default.addObserver(self, selector: #selector(IAPProductRestoreFinishedNotification(notification:)), name: NSNotification.Name(rawValue: "KMIAPProductPurchasedNotification"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(IAPProductRestoreFinishedNotification(notification:)), name: NSNotification.Name(rawValue: "KMIAPProductRestoreFinishedNotification"), object: nil) } override func setup() { indicateLabel.font = NSFont.boldSystemFont(ofSize: 14) indicateLabel.textColor = KMAppearance.Layout.h0Color() indicateLabel.stringValue = NSLocalizedString("Convert", comment: "") infoLabel.font = NSFont.boldSystemFont(ofSize: 11) infoLabel.textColor = KMAppearance.Interactive.m0Color() infoLabel.stringValue = NSLocalizedString("Upgrade to Pro", comment: "") infoLabel.toolTip = NSLocalizedString("Upgrade to Pro", comment: "") } override func mouseUp(with event: NSEvent) { super.mouseUp(with: event) let point = event.locationInWindow let newPoint = convert(point, from: nil) // if let data = self.containerView?.frame.contains(newPoint), data { // if !IAPProductsManager.defaultManager().isAvailableAdvancedPDFToOffice { // self.convertHeaderClickedCallBack?() // } // } } @objc func IAPProductPurchasedNotification(notification: Notification) { // containerView.isHidden = true } @objc func IAPProductRestoreFinishedNotification(notification: Notification) { // containerView.isHidden = true } }