123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // 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
-
- }
- }
- }
|