123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // KMAccountExceptionView.swift
- // PDF Reader Pro
- //
- // Created by lizhe on 2023/9/4.
- //
- import Cocoa
- typealias KMAccountExceptionViewCancelAction = (_ view: KMAccountExceptionView) -> Void
- class KMAccountExceptionView: KMBaseXibView {
- @IBOutlet var textView: NSTextView!
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var doneButton: NSButton!
-
- @IBOutlet weak var closeButton: NSButton!
- @IBOutlet weak var closeBox: KMBox!
-
-
- var cancelAction: KMAccountExceptionViewCancelAction?
-
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- override func setup() {
- self.closeBox.moveCallback = { [weak self] (mouseEntered, mouseBox) in
- if mouseEntered {
- self?.closeButton?.image = NSImage(named: "control_btn_icon_close_hov")
- } else {
- self?.closeButton?.image = NSImage(named: "control_btn_icon_close")
- }
- }
-
- self.textView.delegate = self
- self.textView.frame = (self.textView.enclosingScrollView?.contentView.bounds)!
- self.textView.autoresizingMask = [.width, .height]
- self.textView.font = NSFont.SFProTextRegularFont(14)
-
- self.titleLabel.textColor = NSColor.km_init(hex: "#252629")
- self.titleLabel.font = NSFont.SFProTextSemiboldFont(20)
-
- self.doneButton.backgroundColor(NSColor.km_init(hex: "#1770F4"))
- self.doneButton.contentTintColor = NSColor.km_init(hex: "#FFFFFF")
- self.doneButton.font = NSFont.SFProTextRegularFont(14)
- self.doneButton.border(NSColor.clear, 0, 4)
- }
-
- override func updateLanguage() {
-
- self.titleLabel.stringValue = NSLocalizedString("Account Blocked", comment: "")
- //singin
- let string = NSLocalizedString("Your account is currently blocked due to frequent switching, during which you can still use the free basics function normally.To unblock the account, please contact us and provide complaint instructions.", comment: "")
- let attributedString = NSMutableAttributedString.init(string: string)
- let paragraphStyle = NSMutableParagraphStyle()
- paragraphStyle.alignment = .center;
- paragraphStyle.lineHeightMultiple = 1.32
- paragraphStyle.lineBreakMode = .byWordWrapping
- attributedString.addAttributes([NSAttributedString.Key.font : NSFont.SFProTextRegularFont(14.0),
- NSAttributedString.Key.foregroundColor : NSColor.km_init(hex: "#616469"),
- NSAttributedString.Key.paragraphStyle : paragraphStyle],
- range: NSRange(location: 0, length: string.count))
- let range = string.range(of: NSLocalizedString("contact us", comment: ""))
- attributedString.setAttributes([NSAttributedString.Key.font : NSFont.SFProTextRegularFont(14.0),
- NSAttributedString.Key.foregroundColor : NSColor.km_init(hex: "#1770F4"),
- NSAttributedString.Key.underlineColor : NSColor.clear,
- NSAttributedString.Key.link : "timer://"],
- range: string.nsRange(from: range!)!)
- self.textView.textStorage?.setAttributedString(attributedString)
- }
-
-
- @IBAction func doneAction(_ sender: Any) {
- guard let callBack = cancelAction else { return }
-
- callBack(self)
- }
-
- @IBAction func closeButtonAction(_ sender: Any) {
- guard let callBack = cancelAction else { return }
-
- callBack(self)
- }
- }
- extension KMAccountExceptionView: NSTextViewDelegate {
- func textView(_ textView: NSTextView, clickedOnLink link: Any, at charIndex: Int) -> Bool {
- if link as! String == "timer://" {
- // guard let callBack = reSendAction else { return true }
- // textView.isSelectable = false
- // callBack(self, textView)
- NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/contact")!)
- }
- return true
- }
- }
|