12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // 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
- 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!
-
- var closeAction: KMComparativeTableViewCloseAction?
- var loginAction: KMComparativeTableViewLoginAction?
- var signUpAction: KMComparativeTableViewSignUpAction?
-
- 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()
-
- self.backgroundColor(NSColor(hex: "#F2F9FF"))
-
- self.loginButton.backgroundColor(NSColor(hex: "#1770F4"))
- self.loginButton.border(NSColor(hex: "#1770F4"), 1, 4)
- self.loginButton.contentTintColor = NSColor(hex: "FFFFFF")
-
- self.signUpButton.contentTintColor = NSColor(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)
- }
- }
|