// // KMPurchaseFirstTrialWindowController.swift // PDF Reader Pro Edition // // Created by zenghong on 11/22/23. // import Cocoa @objc class KMPurchaseFirstTrialWindowController: NSWindowController,NSTextFieldDelegate,NSTextViewDelegate, NSWindowDelegate { @IBOutlet weak var contentImageView: NSImageView! @IBOutlet weak var titleField: NSTextField! @IBOutlet weak var rView: NSView! @IBOutlet weak var trialTitleField: NSTextField! @IBOutlet weak var trialMessageField: NSTextField! @IBOutlet weak var trialFeaturesField: NSTextField! @IBOutlet weak var imageView1: NSImageView! @IBOutlet weak var imageView2: NSImageView! @IBOutlet weak var imageView3: NSImageView! @IBOutlet weak var imageView4: NSImageView! @IBOutlet weak var imageView5: NSImageView! @IBOutlet weak var imageView6: NSImageView! @IBOutlet weak var imageView7: NSImageView! @IBOutlet weak var features1Field: NSTextField! @IBOutlet weak var features2Field: NSTextField! @IBOutlet weak var features3Field: NSTextField! @IBOutlet weak var features4Field: NSTextField! @IBOutlet weak var features5Field: NSTextField! @IBOutlet weak var features6Field: NSTextField! @IBOutlet weak var nameTextFieldView: NSView! @IBOutlet weak var nameTextField: NSTextField! @IBOutlet weak var nameInvalidLabel: NSTextField! @IBOutlet weak var emailTextFieldView: NSView! @IBOutlet weak var emailTextField: NSTextField! @IBOutlet weak var emailInvalidLabel: NSTextField! @IBOutlet var bottomTextView: NSTextView! //CustomTextView! @IBOutlet weak var btnBox: NSBox! @IBOutlet weak var activateTrialNowBtn: KMButton! @IBOutlet weak var buyNowBox: NSBox! @IBOutlet weak var buyNowBtn: HyperLinkButton! @IBOutlet weak var enterLicenseBox: NSBox! @IBOutlet weak var enterLicenseBtn: HyperLinkButton! static var currentWindowController: KMPurchaseFirstTrialWindowController! @objc var buttonActionBlock: ((_ firstTrialWinVC: KMPurchaseFirstTrialWindowController, _ btn: KMButton, _ email : String, _ name : String)->Void)? //MARK: 打开文件 @objc static func currentFirstTrialWC() -> KMPurchaseFirstTrialWindowController { if currentWindowController != nil { return currentWindowController } else { let configWC: KMPurchaseFirstTrialWindowController = KMPurchaseFirstTrialWindowController.init(windowNibName: "KMPurchaseFirstTrialWindowController") currentWindowController = configWC; return currentWindowController } } deinit { DistributedNotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self) } override func windowDidLoad() { super.windowDidLoad() DistributedNotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name(rawValue:"AppleInterfaceThemeChangedNotification"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(windowDidBecomeVisible(_:)), name: NSWindow.didBecomeKeyNotification, object: nil) self.window?.delegate = self self.activateTrialNowBtn.tag = 10001 self.buyNowBtn.tag = 10002 self.enterLicenseBtn.tag = 10003 // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. self.emailTextField.delegate = self self.nameTextField.delegate = self self.nameTextFieldView.wantsLayer = true self.nameTextFieldView.layer?.masksToBounds = true self.nameTextFieldView.layer?.cornerRadius = 4.0 self.emailTextFieldView.wantsLayer = true self.emailTextFieldView.layer?.masksToBounds = true self.emailTextFieldView.layer?.cornerRadius = 4.0 self.bottomTextView.delegate = self; self.titleField.wantsLayer = true self.titleField.alphaValue = 0.8 self.imageView2.wantsLayer = true self.imageView2.alphaValue = 0.8 self.imageView3.wantsLayer = true self.imageView3.alphaValue = 0.8 self.imageView4.wantsLayer = true self.imageView4.alphaValue = 0.8 self.imageView5.wantsLayer = true self.imageView5.alphaValue = 0.8 self.imageView6.wantsLayer = true self.imageView6.alphaValue = 0.8 self.imageView7.wantsLayer = true self.imageView7.alphaValue = 0.8 self.features1Field.wantsLayer = true self.features1Field.alphaValue = 0.8 self.features2Field.wantsLayer = true self.features2Field.alphaValue = 0.8 self.features2Field.wantsLayer = true self.features2Field.alphaValue = 0.8 self.features2Field.wantsLayer = true self.features2Field.alphaValue = 0.8 self.features2Field.wantsLayer = true self.features2Field.alphaValue = 0.8 self.features2Field.wantsLayer = true self.features2Field.alphaValue = 0.8 self.reloadData() } @objc func reloadData () { self.titleField.stringValue = NSLocalizedString("Unlock All Advanced Features", comment: "") let customFont = NSFont(name: "Ubuntu Bold", size: 16) self.titleField.font = customFont self.trialTitleField.stringValue = "👋🏻 " + NSLocalizedString("7-day Free Trial", comment: "") self.trialTitleField.font = NSFont(name: "Ubuntu-Bold", size: 26) self.trialMessageField.stringValue = NSLocalizedString("PDF Reader Pro offers a 7-day free trial of the full functions.", comment: "") self.trialMessageField.font = NSFont(name: "SFProText-Regular", size: 14) self.trialFeaturesField.stringValue = NSLocalizedString("Enter your email to get free trial:", comment: "") self.trialFeaturesField.font = NSFont(name: "SFProText-Semibold", size: 16) self.features1Field.stringValue = NSLocalizedString("Edit PDF", comment: "") self.features2Field.stringValue = NSLocalizedString("Organize pages", comment: "") self.features3Field.stringValue = NSLocalizedString("Convert PDFs ", comment: "") self.features4Field.stringValue = NSLocalizedString("Digital signature", comment: "") self.features5Field.stringValue = NSLocalizedString("Create & fill form", comment: "") self.features6Field.stringValue = NSLocalizedString("OCR", comment: "") self.features1Field.font = NSFont(name: "SFProText-Regular", size: 13) self.features2Field.font = NSFont(name: "SFProText-Regular", size: 13) self.features3Field.font = NSFont(name: "SFProText-Regular", size: 13) self.features4Field.font = NSFont(name: "SFProText-Regular", size: 13) self.features5Field.font = NSFont(name: "SFProText-Regular", size: 13) self.features6Field.font = NSFont(name: "SFProText-Regular", size: 13) self.nameTextField.placeholderString = NSLocalizedString("User name", comment: "") self.emailTextField.placeholderString = NSLocalizedString("Email", comment: "") self.nameTextField.font = NSFont(name: "SFProText-Regular", size: 14) self.emailTextField.font = NSFont(name: "SFProText-Regular", size: 14) self.nameTextField.becomeFirstResponder() self.nameInvalidLabel.stringValue = NSLocalizedString("Please enter valid username", comment: "") self.emailInvalidLabel.stringValue = NSLocalizedString("Please enter valid email", comment: "") self.nameInvalidLabel.isHidden = true self.emailInvalidLabel.isHidden = true self.activateTrialNowBtn.title = NSLocalizedString("Apply", comment: "") self.activateTrialNowBtn.font = NSFont(name: "Ubuntu-Medium", size: 16) self.buyNowBtn.font = NSFont(name: "SFProText-semibold", size: 14) self.enterLicenseBtn.font = NSFont(name: "SFProText-semibold", size: 14) self.rView.wantsLayer = true self.rView.layer?.cornerRadius = 8 self.rView.layer?.masksToBounds = true self.btnBox.wantsLayer = true self.btnBox.layer?.cornerRadius = 24 self.updateViewColor() } //MARK: Noti @objc func themeChanged(_ notification: NSNotification) { DispatchQueue.main.async { self.reloadData() } } @objc func windowDidBecomeVisible(_ obj: Notification) { self.reloadData() } @objc func updateViewColor () { self.trialMessageField.textColor = KMAppearance.Layout.h0Color() self.trialFeaturesField.textColor = KMAppearance.Layout.h0Color() self.features1Field.textColor = NSColor(red: 14.0/255.0, green: 17.0/255.0, blue: 20.0/255.0, alpha: 1) self.features2Field.textColor = NSColor(red: 14.0/255.0, green: 17.0/255.0, blue: 20.0/255.0, alpha: 1) self.features3Field.textColor = NSColor(red: 14.0/255.0, green: 17.0/255.0, blue: 20.0/255.0, alpha: 1) self.features4Field.textColor = NSColor(red: 14.0/255.0, green: 17.0/255.0, blue: 20.0/255.0, alpha: 1) self.features5Field.textColor = NSColor(red: 14.0/255.0, green: 17.0/255.0, blue: 20.0/255.0, alpha: 1) self.features6Field.textColor = NSColor(red: 14.0/255.0, green: 17.0/255.0, blue: 20.0/255.0, alpha: 1) self.nameTextFieldView.layer?.borderWidth = 1.0 if (KMAppearance.isDarkMode)(){ self.nameTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.nameTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } self.emailTextFieldView.layer?.borderWidth = 1.0 if (KMAppearance.isDarkMode)(){ self.emailTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.emailTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } if (KMAppearance.isDarkMode)() { self.nameTextField.textColor = KMAppearance.Layout.w0Color() self.emailTextField.textColor = KMAppearance.Layout.w0Color() self.rView.layer?.backgroundColor = NSColor(red: 24.0/255.0, green: 22.0/255.0, blue: 31.0/255.0, alpha: 0.9).cgColor self.activateTrialNowBtn.title = NSLocalizedString("Free Trial", comment: "") self.btnBox.fillColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1) self.btnBox.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor self.activateTrialNowBtn.setTitleColor(NSColor(red: 7.0/255.0, green: 1.0/255.0, blue: 34.0/255.0, alpha: 1)) self.activateTrialNowBtn.mouseMoveCallback = {[weak self] (mouseEntered) in if mouseEntered { self?.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1).cgColor self?.btnBox.fillColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1) self?.btnBox.layer?.backgroundColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1).cgColor } else { self?.btnBox.fillColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1) self?.btnBox.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor self?.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor } } // self.activateTrialNowBtn.setBaseLineOffset(2) self.titleField.textColor = NSColor(red: 0.0/255.0, green: 33.0/255.0, blue: 67.0/255.0, alpha: 1) self.trialTitleField.textColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1) self.buyNowBtn.title = NSLocalizedString("Buy Now", comment: "") self.buyNowBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1)) self.buyNowBtn.mouseMoveCallback = {[weak self] (mouseEntered) in if mouseEntered { self?.buyNowBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1)) } else { self?.buyNowBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1)) } } self.enterLicenseBtn.title = NSLocalizedString("Enter License", comment: "") self.enterLicenseBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1)) self.enterLicenseBtn.mouseMoveCallback = {[weak self] (mouseEntered) in if mouseEntered { self?.enterLicenseBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1)) } else { self?.enterLicenseBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1)) } } self.nameTextFieldView.layer?.backgroundColor = NSColor(red: 57.0/255.0, green: 58.0/255.0, blue: 70.0/255.0, alpha: 1).cgColor self.emailTextFieldView.layer?.backgroundColor = NSColor(red: 57.0/255.0, green: 58.0/255.0, blue: 70.0/255.0, alpha: 1).cgColor let stringValue : String = NSLocalizedString("By applying for free trial, you confirm that you agree this Privacy Policy.", comment: "") let attributedString: NSMutableAttributedString = NSMutableAttributedString(string: NSLocalizedString("By applying for free trial, you confirm that you agree this Privacy Policy.", comment: "")) let privacyPolicy : String = NSLocalizedString("Privacy Policy.", comment: "") let allRange = (stringValue as NSString).range(of: stringValue) attributedString.addAttributes([NSAttributedString.Key.foregroundColor : KMAppearance.Layout.w70Color()], range: allRange) attributedString.addAttributes([NSAttributedString.Key.font :NSFont(name: "SFProText-Regular", size: 12.0) as Any], range: allRange) let urlString : String = "https://www.pdfreaderpro.com/privacy-policy" let encodedURLString : String = urlString.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)! let linkRange = (stringValue as NSString).range(of: privacyPolicy) attributedString.addAttribute(.link, value: NSURL(string: encodedURLString)!, range: linkRange) attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: linkRange) self.bottomTextView.linkTextAttributes = [ NSAttributedString.Key.foregroundColor: KMAppearance.Interactive.a0Color(), NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue ] self.bottomTextView.textStorage?.setAttributedString(attributedString) self.bottomTextView.isEditable = false // TextView不可编辑 self.bottomTextView.isSelectable = true // TextView可选择 self.bottomTextView.sizeToFit() } else { self.nameTextField.textColor = KMAppearance.Layout.h0Color() self.emailTextField.textColor = KMAppearance.Layout.h0Color() self.rView.layer?.backgroundColor = NSColor(red: 248.0/255.0, green: 249.0/255.0, blue: 255.0/255.0, alpha: 1).cgColor self.btnBox.fillColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1) self.btnBox.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor self.activateTrialNowBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1)) self.activateTrialNowBtn.mouseMoveCallback = {[weak self] (mouseEntered) in if mouseEntered { self?.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 0.0/255.0, green: 207.0/255.0, blue: 133.0/255.0, alpha: 1).cgColor self?.btnBox.fillColor = NSColor(red: 0.0/255.0, green: 207.0/255.0, blue: 133.0/255.0, alpha: 1) self?.btnBox.layer?.backgroundColor = NSColor(red: 0.0/255.0, green: 207.0/255.0, blue: 133.0/255.0, alpha: 1).cgColor } else { self?.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor self?.btnBox.fillColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1) self?.btnBox.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor } } self.titleField.textColor = NSColor(red: 0.0/255.0, green: 33.0/255.0, blue: 67.0/255.0, alpha: 1) self.trialTitleField.textColor = NSColor(red: 0.0/255.0, green: 33.0/255.0, blue: 67.0/255.0, alpha: 1) self.buyNowBtn.title = NSLocalizedString("Buy Now", comment: "") self.buyNowBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1)) self.buyNowBtn.mouseMoveCallback = {[weak self] (mouseEntered) in if mouseEntered { self?.buyNowBtn.setTitleColor(NSColor(red: 8.0/255.0, green: 124.0/255.0, blue: 255.0/255.0, alpha: 1)) } else { self?.buyNowBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1)) } } self.enterLicenseBtn.title = NSLocalizedString("Enter License", comment: "") self.enterLicenseBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1)) self.enterLicenseBtn.mouseMoveCallback = {[weak self] (mouseEntered) in if mouseEntered { self?.enterLicenseBtn.setTitleColor(NSColor(red: 8.0/255.0, green: 124.0/255.0, blue: 255.0/255.0, alpha: 1)) } else { self?.enterLicenseBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1)) } } self.nameTextFieldView.layer?.backgroundColor = NSColor(red: 235.0/255.0, green: 236.0/255.0, blue: 250.0/255.0, alpha: 1).cgColor self.emailTextFieldView.layer?.backgroundColor = NSColor(red: 235.0/255.0, green: 236.0/255.0, blue: 250.0/255.0, alpha: 1).cgColor let stringValue : String = NSLocalizedString("By applying for free trial, you confirm that you agree this Privacy Policy.", comment: "") let attributedString: NSMutableAttributedString = NSMutableAttributedString(string: NSLocalizedString("By applying for free trial, you confirm that you agree this Privacy Policy.", comment: "")) let privacyPolicy : String = NSLocalizedString("Privacy Policy.", comment: "") let urlString : String = "https://www.pdfreaderpro.com/privacy-policy" let encodedURLString : String = urlString.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)! let linkRange = (stringValue as NSString).range(of: privacyPolicy) attributedString.addAttribute(NSAttributedString.Key.link, value: NSURL(string: encodedURLString)!, range: linkRange) attributedString.addAttribute(NSAttributedString.Key.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: linkRange) let allRange = (stringValue as NSString).range(of: stringValue) attributedString.addAttributes([NSAttributedString.Key.foregroundColor : KMAppearance.Layout.h1Color()], range: allRange) attributedString.addAttributes([NSAttributedString.Key.font :NSFont(name: "SFProText-Regular", size: 12.0) as Any], range: allRange) // 设置悬停时链接文本颜色 // let hoverColor = NSColor.blue // attributedString.addAttribute(NSAttributedString.Key(rawValue: "NSMouseInRectAttribute"), value: hoverColor, range: linkRange) // 设置TextView的富文本属性 self.bottomTextView.linkTextAttributes = [ NSAttributedString.Key.foregroundColor: KMAppearance.Interactive.a0Color(), NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue ] self.bottomTextView.textStorage?.setAttributedString(attributedString) self.bottomTextView.isEditable = false // TextView不可编辑 self.bottomTextView.isSelectable = true // TextView可选择 self.bottomTextView.sizeToFit() } self.buyNowBtn.sizeToFit() self.enterLicenseBtn.sizeToFit() } func validateEmail(_ strEmail: String) -> Bool { let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}" let emailTest: NSPredicate = NSPredicate(format: "SELF MATCHES %@", emailRegex) return emailTest.evaluate(with: strEmail) } //MARK: Btn Action @IBAction func activateTrialNowAction(_ sender: KMButton) { guard let callBack = self.buttonActionBlock else { return } var isValidate: Bool = true if self.validateEmail(self.emailTextField.stringValue) == true { self.emailInvalidLabel.isHidden = true isValidate = true && isValidate } else { self.emailInvalidLabel.isHidden = false isValidate = false && isValidate } if self.nameTextField.stringValue.isEmpty == false { self.nameInvalidLabel.isHidden = true isValidate = true && isValidate } else { self.nameInvalidLabel.isHidden = false isValidate = false && isValidate } if isValidate == false { return } callBack(self,sender,self.emailTextField.stringValue,self.nameTextField.stringValue) FMTrackEventManager.defaultManager.trackOnceEvent(event: "PUW", withProperties: ["PUW_Btn":"Btn_PUW_ActivateTrialNow"]) } @IBAction func buyNowAction(_ sender: HyperLinkButton) { // guard let callBack = self.buttonActionBlock else { // return // } // callBack(self,sender,self.emailTextField.stringValue,self.nameTextField.stringValue) // FMTrackEventManager.defaultManager.trackOnceEvent(event: "PUW", withProperties: ["PUW_Btn":"Btn_PUW_BuyNow"]) #if VERSION_DMG let singleTon = KMPurchaseCompareDMGWindowController.init() singleTon.showWindow(nil) singleTon.window?.center() #endif } @IBAction func enterLicenseAction(_ sender: HyperLinkButton) { guard let callBack = self.buttonActionBlock else { return } callBack(self,sender,self.emailTextField.stringValue,self.nameTextField.stringValue) FMTrackEventManager.defaultManager.trackOnceEvent(event: "PUW", withProperties: ["PUW_Btn":"Btn_PUW_Enter_The_License"]) } //MARK: NSTextFieldDelegate func controlTextDidChange(_ obj: Notification) { if obj.object == nil { return } let textField = obj.object as! NSTextField if self.emailTextField.isEqual(textField) { self.emailInvalidLabel.isHidden = true self.nameTextFieldView.layer?.borderWidth = 0.0 if (KMAppearance.isDarkMode)(){ self.nameTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.nameTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } self.emailTextFieldView.layer?.borderWidth = 1.0 if (KMAppearance.isDarkMode)(){ self.emailTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.emailTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } } if self.nameTextField.isEqual(textField) { self.nameInvalidLabel.isHidden = true self.nameTextFieldView.layer?.borderWidth = 1.0 if (KMAppearance.isDarkMode)(){ self.nameTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.nameTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } self.emailTextFieldView.layer?.borderWidth = 0.0 if (KMAppearance.isDarkMode)(){ self.emailTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.emailTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } } } func controlTextDidEndEditing(_ obj: Notification) { let fied: NSTextField = obj.object as! NSTextField; if fied.isEqual(self.emailTextField) { if self.validateEmail(self.emailTextField.stringValue) == true { self.emailInvalidLabel.isHidden = true } else { self.emailInvalidLabel.isHidden = false; } self.nameTextFieldView.layer?.borderWidth = 1.0 if (KMAppearance.isDarkMode)(){ self.nameTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.nameTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } self.emailTextFieldView.layer?.borderWidth = 0.0 if (KMAppearance.isDarkMode)(){ self.emailTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.emailTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } } if fied.isEqual(self.nameTextField) { if self.nameTextField.stringValue.isEmpty == false { self.nameInvalidLabel.isHidden = true } else { self.nameInvalidLabel.isHidden = false; } self.nameTextFieldView.layer?.borderWidth = 0.0 if (KMAppearance.isDarkMode)(){ self.nameTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.nameTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } self.emailTextFieldView.layer?.borderWidth = 1.0 if (KMAppearance.isDarkMode)(){ self.emailTextFieldView.layer?.borderColor = KMAppearance.Layout.w30Color().cgColor } else { self.emailTextFieldView.layer?.borderColor = NSColor(red: 0.0/255.0, green: 85.0/255.0, blue: 251.0/255.0, alpha: 1).cgColor } } } func textView(_ textView: NSTextView, clickedOnLink link: Any, at charIndex: Int) -> Bool { guard let url = link as? URL else { return false } NSWorkspace.shared.open(url) return true } func windowWillClose(_ notification: Notification) { KMPurchaseFirstTrialWindowController.currentWindowController = nil } }