1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- //
- // KMFunctionGuideNameItemView.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2023/12/8.
- //
- import Cocoa
- class KMFunctionGuideNameItemView: NSView, NibLoadable {
-
- @IBOutlet weak var contendView: NSView!
- @IBOutlet weak var iconImg: NSImageView!
- @IBOutlet weak var nameLabel: NSTextField!
-
- var _infoDict = NSDictionary()
- var _isSelected = false
-
- var clickHandle: ((_ view: KMFunctionGuideNameItemView)->Void)?
-
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- self.setUp()
- }
-
- func setUp() {
- self.contendView.wantsLayer = true
- self.contendView.layer?.cornerRadius = 4
- self.contendView.layer?.masksToBounds = true
-
- self.nameLabel.font = NSFont.SFProTextSemiboldFont(14)
- self.updateViewColor()
- }
-
- func updateViewColor() {
- if KMAppearance.isDarkMode() {
- self.nameLabel.textColor = NSColor(red: 200/255, green: 201/255, blue: 204/255, alpha: 1)
- self.contendView.layer?.backgroundColor = NSColor.clear.cgColor
- self.iconImg.image = NSImage(named: "whatNewItemNormal")
- } else {
- self.nameLabel.textColor = NSColor(red: 66/255, green: 70/255, blue: 77/255, alpha: 1)
- self.contendView.layer?.backgroundColor = NSColor.clear.cgColor
- self.iconImg.image = NSImage(named: "whatNewItemNormal")
- }
- }
-
-
- //MARK: Setter
- var infoDict: NSDictionary {
- set {
- _infoDict = newValue
-
- self.nameLabel.stringValue = NSLocalizedString(self.infoDict["name"] as! String, comment: "")
- }
- get {
- return _infoDict
- }
- }
-
- var isSelected: Bool {
- set {
- _isSelected = newValue
-
- self.updateViewColor()
- }
- get {
- return _isSelected
- }
- }
-
- //MARK: IBAction
- @IBAction func clickAction(_ sender: Any) {
- guard let callBack = self.clickHandle else {
- return
- }
- callBack(self)
- }
-
- }
|