// // KMFreeGetAIWC.swift // PDF Reader Pro // // Created by wanjun on 2024/11/11. // import Cocoa @objcMembers class KMFreeGetAIWC: NSWindowController { @IBOutlet weak var titleLabel1: NSTextField! @IBOutlet weak var subTitle1: NSTextField! @IBOutlet weak var subTitle2: NSTextField! @IBOutlet weak var subTitle3: NSTextField! @IBOutlet weak var aitoolsBox: KMBox! @IBOutlet weak var aitoolsLabel: NSTextField! @IBOutlet weak var laterButton: NSButton! @IBOutlet weak var privacyPolicyLabel: NSTextField! @IBOutlet weak var termsServiceLabel: NSTextField! private var viewModel = KMProductModel() static let shared: KMFreeGetAIWC = { let windowC = KMFreeGetAIWC(windowNibName: "KMFreeGetAIWC") return windowC }() override func windowDidLoad() { super.windowDidLoad() // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. languageLocalized() initializeUI() DistributedNotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil) } @objc func themeChanged(_ notification: Notification) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { self.initializeUI() } } // MARK: Private Method private func languageLocalized() -> Void { titleLabel1.stringValue = NSLocalizedString("Successfully subscribe PDF Reader Pro Advanced - Annual Plan!", tableName: "MemberCenterLocalizable", comment: "") subTitle1.stringValue = String(format: " · %@", NSLocalizedString("You get the chance to use AI Tools free for a year on the desktop version", tableName: "MemberCenterLocalizable", comment: "")) subTitle2.stringValue = String(format: " · %@", NSLocalizedString("Free for the first year, then auto-renewal at $125.99 per year. You can cancel your subscription anytime.", tableName: "MemberCenterLocalizable", comment: "")) subTitle3.stringValue = String(format: " · %@", NSLocalizedString("Pick up free AI Tools before 23:59:00, or it will be invalid", tableName: "MemberCenterLocalizable", comment: "")) aitoolsLabel.stringValue = NSLocalizedString("Get 1-Year AI Tools with $0", tableName: "MemberCenterLocalizable", comment: "") laterButton.title = NSLocalizedString("Later", tableName: "MemberCenterLocalizable", comment: "") privacyPolicyLabel.isEditable = false privacyPolicyLabel.isSelectable = true privacyPolicyLabel.allowsEditingTextAttributes = true let privacyPolicy = NSLocalizedString("Privacy Policy", tableName: "MemberCenterLocalizable", comment: "") let termsService = NSLocalizedString("Terms of Service", tableName: "MemberCenterLocalizable", comment: "") let attributedString1 = NSMutableAttributedString(string: privacyPolicy) let attributedString2 = NSMutableAttributedString(string: termsService) let privacyPolicyRange = (privacyPolicy as NSString).range(of: privacyPolicy) let termsServiceRange = (termsService as NSString).range(of: termsService) attributedString1.addAttributes([ .font: NSFont.systemFont(ofSize: 12), .foregroundColor: NSColor(named: "273C62") ?? .blue, .underlineStyle: NSUnderlineStyle.single.rawValue, .link: NSURL(string: NSLocalizedString("https://www.pdfreaderpro.com/privacy-policy", comment: ""))! ], range: privacyPolicyRange) attributedString2.addAttributes([ .font: NSFont.systemFont(ofSize: 12), .foregroundColor: NSColor(named: "273C62") ?? .blue, .underlineStyle: NSUnderlineStyle.single.rawValue, .link: NSURL(string: NSLocalizedString("https://www.pdfreaderpro.com/terms_of_service", comment: ""))! ], range: termsServiceRange) privacyPolicyLabel.attributedStringValue = attributedString1 termsServiceLabel.attributedStringValue = attributedString2 aitoolsBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in guard let self = self else { return } } aitoolsBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in guard let self = self else { return } #if VERSION_FREE #if VERSION_DMG // DMG #else // AppStore 免费版本 IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack12month_lite, discount: IAPProductsManager.default().isCancelAutoRenew()) #endif #else // AppStore 付费版 #endif } } private func initializeUI() -> Void { let isDarkModel = KMAdvertisementConfig.isDarkModel() if isDarkModel { self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor; } else { self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor; } titleLabel1.textColor = NSColor(named: "1D2023") titleLabel1.font = NSFont.SFProTextSemiboldFont(24) subTitle1.textColor = NSColor(named: "101828") subTitle1.font = NSFont.SFProTextRegularFont(14) subTitle2.textColor = NSColor(named: "101828") subTitle2.font = NSFont.SFProTextRegularFont(14) subTitle3.textColor = NSColor(named: "F04438") subTitle3.font = NSFont.SFProTextRegularFont(14) aitoolsBox.fillColor = NSColor(named: "273C62") ?? .blue aitoolsLabel.textColor = NSColor(named: "FFFFFF") aitoolsLabel.font = NSFont.SFProTextRegularFont(13) laterButton.setTitleColor(color: NSColor(named: "4982E6") ?? NSColor.white, font: NSFont.SFProTextRegularFont(12)) } // MARK: Action @IBAction func laterButtonAction(_ sender: NSButton) { window?.close() } }