// // KMLinkPopupBaseView.swift // PDF Reader Pro // // Created by Niehaoyu on 2024/10/18. // import Cocoa import KMComponentLibrary class KMLinkPopupBaseView: BaseXibView { @IBOutlet var contendBox: NSBox! @IBOutlet var baseView: NSView! @IBOutlet var pageButton: ComponentButton! @IBOutlet var webButton: ComponentButton! @IBOutlet var emailButton: ComponentButton! @IBOutlet var moreButton: ComponentButton! override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) // Drawing code here. } //MARK: - Setter var linkPopupType: PDFLinkPopupType = .None { didSet { self.refreshUI() self.reloadData() } } func setUpProperty() { pageButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, state: .normal, onlyIcon: false, showLeftIcon: true, showRightIcon: false, buttonText: KMLocalizedString("Page")) pageButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "") webButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, state: .normal, onlyIcon: false, showLeftIcon: true, showRightIcon: false, buttonText: KMLocalizedString("Web")) webButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "") emailButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, state: .normal, onlyIcon: false, showLeftIcon: true, showRightIcon: false, buttonText: KMLocalizedString("Email")) emailButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "") moreButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true) moreButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "") } func refreshUI() { var rect = self.frame if linkPopupType == .None { rect.size.width = 303 rect.size.height = 40 } else if linkPopupType == .Page { rect.size.width = 256 rect.size.height = 240 } else if linkPopupType == .Web { rect.size.width = 328 rect.size.height = 40 } else if linkPopupType == .Email { rect.size.width = 328 rect.size.height = 40 } NSAnimationContext.runAnimationGroup({ context in context.duration = 0.35 self.animator().frame = rect }, completionHandler: nil) } func reloadData() { } }