123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- //
- // 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 titleLabel2: 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()
- }
-
- // MARK: Private Method
-
- private func languageLocalized() -> Void {
- titleLabel1.stringValue = NSLocalizedString("Successfully subscribe PDF Reader", tableName: "MemberCenterLocalizable", comment: "")
- titleLabel2.stringValue = NSLocalizedString("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 automatically renew at $169.99 annually. 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().aiYearPlan_lite, discount: IAPProductsManager.default().isCancelAutoRenew())
- #endif
- #else
- // AppStore 付费版
-
- #endif
- }
- }
-
- private func initializeUI() -> Void {
- titleLabel1.textColor = NSColor(named: "1D2023")
- titleLabel1.font = NSFont.SFProTextSemiboldFont(24)
- titleLabel2.textColor = NSColor(named: "1D2023")
- titleLabel2.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()
- }
- }
|