KMEditPDFCropComfirmWindowController.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // KMEditPDFCropComfirmWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2024/6/26.
  6. //
  7. import Cocoa
  8. class KMEditPDFCropComfirmWindowController: NSWindowController {
  9. @IBOutlet weak var leftBox: NSBox!
  10. @IBOutlet weak var rightBox: NSBox!
  11. private var leftVc_: KMDesignButton?
  12. private var rightVc_: KMDesignButton?
  13. var itemAction: KMCommonClickBlock?
  14. static let shared = KMEditPDFCropComfirmWindowController(windowNibName: "KMEditPDFCropComfirmWindowController")
  15. override func windowDidLoad() {
  16. super.windowDidLoad()
  17. // self.window?.backgroundColor = .white
  18. self.window?.contentView?.wantsLayer = true
  19. self.window?.contentView?.layer?.cornerRadius = 4
  20. self.leftVc_ = KMDesignButton(withType: .Image)
  21. self.leftBox.contentView = self.leftVc_!.view
  22. self.leftBox.borderWidth = 0
  23. self.leftVc_?.pagination()
  24. self.leftVc_?.target = self
  25. self.leftVc_?.action = #selector(_itemClick)
  26. self.leftVc_?.image = NSImage(named: "KMImageNameEditPDFCropComfirm")!
  27. self.leftVc_?.tag = 0
  28. self.rightVc_ = KMDesignButton(withType: .Image)
  29. self.rightBox.contentView = self.rightVc_!.view
  30. self.rightBox.borderWidth = 0
  31. self.rightVc_?.pagination()
  32. self.rightVc_?.target = self
  33. self.rightVc_?.action = #selector(_itemClick)
  34. self.rightVc_?.image = NSImage(named: "KMImageNameEditPDFCropCancel")!
  35. self.rightVc_?.tag = 1
  36. }
  37. @objc private func _itemClick(_ sender: NSButton) {
  38. self.itemAction?(sender.tag)
  39. }
  40. override func showWindow(_ sender: Any?) {
  41. super.showWindow(sender)
  42. self.interfaceThemeDidChanged(NSApp.appearance?.name ?? .aqua)
  43. }
  44. }
  45. extension KMEditPDFCropComfirmWindowController: KMInterfaceThemeChangedProtocol {
  46. func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) {
  47. self.window?.appearance = .init(named: appearance)
  48. let isDark = appearance == .darkAqua
  49. if isDark {
  50. self.window?.backgroundColor = NSColor(red: 37/255.0, green: 37/255.0, blue: 38/255.0, alpha: 1.0)
  51. self.leftVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
  52. self.rightVc_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
  53. } else {
  54. self.window?.backgroundColor = .white
  55. self.leftVc_?.background_hov = KMAppearance.view_bg_dis_color()
  56. self.rightVc_?.background_hov = KMAppearance.view_bg_dis_color()
  57. }
  58. }
  59. }