// // KMEditPDFCropComfirmWindowController.swift // PDF Reader Pro // // Created by tangchao on 2024/6/26. // import Cocoa class KMEditPDFCropComfirmWindowController: NSWindowController { @IBOutlet weak var leftBox: NSBox! @IBOutlet weak var rightBox: NSBox! private var leftVc_: KMDesignButton? private var rightVc_: KMDesignButton? var itemAction: KMCommonClickBlock? static let shared = KMEditPDFCropComfirmWindowController(windowNibName: "KMEditPDFCropComfirmWindowController") override func windowDidLoad() { super.windowDidLoad() // self.window?.backgroundColor = .white self.window?.contentView?.wantsLayer = true self.window?.contentView?.layer?.cornerRadius = 4 self.leftVc_ = KMDesignButton(withType: .Image) self.leftBox.contentView = self.leftVc_!.view self.leftBox.borderWidth = 0 self.leftVc_?.pagination() self.leftVc_?.target = self self.leftVc_?.action = #selector(_itemClick) self.leftVc_?.image = NSImage(named: "KMImageNameEditPDFCropComfirm")! self.leftVc_?.tag = 0 self.rightVc_ = KMDesignButton(withType: .Image) self.rightBox.contentView = self.rightVc_!.view self.rightBox.borderWidth = 0 self.rightVc_?.pagination() self.rightVc_?.target = self self.rightVc_?.action = #selector(_itemClick) self.rightVc_?.image = NSImage(named: "KMImageNameEditPDFCropCancel")! self.rightVc_?.tag = 1 } @objc private func _itemClick(_ sender: NSButton) { self.itemAction?(sender.tag) } override func showWindow(_ sender: Any?) { super.showWindow(sender) self.interfaceThemeDidChanged(NSApp.appearance?.name ?? .aqua) } } extension KMEditPDFCropComfirmWindowController: KMInterfaceThemeChangedProtocol { func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) { self.window?.appearance = .init(named: appearance) let isDark = appearance == .darkAqua if isDark { self.window?.backgroundColor = NSColor(red: 37/255.0, green: 37/255.0, blue: 38/255.0, alpha: 1.0) self.leftVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1) self.rightVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1) } else { self.window?.backgroundColor = .white self.leftVc_?.background_hov = KMAppearance.view_bg_dis_color() self.rightVc_?.background_hov = KMAppearance.view_bg_dis_color() } } }