// // KMSectionCellView.swift // PDF Reader Pro // // Created by User-Tangchao on 2024/9/18. // import Cocoa import KMComponentLibrary class KMAnnotationSectionCellView: NSTableCellView, NibLoadable { @IBOutlet weak var titleLabel: NSTextField! @IBOutlet weak var countLabel: NSTextField! @IBOutlet weak var expandButton: NSButton! @IBOutlet weak var titleLeftConst: NSLayoutConstraint! var contentInset: NSEdgeInsets = .init() var itemClick: KMCommonClickBlock? var isExpand = false { didSet { if self.isExpand { self.expandButton.image = NSImage(named: "KMImageNameBotaNoteExpand") } else { self.expandButton.image = NSImage(named: "KMImageNameBotaNoteNoExpand") } } } override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) // Drawing code here. } override func awakeFromNib() { super.awakeFromNib() titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium") countLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-regular") NotificationCenter.default.addObserver(self, selector: #selector(updateUI), name: APPAppearanceChangedNotificationName, object: nil) self.updateUI() self.expandButton.target = self self.expandButton.action = #selector(expandAction) } @objc func expandAction() { self.itemClick?(1) } @objc func updateUI() { titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/1") countLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/3") } override func updateLayer() { super.updateLayer() self.updateUI() } }