KMNoteReplyCellView.swift 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // KMNoteReplyCellView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/9/20.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. class KMNoteReplyCellView: NSTableCellView, NibLoadable {
  10. @IBOutlet weak var backgroundBox: KMBox!
  11. @IBOutlet weak var titleLabel: NSTextField!
  12. @IBOutlet weak var timeLabel: NSTextField!
  13. @IBOutlet weak var contentLabel: NSTextField!
  14. @IBOutlet weak var leftVorLineView: NSView!
  15. var itemClick: KMCommonClickBlock?
  16. var model: KMBotaAnnotationReplyModel?
  17. override func draw(_ dirtyRect: NSRect) {
  18. super.draw(dirtyRect)
  19. // Drawing code here.
  20. }
  21. override func awakeFromNib() {
  22. super.awakeFromNib()
  23. self.backgroundBox.borderWidth = 0
  24. self.backgroundBox.cornerRadius = 0
  25. self.backgroundBox.moveCallback = { enter, theBox in
  26. }
  27. NotificationCenter.default.addObserver(self, selector: #selector(updateUI), name: APPAppearanceChangedNotificationName, object: nil)
  28. self.updateUI()
  29. }
  30. @objc func moreAction(_ sender: NSButton) {
  31. self.itemClick?(1, sender)
  32. }
  33. override func mouseUp(with event: NSEvent) {
  34. super.mouseUp(with: event)
  35. }
  36. @objc func updateUI() {
  37. self.leftVorLineView.wantsLayer = true
  38. self.leftVorLineView.layer?.backgroundColor = ComponentLibrary.shared.getComponentColorFromKey("colorPrimary/border2").cgColor
  39. self.titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/1")
  40. self.titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
  41. self.timeLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-xs-regular")
  42. self.timeLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/3")
  43. self.timeLabel.lineBreakMode = .byTruncatingTail
  44. self.contentLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-regular")
  45. self.contentLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
  46. }
  47. override func updateLayer() {
  48. super.updateLayer()
  49. self.updateUI()
  50. }
  51. }