// // KMComparativeTableView.swift // PDF Master // // Created by lizhe on 2023/2/24. // import Cocoa typealias KMComparativeTableViewCloseAction = (_ view: KMComparativeTableView) -> Void typealias KMComparativeTableViewLoginAction = (_ view: KMComparativeTableView) -> Void typealias KMComparativeTableViewSignUpAction = (_ view: KMComparativeTableView) -> Void typealias KMComparativeTableViewSubscriptionAction = (_ view: KMComparativeTableView) -> Void typealias KMComparativeTableViewRestoreAction = (_ view: KMComparativeTableView) -> Void class KMComparativeTableView: KMBaseXibView { @IBOutlet weak var closeBox: KMBox! @IBOutlet weak var closeButton: NSButton! @IBOutlet weak var signUpButton: NSButton! @IBOutlet weak var loginButton: NSButton! @IBOutlet weak var outlineView: KMComparativeOutlineView! @IBOutlet weak var restoreButton: NSButton! @IBOutlet weak var waterMarkButton: NSButton! var closeAction: KMComparativeTableViewCloseAction? var loginAction: KMComparativeTableViewLoginAction? var signUpAction: KMComparativeTableViewSignUpAction? var subscriptionAction: KMComparativeTableViewSubscriptionAction? var restoreAction: KMComparativeTableViewRestoreAction? override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) // Drawing code here. } override func setup() { super.setup() self.closeBox.moveCallback = { [weak self] (mouseEntered, mouseBox) in if mouseEntered { self?.closeButton.image = NSImage(named: "control_btn_icon_close_hov") } else { self?.closeButton.image = NSImage(named: "control_btn_icon_close") } } } override func updateUI() { super.updateUI() #if VERSION_FREE self.restoreButton.isHidden = false #endif if KMPurchaseManager.manager.state == .subscription { self.waterMarkButton.isHidden = true } self.backgroundColor(NSColor.km_init(hex: "#F2F9FF")) self.loginButton.backgroundColor(NSColor.km_init(hex: "#1770F4")) self.loginButton.border(NSColor.km_init(hex: "#1770F4"), 1, 4) self.loginButton.contentTintColor = NSColor.km_init(hex: "FFFFFF") self.signUpButton.contentTintColor = NSColor.km_init(hex: "#1770F4") } override func reloadData() { super.reloadData() } override func updateLanguage() { super.updateLanguage() self.signUpButton.title = NSLocalizedString("Sign Up", comment: "") self.loginButton.title = NSLocalizedString("Log In", comment: "") } } protocol KMComparativeTableViewAction {} extension KMComparativeTableView: KMComparativeTableViewAction { @IBAction func closeButtonAction(_ sender: Any) { guard let callBack = closeAction else { return } callBack(self) } @IBAction func signUpButtonAction(_ sender: Any) { guard let callBack = signUpAction else { return } callBack(self) } @IBAction func loginButtonAction(_ sender: Any) { guard let callBack = loginAction else { return } callBack(self) } @IBAction func subscriptionButtonAction(_ sender: Any) { guard let callBack = subscriptionAction else { return } callBack(self) } @IBAction func restoreButtonAction(_ sender: Any) { guard let callBack = restoreAction else { return } callBack(self) } @IBAction func waterMarkButtonAction(_ sender: Any) { KMSubscribeWaterMarkWindowController.show(window: self.window ?? NSWindow()) { isSubscribeSuccess, isWaterMark, isClose in } } }