KMFreeGetAIWC.swift 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // KMFreeGetAIWC.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/11/11.
  6. //
  7. import Cocoa
  8. @objcMembers
  9. class KMFreeGetAIWC: NSWindowController {
  10. @IBOutlet weak var titleLabel1: NSTextField!
  11. @IBOutlet weak var titleLabel2: NSTextField!
  12. @IBOutlet weak var subTitle1: NSTextField!
  13. @IBOutlet weak var subTitle2: NSTextField!
  14. @IBOutlet weak var subTitle3: NSTextField!
  15. @IBOutlet weak var aitoolsBox: KMBox!
  16. @IBOutlet weak var aitoolsLabel: NSTextField!
  17. @IBOutlet weak var laterButton: NSButton!
  18. @IBOutlet weak var privacyPolicyLabel: NSTextField!
  19. @IBOutlet weak var termsServiceLabel: NSTextField!
  20. private var viewModel = KMProductModel()
  21. static let shared: KMFreeGetAIWC = {
  22. let windowC = KMFreeGetAIWC(windowNibName: "KMFreeGetAIWC")
  23. return windowC
  24. }()
  25. override func windowDidLoad() {
  26. super.windowDidLoad()
  27. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  28. languageLocalized()
  29. initializeUI()
  30. }
  31. // MARK: Private Method
  32. private func languageLocalized() -> Void {
  33. titleLabel1.stringValue = NSLocalizedString("Successfully subscribe PDF Reader", tableName: "MemberCenterLocalizable", comment: "")
  34. titleLabel2.stringValue = NSLocalizedString("Pro Advanced - Annual Plan!", tableName: "MemberCenterLocalizable", comment: "")
  35. subTitle1.stringValue = String(format: " · %@", NSLocalizedString("You get the chance to use AI Tools free for a year on the desktop version", tableName: "MemberCenterLocalizable", comment: ""))
  36. 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: ""))
  37. subTitle3.stringValue = String(format: " · %@", NSLocalizedString("Pick up free AI tools before 23:59:00, or it will be invalid", tableName: "MemberCenterLocalizable", comment: ""))
  38. aitoolsLabel.stringValue = NSLocalizedString("Get 1-Year AI Tools with $0", tableName: "MemberCenterLocalizable", comment: "")
  39. laterButton.title = NSLocalizedString("Later", tableName: "MemberCenterLocalizable", comment: "")
  40. privacyPolicyLabel.isEditable = false
  41. privacyPolicyLabel.isSelectable = true
  42. privacyPolicyLabel.allowsEditingTextAttributes = true
  43. let privacyPolicy = NSLocalizedString("Privacy Policy", tableName: "MemberCenterLocalizable", comment: "")
  44. let termsService = NSLocalizedString("Terms of Service", tableName: "MemberCenterLocalizable", comment: "")
  45. let attributedString1 = NSMutableAttributedString(string: privacyPolicy)
  46. let attributedString2 = NSMutableAttributedString(string: termsService)
  47. let privacyPolicyRange = (privacyPolicy as NSString).range(of: privacyPolicy)
  48. let termsServiceRange = (termsService as NSString).range(of: termsService)
  49. attributedString1.addAttributes([
  50. .font: NSFont.systemFont(ofSize: 12),
  51. .foregroundColor: NSColor(named: "273C62") ?? .blue,
  52. .underlineStyle: NSUnderlineStyle.single.rawValue,
  53. .link: NSURL(string: NSLocalizedString("https://www.pdfreaderpro.com/privacy-policy", comment: ""))!
  54. ], range: privacyPolicyRange)
  55. attributedString2.addAttributes([
  56. .font: NSFont.systemFont(ofSize: 12),
  57. .foregroundColor: NSColor(named: "273C62") ?? .blue,
  58. .underlineStyle: NSUnderlineStyle.single.rawValue,
  59. .link: NSURL(string: NSLocalizedString("https://www.pdfreaderpro.com/terms_of_service", comment: ""))!
  60. ], range: termsServiceRange)
  61. privacyPolicyLabel.attributedStringValue = attributedString1
  62. termsServiceLabel.attributedStringValue = attributedString2
  63. aitoolsBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  64. guard let self = self else { return }
  65. }
  66. aitoolsBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  67. guard let self = self else { return }
  68. #if VERSION_FREE
  69. #if VERSION_DMG
  70. // DMG
  71. #else
  72. // AppStore 免费版本
  73. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiYearPlan_lite, discount: IAPProductsManager.default().isCancelAutoRenew())
  74. #endif
  75. #else
  76. // AppStore 付费版
  77. #endif
  78. }
  79. }
  80. private func initializeUI() -> Void {
  81. titleLabel1.textColor = NSColor(named: "1D2023")
  82. titleLabel1.font = NSFont.SFProTextSemiboldFont(24)
  83. titleLabel2.textColor = NSColor(named: "1D2023")
  84. titleLabel2.font = NSFont.SFProTextSemiboldFont(24)
  85. subTitle1.textColor = NSColor(named: "101828")
  86. subTitle1.font = NSFont.SFProTextRegularFont(14)
  87. subTitle2.textColor = NSColor(named: "101828")
  88. subTitle2.font = NSFont.SFProTextRegularFont(14)
  89. subTitle3.textColor = NSColor(named: "F04438")
  90. subTitle3.font = NSFont.SFProTextRegularFont(14)
  91. aitoolsBox.fillColor = NSColor(named: "273C62") ?? .blue
  92. aitoolsLabel.textColor = NSColor(named: "FFFFFF")
  93. aitoolsLabel.font = NSFont.SFProTextRegularFont(13)
  94. laterButton.setTitleColor(color: NSColor(named: "4982E6") ?? NSColor.white, font: NSFont.SFProTextRegularFont(12))
  95. }
  96. // MARK: Action
  97. @IBAction func laterButtonAction(_ sender: NSButton) {
  98. window?.close()
  99. }
  100. }