123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //
- // KMAIIconGuideView.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2024/3/1.
- //
- import Cocoa
- class KMAIIconGuideView: NSView, NibLoadable {
- @IBOutlet weak var contendView: NSView!
-
- @IBOutlet weak var shadowView: NSView!
-
- @IBOutlet weak var infoContendView: NSView!
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var subTitleLabel: NSTextField!
-
- @IBOutlet weak var finishBox: KMBox!
- @IBOutlet weak var finishBoxLabel: NSTextField!
- @IBOutlet weak var finishBoxBtn: KMButton!
-
- var clickHandle: ((_ view: KMAIIconGuideView, _ actionType: KMGuideActionType)->Void)?
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- deinit {
- DistributedNotificationCenter.default.removeObserver(self)
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- self.infoContendView.wantsLayer = true
- self.infoContendView.layer?.borderWidth = 2
- self.infoContendView.layer?.cornerRadius = 8
- self.infoContendView.layer?.masksToBounds = true
-
- self.titleLabel.stringValue = NSLocalizedString("Show/Hide AI robot icon", comment: "")
- self.subTitleLabel.stringValue = NSLocalizedString("Right-click to hide AI robot icon. Show the icon again from the top right corner “My AI Credit”. ", comment: "")
- self.finishBoxLabel.stringValue = NSLocalizedString("Got it", comment: "")
-
-
- self.finishBox.wantsLayer = true
- self.finishBox.borderWidth = 1
- self.finishBox.cornerRadius = 2
-
- self.finishBoxBtn.mouseMoveCallback = {[weak self] mouseEntered in
- if KMAppearance.isDarkMode() {
- if mouseEntered {
- self?.finishBox.fillColor = NSColor(red: 23/255, green: 85/255, blue: 178/255, alpha: 1)
- } else {
- self?.finishBox.fillColor = KMAppearance.KMColor_Interactive_A0()
- }
- } else {
- if mouseEntered {
- self?.finishBox.fillColor = NSColor(red: 39/255, green: 60/255, blue: 98/255, alpha: 1)
- } else {
- self?.finishBox.fillColor = NSColor(red: 56/255, green: 100/255, blue: 176/255, alpha: 1)
- }
- }
-
- }
-
- self.shadowView.wantsLayer = true
- self.shadowView.layer?.borderWidth = 0
- self.shadowView.layer?.shadowColor = NSColor.black.withAlphaComponent(0.55).cgColor
- self.shadowView.layer?.shadowOpacity = 0.1
- self.shadowView.layer?.shadowRadius = 3.0
- let shadowPath = NSBezierPath(rect: self.shadowView.bounds)
- if #available(macOS 14.0, *) {
- self.shadowView.layer?.shadowPath = shadowPath.PDFListViewCGPath()
- }
-
- DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChange), name: NSNotification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
- self.updateViewColor()
- }
-
- func updateViewColor() {
-
- if KMAppearance.isDarkMode() {
- self.infoContendView.layer?.borderColor = NSColor(red: 34/255, green: 122/255, blue: 255/255, alpha: 1).cgColor
- self.infoContendView.layer?.backgroundColor = NSColor.black.cgColor
- self.titleLabel.textColor = KMAppearance.KMColor_Layout_W0()
- self.subTitleLabel.textColor = KMAppearance.KMColor_Layout_H1()
- self.finishBoxLabel.textColor = NSColor.white
- self.finishBox.borderColor = NSColor.clear
- self.finishBox.fillColor = NSColor(red: 73/255, green: 130/255, blue: 230/255, alpha: 1)
-
-
- } else {
- self.infoContendView.layer?.borderColor = NSColor(red: 73/255, green: 130/255, blue: 230/255, alpha: 1).cgColor
- self.infoContendView.layer?.backgroundColor = NSColor.white.cgColor
- self.titleLabel.textColor = KMAppearance.KMColor_Layout_M()
- self.subTitleLabel.textColor = KMAppearance.KMColor_Layout_H0()
- self.finishBox.borderColor = NSColor.clear
- self.finishBox.fillColor = NSColor(red: 73/255, green: 130/255, blue: 230/255, alpha: 1)
- self.finishBoxLabel.textColor = NSColor.white
-
- }
-
- }
-
- //MARK: IBAction
- @IBAction func finishBtnAction(_ sender: KMButton) {
- guard let callBack = self.clickHandle else {
- return
- }
- callBack(self, .getIt)
- }
-
- @objc func themeChange() {
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
- self.updateViewColor()
- }
- }
- }
|