123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- //
- // KMComparativeTableViewController.swift
- // PDF Master
- //
- // Created by lizhe on 2023/2/24.
- //
- import Cocoa
- typealias KMComparativeTableViewControllerLoginAction = (_ controller: KMComparativeTableViewController) -> Void
- typealias KMComparativeTableViewControllerSignUpAction = (_ controller: KMComparativeTableViewController) -> Void
- var comparativeController: KMComparativeTableViewController?
- var comparativeMainWindow: NSWindow?
- class KMComparativeTableViewController: NSWindowController {
- @IBOutlet weak var comparativeTableView: KMComparativeTableView!
- var inputType: DataNavigationViewButtonActionType?
-
- var loginAction: KMComparativeTableViewControllerLoginAction?
- var signUpAction: KMComparativeTableViewControllerSignUpAction?
-
- deinit {
- print("KMComparativeTableViewController 释放")
- }
-
- //MARK: 打开文件
- /**
- @abstract 弹出比较表
- @param window 弹出window
- @param type 从什么页面跳转到比较表 默认batch
- */
- static func show(window: NSWindow, _ type: DataNavigationViewButtonActionType = .Batch) -> KMComparativeTableViewController {
- let controller: KMComparativeTableViewController = KMComparativeTableViewController.init(windowNibName: "KMComparativeTableViewController")
- controller.inputType = type
- controller.loginAction = { controller in
- comparativeController = nil
- comparativeMainWindow?.endSheet(controller.window!)
- comparativeMainWindow = nil
- controller.close()
- KMLoginWindowController.show(window: NSApp.mainWindow!, .Batch, .login)
- }
- controller.signUpAction = { controller in
- comparativeController = nil
- comparativeMainWindow?.endSheet(controller.window!)
- comparativeMainWindow = nil
- controller.close()
- KMLoginWindowController.show(window: NSApp.mainWindow!, .Batch, .register)
- }
- window.beginSheet(controller.window!)
- comparativeController = controller
- comparativeMainWindow = window
- return controller
- }
-
-
- override func windowDidLoad() {
- super.windowDidLoad()
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
- self.setup()
- }
-
- func setup() {
- self.window?.contentView?.backgroundColor(NSColor(hex: "FFFFFF"))
- self.comparativeTableView.closeAction = { view in
- print("关闭")
- comparativeMainWindow?.endSheet(view.window!)
- view.window?.close()
- comparativeController = nil
- comparativeMainWindow = nil
- }
-
- self.comparativeTableView.signUpAction = { [weak self] view in
- print("注册")
- guard let callBack = self?.signUpAction else { return }
- callBack(self!)
- }
- self.comparativeTableView.loginAction = { [weak self] view in
- print("登录")
- guard let callBack = self?.loginAction else { return }
- callBack(self!)
- }
- }
-
- }
|