KMProductCompareWC.swift 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  1. //
  2. // KMProductCompareWC.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/11/6.
  6. //
  7. import Cocoa
  8. import Combine
  9. @objcMembers
  10. class KMProductCompareWC: NSWindowController {
  11. @objc var modalSession: NSApplication.ModalSession?
  12. @IBOutlet @objc weak var tableView: NSTableView!
  13. @IBOutlet @objc weak var titleLabel: NSTextField!
  14. @IBOutlet @objc weak var topMainBox: NSBox!
  15. @IBOutlet @objc weak var topMainView: NSView!
  16. @IBOutlet @objc weak var topsubBox1: NSBox!
  17. @IBOutlet @objc weak var topSelectBox1: NSBox!
  18. @IBOutlet @objc weak var topsubBox2: NSBox!
  19. @IBOutlet @objc weak var topSelectBox2: NSBox!
  20. @IBOutlet @objc weak var topsubBox3: NSBox!
  21. @IBOutlet @objc weak var topSelectBox3: NSBox!
  22. @IBOutlet @objc weak var topsubBox4: NSBox!
  23. @IBOutlet @objc weak var topSelectBox4: NSBox!
  24. @IBOutlet weak var topsubBoxWidth1: NSLayoutConstraint!
  25. @IBOutlet weak var topsubBoxWidth2: NSLayoutConstraint!
  26. @IBOutlet weak var topsubBoxWidth3: NSLayoutConstraint!
  27. @IBOutlet weak var topsubBoxWidth4: NSLayoutConstraint!
  28. @IBOutlet @objc weak var switchLabel: NSTextField!
  29. // @IBOutlet @objc weak var switchButton: NSButton!
  30. @IBOutlet @objc weak var freeInfoView: NSView!
  31. @IBOutlet @objc weak var freeInfoLabel: NSTextField!
  32. @IBOutlet @objc weak var value1InfoView: NSView!
  33. // @IBOutlet @objc weak var value1InfoBox: NSBox!
  34. @IBOutlet @objc weak var value1InfoTypeBox: NSBox!
  35. @IBOutlet @objc weak var sixMouthProLabel: NSTextField!
  36. @IBOutlet @objc weak var oneYearProLabel: NSTextField!
  37. @IBOutlet weak var backgroundImage1: NSImageView!
  38. @IBOutlet @objc weak var switchBox: NSBox!
  39. @IBOutlet @objc weak var switchBtn: NSButton!
  40. @IBOutlet @objc weak var switchCircleView: NSView!
  41. @IBOutlet @objc weak var switchCircleLeftConst: NSLayoutConstraint!
  42. @IBOutlet @objc weak var saleBox: NSBox!
  43. @IBOutlet @objc weak var saleIv: NSImageView!
  44. @IBOutlet @objc weak var saleLabel: NSTextField!
  45. @IBOutlet @objc weak var value1InfoLabel: NSTextField!
  46. @IBOutlet @objc weak var value1PurchaseLabel: NSTextField!
  47. @IBOutlet @objc weak var value1PurchaseSubLabel: NSTextField!
  48. @IBOutlet @objc weak var value1PurchaseButton: KMCustomButton!
  49. @IBOutlet @objc weak var value1PurchaseBtnLbl: NSTextField!
  50. @IBOutlet @objc weak var value1PurchaseOriPriceLbl: NSTextField!
  51. @IBOutlet @objc weak var value1PurchaseBtnLblBtn: NSButton!
  52. // 标准版年订阅
  53. @IBOutlet @objc weak var standardPlanInfoView: NSView!
  54. @IBOutlet @objc weak var standardPlanInfoLabel: NSTextField!
  55. @IBOutlet @objc weak var standardPlanPurchaseLabel: NSTextField!
  56. @IBOutlet @objc weak var standardPlanPurchaseSubLabel: NSTextField!
  57. @IBOutlet @objc weak var standardPlanPurchaseButton: NSButton!
  58. @IBOutlet @objc weak var standardPlanPurchaseLbl: NSTextField!
  59. @IBOutlet @objc weak var standardPlanPurchaseLblBtn: NSButton!
  60. @IBOutlet @objc weak var standardPlanPurchaseSubLabel2: NSTextField!
  61. // 高级版年订阅
  62. @IBOutlet @objc weak var advancedPlanInfoView: NSView!
  63. @IBOutlet @objc weak var advancedPlanInfoLabel: NSTextField!
  64. @IBOutlet @objc weak var advancedPlanPurchaseLabel: NSTextField!
  65. @IBOutlet @objc weak var advancedPlanPurchaseSubLabel: NSTextField!
  66. @IBOutlet @objc weak var advancedPlanPurchaseButton: NSButton!
  67. @IBOutlet @objc weak var advancedPlanPurchaseLbl: NSTextField!
  68. @IBOutlet @objc weak var advancedPlanPurchaseLblBtn: NSButton!
  69. @IBOutlet @objc weak var advancedPlanPurchaseSubLabel2: NSTextField!
  70. @IBOutlet weak var backgroundImage3: NSImageView!
  71. @IBOutlet @objc weak var discountPermanent2: NSImageView!
  72. // 买断
  73. @IBOutlet @objc weak var permanentInfoView: NSView!
  74. @IBOutlet @objc weak var permanentInfoLabel: NSTextField!
  75. @IBOutlet @objc weak var permanentPurchaseLabel: NSTextField!
  76. @IBOutlet @objc weak var permanentPurchaseSubLabel: NSTextField!
  77. @IBOutlet @objc weak var permanentPurchaseButton: NSButton!
  78. @IBOutlet @objc weak var permanentPurchaseLbl: NSTextField!
  79. @IBOutlet @objc weak var permanentPurchaseLblBtn: NSButton!
  80. @IBOutlet @objc weak var permanentPurchaseSubLabel2: NSTextField!
  81. @IBOutlet @objc weak var discountPermanent4: NSImageView!
  82. @IBOutlet @objc weak var aboutButton: NSButton!
  83. @IBOutlet @objc weak var btnRestore: HyperLinkButton!
  84. @IBOutlet @objc weak var privacyPolicyBtn: HyperLinkButton!
  85. @IBOutlet @objc weak var termOfSerBtn: HyperLinkButton!
  86. @IBOutlet @objc weak var textView: NSTextView!
  87. @IBOutlet @objc weak var specialView: NSView!
  88. @IBOutlet @objc weak var specialImageView: NSImageView!
  89. @IBOutlet @objc weak var specialLabel: NSTextField!
  90. @IBOutlet @objc weak var specialView1: NSView!
  91. @IBOutlet @objc weak var specialImageView1: NSImageView!
  92. @IBOutlet @objc weak var specialLabel1: NSTextField!
  93. @IBOutlet @objc weak var box: NSBox!
  94. @IBOutlet @objc weak var labelbox: NSBox!
  95. // @IBOutlet @objc weak var topButtonOffset: NSLayoutConstraint!
  96. @objc var value1Layer: CALayer?
  97. @objc var discountToSaveWinC: KMDiscountToSaveWindowController?
  98. @IBOutlet @objc weak var billedTopConst: NSLayoutConstraint!
  99. @IBOutlet @objc weak var discountYearly: NSImageView!
  100. @IBOutlet @objc weak var discountPermanent: NSImageView!
  101. // @IBOutlet @objc weak var discountPremium: NSImageView!
  102. @IBOutlet @objc weak var platformsView1: NSView!
  103. @IBOutlet @objc weak var platformsView2: NSView!
  104. @IBOutlet @objc weak var platformsView3: NSView!
  105. @IBOutlet @objc weak var platformsView4: NSView!
  106. @IBOutlet @objc weak var giftAIImage1: NSImageView!
  107. @IBOutlet @objc weak var giftAILabel1: NSTextField!
  108. @IBOutlet @objc weak var giftAIImage2: NSImageView!
  109. @IBOutlet @objc weak var giftAILabel2: NSTextField!
  110. @IBOutlet @objc weak var giftAIImage3: NSImageView!
  111. @IBOutlet @objc weak var giftAILabel3: NSTextField!
  112. @IBOutlet @objc weak var giftAIImage4: NSImageView!
  113. @IBOutlet @objc weak var giftAILabel4: NSTextField!
  114. private var model = KMProductModel.shared
  115. private var cancellables = Set<AnyCancellable>()
  116. var orientation: Bool = false // 是否定向跳转
  117. var orientationType: KMCompareTableType = .trial // 定向跳转比较表
  118. static let shared: KMProductCompareWC = {
  119. let windowC = KMProductCompareWC(windowNibName: "KMProductCompareWC")
  120. return windowC
  121. }()
  122. override init(window: NSWindow?) {
  123. super.init(window: window)
  124. setupNotifications()
  125. }
  126. required init?(coder: NSCoder) {
  127. super.init(coder: coder)
  128. }
  129. // MARK: - Notification Setup
  130. private func setupNotifications() {
  131. NotificationCenter.default.addObserver(
  132. self,
  133. selector: #selector(IAPProductLoadedNotification(_:)),
  134. name: NSNotification.Name(rawValue: "KMIAPProductLoadedNotification"),
  135. object: nil
  136. )
  137. NotificationCenter.default.addObserver(
  138. self,
  139. selector: #selector(IAPSubscriptionLoadedNotification(_:)),
  140. name: NSNotification.Name(rawValue: "KMIAPSubscriptionLoadedNotification"),
  141. object: nil
  142. )
  143. NotificationCenter.default.addObserver(
  144. self,
  145. selector: #selector(IAPProductPurchasedNotification(_:)),
  146. name: NSNotification.Name(rawValue: "KMIAPProductPurchasedNotification"),
  147. object: nil
  148. )
  149. NotificationCenter.default.addObserver(
  150. self,
  151. selector: #selector(IAPProductFailedNotification(_:)),
  152. name: NSNotification.Name(rawValue: "KMIAPProductFailedNotification"),
  153. object: nil
  154. )
  155. NotificationCenter.default.addObserver(
  156. self,
  157. selector: #selector(IAPProductRestoreFinishedNotification(_:)),
  158. name: NSNotification.Name(rawValue: "KMIAPProductRestoreFinishedNotification"),
  159. object: nil
  160. )
  161. NotificationCenter.default.addObserver(
  162. self,
  163. selector: #selector(IAPProductRestoreFailedNotification(_:)),
  164. name: NSNotification.Name(rawValue: "KMIAPProductRestoreFailedNotification"),
  165. object: nil
  166. )
  167. DistributedNotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
  168. }
  169. // MARK: - Deinitialization
  170. deinit {
  171. NotificationCenter.default.removeObserver(self)
  172. }
  173. // MARK: - Singleton
  174. @objc class func sharedInstance() -> NSWindowController {
  175. struct Singleton {
  176. static let instance: KMProductCompareWC = KMProductCompareWC()
  177. }
  178. return Singleton.instance
  179. }
  180. override func windowDidLoad() {
  181. super.windowDidLoad()
  182. window?.backgroundColor = KMAppearance.Upgrade.vipBGColor()
  183. window?.isMovableByWindowBackground = true
  184. #if VERSION_DMG
  185. btnRestore.isHidden = true
  186. #endif
  187. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  188. bindViewModel()
  189. if orientation {
  190. model.state = orientationType
  191. } else {
  192. model.getCurrentComparisonTableType()
  193. }
  194. value1InfoLabel.stringValue = NSLocalizedString("6-Month Plan", comment: "")
  195. value1InfoLabel.font = NSFont.UbuntuMediumFontWithSize(16)
  196. value1PurchaseButton.wantsLayer = true
  197. value1PurchaseButton.layer?.backgroundColor = NSColor(red: 1, green: 94/255, blue: 44/255, alpha: 1).cgColor
  198. value1PurchaseButton.layer?.cornerRadius = value1PurchaseButton.frame.height / 2
  199. value1PurchaseBtnLblBtn.wantsLayer = true
  200. value1PurchaseButton.mouseMoveCallback = { [weak self] mouseEntered in
  201. guard let self = self else { return }
  202. if self.value1PurchaseBtnLblBtn.isEnabled == true {
  203. self.value1PurchaseBtnLblBtn.layer?.backgroundColor = mouseEntered ? NSColor.black.withAlphaComponent(0.15).cgColor : NSColor.clear.cgColor
  204. }
  205. }
  206. value1PurchaseBtnLblBtn.layer?.cornerRadius = value1PurchaseBtnLblBtn.frame.height / 2
  207. value1PurchaseBtnLblBtn.layer?.masksToBounds = true
  208. standardPlanPurchaseButton.wantsLayer = true
  209. standardPlanPurchaseButton.layer?.cornerRadius = standardPlanPurchaseButton.frame.height / 2
  210. self.standardPlanPurchaseButton.layer?.backgroundColor = NSColor.white.cgColor
  211. switchLabel.stringValue = NSLocalizedString("Choose your favorite payment and enjoy flexible upgrades.", comment: "")
  212. switchLabel.textColor = KMAppearance.Interactive.m0Color()
  213. box.wantsLayer = true
  214. box.shadow = NSShadow()
  215. box.layer?.shadowOpacity = 0.3
  216. box.layer?.shadowColor = NSColor.black.withAlphaComponent(0.3).cgColor
  217. box.layer?.shadowOffset = NSMakeSize(0, 3)
  218. box.layer?.shadowRadius = 8
  219. box.layer?.masksToBounds = false
  220. permanentPurchaseButton.wantsLayer = true
  221. permanentPurchaseButton.layer?.cornerRadius = permanentPurchaseButton.frame.height / 2
  222. self.permanentPurchaseButton.layer?.backgroundColor = NSColor.white.cgColor
  223. let txtColor = NSColor(red: 102/255, green: 102/255, blue: 102/255, alpha: 1)
  224. aboutButton.title = NSLocalizedString("About Subscriptions", comment: "")
  225. aboutButton.setTitleColor(NSColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.7))
  226. aboutButton.isHidden = true
  227. reloadData()
  228. reloadDataContent()
  229. #if !VERSION_DMG
  230. IAPProductsManager.default().loadProducts()
  231. #endif
  232. #if VERSION_DMG
  233. textView.string = String(format: "Subscription plans:\nPDF Reader Pro Standard - Annual Plan: $79.99/year\nPDF Reader Pro Advanced - Annual Plan: $99.99/year\nPDF Reader Pro Permanent: $119.99\n\nSubscriptions: %@\n- Subscriptions will be charged through your iTunes account at the confirmation of purchase.\n- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period.\n- Your iTunes account will be charged for renewal within 24-hours prior to the end of the current period, for the same duration and at the current subscription price.\n- You may manage your subscriptions in your iTunes Account Settings after purchase.\n- No cancellation of the current subscription is allowed during an active subscription period.\n\n- Terms of service:\nhttps://www.pdfreaderpro.com/terms_of_service\n- Privacy Policy:\nhttps://www.pdfreaderpro.com/privacy-policy", "", NSLocalizedString("USD $39.99/(6 months), USD$59.99/(12 months), USD $59.99/(one-time purchase)", comment: ""))
  234. #else
  235. textView.string = String(format: "Subscription plans:\nPDF Reader Pro Advanced - 6-Month Plan: $49.99/year\nPDF Reader Pro Advanced - Annual Plan: $99.99/year\nPDF Reader Pro Permanent: $119.99\n\nSubscriptions: %@\n- Subscriptions will be charged through your iTunes account at the confirmation of purchase.\n- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period.\n- Your iTunes account will be charged for renewal within 24-hours prior to the end of the current period, for the same duration and at the current subscription price.\n- You may manage your subscriptions in your iTunes Account Settings after purchase.\n- No cancellation of the current subscription is allowed during an active subscription period.\n\n- Terms of service:\nhttps://www.pdfreaderpro.com/terms_of_service\n- Privacy Policy:\nhttps://www.pdfreaderpro.com/privacy-policy", "", NSLocalizedString("USD $39.99/(6 months), USD$59.99/(12 months), USD $59.99/(one-time purchase)", comment: ""))
  236. #endif
  237. showDiscount()
  238. }
  239. func windowShouldClose(sender:Any) -> Bool {
  240. FMTrackEventManager.defaultManager.trackEvent(event: "PUW", withProperties: ["PUW_Btn":"PUW_Btn_Upgrade_Cancel"])
  241. if model.isShowSale {
  242. trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Btn":"PUW_7OffUpgrade_Cancel"], platform: .AppCenter)
  243. }
  244. endModal(sender)
  245. return true
  246. }
  247. override func close() {
  248. super.close()
  249. endModal("")
  250. }
  251. @objc func startModal(_ sender: Any) {
  252. NSApp.stopModal()
  253. modalSession = NSApp.beginModalSession(for: window!)
  254. while NSApp.runModalSession(modalSession!) == .continue {
  255. // Modal loop
  256. }
  257. }
  258. @objc func endModal(_ sender: Any) {
  259. if let session = modalSession {
  260. NSApp.stopModal()
  261. NSApp.endModalSession(session)
  262. window?.orderOut(self)
  263. modalSession = nil
  264. }
  265. }
  266. @objc func showWindowRestore(_ sender: Any) {
  267. showWindow(sender)
  268. buttonItemClicked_Restore(sender)
  269. }
  270. @objc override func showWindow(_ sender: Any?) {
  271. super.showWindow(sender)
  272. alertingCodeForRefreshUserInfo_ = nil
  273. alertingForRefreshUserInfo_ = false
  274. #if VERSION_DMG
  275. model.getDMGProductDatas { success, result in
  276. }
  277. #endif
  278. if orientation {
  279. model.state = orientationType
  280. } else {
  281. model.getCurrentComparisonTableType()
  282. }
  283. languageLocalized()
  284. initializeUI()
  285. reloadData()
  286. if model.isShowSale {
  287. showDiscountToSaveWindow()
  288. }
  289. reloadDataContent()
  290. showDiscount()
  291. }
  292. // MARK: - Private Methods
  293. private func languageLocalized() -> Void {
  294. titleLabel.stringValue = NSLocalizedString("Subscribe to All Access Pack to enjoy more expanded features.", comment: "")
  295. btnRestore.title = NSLocalizedString("Restore", comment: "")
  296. btnRestore.toolTip = NSLocalizedString("Restore", comment: "")
  297. privacyPolicyBtn.title = NSLocalizedString("Privacy Policy", comment: "")
  298. privacyPolicyBtn.toolTip = NSLocalizedString("Privacy Policy", comment: "")
  299. termOfSerBtn.title = NSLocalizedString("Terms of Service", comment: "")
  300. termOfSerBtn.toolTip = NSLocalizedString("Terms of Service", comment: "")
  301. sixMouthProLabel.stringValue = NSLocalizedString("6-Month Plan", comment: "")
  302. oneYearProLabel.stringValue = NSLocalizedString("1-year Plan", comment: "")
  303. freeInfoLabel.stringValue = NSLocalizedString("Free", comment: "")
  304. standardPlanInfoLabel.stringValue = NSLocalizedString("PDF Reader Pro Standard - Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  305. standardPlanPurchaseSubLabel.stringValue = NSLocalizedString("Auto-renewal | Billed yearly", tableName: "MemberCenterLocalizable", comment: "")
  306. standardPlanPurchaseSubLabel2.stringValue = NSLocalizedString("(Tax Incl.)",tableName: "MemberCenterLocalizable", comment: "")
  307. advancedPlanInfoLabel.stringValue = NSLocalizedString("PDF Reader Pro Advanced - Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  308. advancedPlanPurchaseSubLabel.stringValue = NSLocalizedString("Auto-renewal | Billed yearly", tableName: "MemberCenterLocalizable", comment: "")
  309. advancedPlanPurchaseSubLabel2.stringValue = NSLocalizedString("(Tax Incl.)",tableName: "MemberCenterLocalizable", comment: "")
  310. permanentInfoLabel.stringValue = NSLocalizedString("PDF Reader Pro Permanent", tableName: "MemberCenterLocalizable", comment: "")
  311. permanentPurchaseSubLabel.stringValue = NSLocalizedString("one-time purchase", comment: "")
  312. permanentPurchaseSubLabel2.stringValue = NSLocalizedString("(Tax Incl.)",tableName: "MemberCenterLocalizable", comment: "")
  313. standardPlanPurchaseLbl.stringValue = NSLocalizedString("Subscribe", comment: "")
  314. if KMMemberInfo.shared.userScenarioType == .lite_type3 ||
  315. KMMemberInfo.shared.userScenarioType == .lite_type11 {
  316. advancedPlanPurchaseLbl.stringValue = NSLocalizedString("Renew now",tableName: "MemberCenterLocalizable", comment: "")
  317. } else {
  318. advancedPlanPurchaseLbl.stringValue = NSLocalizedString("Subscribe", comment: "")
  319. }
  320. permanentPurchaseLbl.stringValue = NSLocalizedString("Purchase", comment: "")
  321. giftAILabel1.stringValue = NSLocalizedString("1-Year AI Tools Giveaway",tableName: "MemberCenterLocalizable", comment: "")
  322. giftAILabel2.stringValue = NSLocalizedString("1-Year AI Tools Giveaway",tableName: "MemberCenterLocalizable", comment: "")
  323. giftAILabel3.stringValue = NSLocalizedString("1-Year AI Tools Giveaway",tableName: "MemberCenterLocalizable", comment: "")
  324. giftAILabel4.stringValue = NSLocalizedString("1-Year AI Tools Giveaway",tableName: "MemberCenterLocalizable", comment: "")
  325. #if VERSION_FREE
  326. #if VERSION_DMG
  327. // DMG
  328. if KMMemberInfo.shared.canTrail && model.state == .trial {
  329. advancedPlanPurchaseLbl.stringValue = NSLocalizedString("Free Trial", comment: "")
  330. }
  331. if model.state == .dmg_Base {
  332. standardPlanPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProStandard_dmg)
  333. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProAdvanced_dmg)
  334. permanentPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProPermanent_dmg)
  335. } else if model.state == .dmg_Upgrades1 || model.state == .dmg_Upgrades2 {
  336. guard let productModels = model.dmgProductDatas?.listingProducts else { return }
  337. for productModel in productModels {
  338. if productModel.code == "advanced-annual-subscription" {
  339. model.getDMGProductPriceInfosForMember(productId: productModel.id, isEducation: 0) { [weak self] success, result in
  340. guard let self = self else { return }
  341. guard let results: KMMemberProductResult = result else { return }
  342. guard let productModels2 = results.listingProducts else { return }
  343. for productModel2 in productModels2 {
  344. if productModel2.code == "advanced-annual-subscription" {
  345. self.advancedPlanPurchaseLabel.stringValue = String(format: "USD $%.2f", Float(productModel2.upgradePriceString ?? "") ?? 0)
  346. }
  347. }
  348. }
  349. } else if productModel.code == "advanced-permanent-blackFive" {
  350. model.getDMGProductPriceInfosForMember(productId: productModel.id, isEducation: 0) { [weak self] success, result in
  351. guard let self = self else { return }
  352. guard let results: KMMemberProductResult = result else { return }
  353. guard let productModels2 = results.listingProducts else { return }
  354. for productModel2 in productModels2 {
  355. if productModel2.code == "advanced-annual-subscription-blackFive" {
  356. self.advancedPlanPurchaseLabel.stringValue = String(format: "USD $%.2f", Float(productModel2.upgradePriceString ?? "") ?? 0)
  357. }
  358. }
  359. }
  360. }
  361. }
  362. } else {
  363. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProAdvanced_dmg)
  364. }
  365. #else
  366. var isTrialPeriod = false
  367. if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
  368. isTrialPeriod = true
  369. }
  370. if(!isTrialPeriod &&
  371. KMMemberInfo.shared.canTrail) {
  372. advancedPlanPurchaseLbl.stringValue = NSLocalizedString("Free Trial", comment: "")
  373. }
  374. // AppStore 免费版本
  375. if model.state == .lite_Base {
  376. permanentPurchaseLabel.stringValue = model.getProductPrice(.allAccessPackPermanent_lite)
  377. } else if model.state == .lite_MacWindows {
  378. if KMMemberInfo.shared.userScenarioType == .lite_type5 {
  379. let platforms = KMMemberInfo.shared.vip_platforms
  380. let platformsArray = platforms
  381. .components(separatedBy: ",")
  382. .map { $0.trimmingCharacters(in: .whitespaces) }
  383. if platformsArray.count == 1 {
  384. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAddDevicesAllAccessPack12months_lite)
  385. } else if platformsArray.count == 2 {
  386. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAdd2DevicesAllAccessPack12months_lite)
  387. } else {
  388. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAdd2DevicesAllAccessPack12months_lite)
  389. }
  390. } else {
  391. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAddDevicesAllAccessPack12months_lite)
  392. }
  393. } else {
  394. // model.state == .trial
  395. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.fourDevicesAllAccessPackNew12months_lite)
  396. }
  397. #endif
  398. #else
  399. if IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.isTrialPeriod == false && KMMemberInfo.shared.canTrail {
  400. advancedPlanPurchaseLbl.stringValue = NSLocalizedString("Free Trial", comment: "")
  401. }
  402. // AppStore 付费版
  403. if model.state == .pro_Base {
  404. if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  405. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.standardAddDevicesAllAccessPack12months_pro)
  406. permanentPurchaseLabel.stringValue = model.getProductPrice(.pdfToOfficePackPermanent_pro)
  407. }
  408. } else if model.state == .pro_Advanced {
  409. let platforms = KMMemberInfo.shared.vip_platforms
  410. let platformsArray = platforms
  411. .components(separatedBy: ",")
  412. .map { $0.trimmingCharacters(in: .whitespaces) }
  413. if KMMemberInfo.shared.userScenarioType == .pro_type1 {
  414. if platformsArray.count == 1 {
  415. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAddDevicesAllAccessPack12months_pro)
  416. } else if platformsArray.count == 2 {
  417. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAdd2DevicesAllAccessPack12months_pro)
  418. } else if KMMemberInfo.shared.vip_levels == "1" {
  419. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAddDevicesAllAccessPack12months_pro)
  420. } else {
  421. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAdd2DevicesAllAccessPack12months_pro)
  422. }
  423. } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
  424. if platformsArray.count == 1 {
  425. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAddDevicesAllAccessPack12months_pro)
  426. } else if platformsArray.count == 2 {
  427. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAdd2DevicesAllAccessPack12months_pro)
  428. } else {
  429. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.advancedAdd2DevicesAllAccessPack12months_pro)
  430. }
  431. }
  432. } else {
  433. advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.fourDevicesAllAccessPack12months_pro)
  434. }
  435. #endif
  436. }
  437. private func initializeUI() -> Void {
  438. btnRestore.setTitleColor(NSColor(named: "FFFFFF") ?? NSColor.white)
  439. btnRestore.font = NSFont.SFProTextRegularFont(13)
  440. btnRestore.mouseMoveCallback = { [weak self] mouseEntered in
  441. guard let self = self else { return }
  442. if mouseEntered {
  443. self.btnRestore.setTitleColor(NSColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.7))
  444. } else {
  445. self.btnRestore.setTitleColor(NSColor(named: "FFFFFF") ?? NSColor.white)
  446. }
  447. }
  448. privacyPolicyBtn.setTitleColor(NSColor(named: "FFFFFF") ?? NSColor.white)
  449. privacyPolicyBtn.font = NSFont.SFProTextRegularFont(13)
  450. privacyPolicyBtn.mouseMoveCallback = { [weak self] mouseEntered in
  451. guard let self = self else { return }
  452. if mouseEntered {
  453. self.privacyPolicyBtn.setTitleColor(NSColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.7))
  454. } else {
  455. self.privacyPolicyBtn.setTitleColor(NSColor(named: "FFFFFF") ?? NSColor.white)
  456. }
  457. }
  458. termOfSerBtn.setTitleColor(NSColor(named: "FFFFFF") ?? NSColor.white)
  459. termOfSerBtn.font = NSFont.SFProTextRegularFont(13)
  460. termOfSerBtn.mouseMoveCallback = { [weak self] mouseEntered in
  461. guard let self = self else { return }
  462. if mouseEntered {
  463. self.termOfSerBtn.setTitleColor(NSColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.7))
  464. } else {
  465. self.termOfSerBtn.setTitleColor(NSColor(named: "FFFFFF") ?? NSColor.white)
  466. }
  467. }
  468. giftAILabel1.textColor = NSColor(named: "FFFFFF") ?? NSColor.white
  469. giftAILabel1.font = NSFont.SFProTextRegularFont(12)
  470. giftAILabel2.textColor = NSColor(named: "FFFFFF") ?? NSColor.white
  471. giftAILabel2.font = NSFont.SFProTextRegularFont(12)
  472. giftAILabel3.textColor = NSColor(named: "FFFFFF") ?? NSColor.white
  473. giftAILabel3.font = NSFont.SFProTextRegularFont(12)
  474. giftAILabel4.textColor = NSColor(named: "FFFFFF") ?? NSColor.white
  475. giftAILabel4.font = NSFont.SFProTextRegularFont(12)
  476. value1InfoTypeBox.fillColor = NSColor.clear
  477. value1InfoTypeBox.borderWidth = 0
  478. sixMouthProLabel.textColor = .white
  479. sixMouthProLabel.font = NSFont.UbuntuMediumFontWithSize(14)
  480. sixMouthProLabel.lineBreakMode = .byTruncatingTail
  481. sixMouthProLabel.toolTip = sixMouthProLabel.stringValue
  482. sixMouthProLabel.alignment = .center
  483. oneYearProLabel.textColor = .white
  484. oneYearProLabel.font = NSFont.UbuntuMediumFontWithSize(14)
  485. oneYearProLabel.lineBreakMode = .byTruncatingTail
  486. oneYearProLabel.toolTip = oneYearProLabel.stringValue
  487. oneYearProLabel.alignment = .center
  488. switchBox.fillColor = NSColor(white: 1, alpha: 0.2)
  489. switchBox.cornerRadius = 12
  490. switchBox.borderWidth = 1
  491. switchBox.borderColor = NSColor(red: 235/255, green: 236/255, blue: 240/255, alpha: 1.0)
  492. switchCircleView.wantsLayer = true
  493. switchCircleView.layer?.cornerRadius = 8
  494. switchCircleView.layer?.backgroundColor = NSColor.white.cgColor
  495. switchBtn.title = ""
  496. switchBtn.target = self
  497. switchBtn.action = #selector(switchAction)
  498. saleLabel.isHidden = true
  499. saleLabel.superview?.isHidden = true
  500. saleBox.borderWidth = 0
  501. topMainBox.contentView = topMainView
  502. topsubBox1.isHidden = false
  503. topsubBox2.isHidden = false
  504. topsubBox3.isHidden = false
  505. topsubBox4.isHidden = false
  506. topSelectBox1.isHidden = true
  507. topSelectBox2.isHidden = true
  508. topSelectBox3.isHidden = true
  509. topSelectBox4.isHidden = true
  510. giftAIImage1.isHidden = true
  511. giftAILabel1.isHidden = true
  512. giftAIImage2.isHidden = true
  513. giftAILabel2.isHidden = true
  514. giftAIImage3.isHidden = true
  515. giftAILabel3.isHidden = true
  516. giftAIImage4.isHidden = true
  517. giftAILabel4.isHidden = true
  518. freeInfoLabel.font = NSFont.UbuntuMediumFontWithSize(14)
  519. standardPlanInfoLabel.font = NSFont.UbuntuMediumFontWithSize(14)
  520. advancedPlanInfoLabel.font = NSFont.UbuntuMediumFontWithSize(14)
  521. permanentInfoLabel.font = NSFont.UbuntuMediumFontWithSize(14)
  522. standardPlanPurchaseSubLabel.font = NSFont.SFProTextRegularFont(11)
  523. standardPlanPurchaseSubLabel2.font = NSFont.SFProTextRegularFont(11)
  524. advancedPlanPurchaseSubLabel.font = NSFont.SFProTextRegularFont(11)
  525. advancedPlanPurchaseSubLabel2.font = NSFont.SFProTextRegularFont(11)
  526. permanentPurchaseSubLabel.font = NSFont.UbuntuMediumFontWithSize(11)
  527. permanentPurchaseSubLabel2.font = NSFont.SFProTextRegularFont(11)
  528. value1PurchaseLabel.font = NSFont.UbuntuBoldFontWithSize(20)
  529. standardPlanPurchaseLabel.font = NSFont.UbuntuBoldFontWithSize(20)
  530. standardPlanPurchaseLabel.textColor = NSColor(red: 1.0, green: 231.0/255.0, blue: 106.0/255.0, alpha: 1.0)
  531. advancedPlanPurchaseLabel.font = NSFont.UbuntuBoldFontWithSize(20)
  532. advancedPlanPurchaseLabel.textColor = NSColor(red: 1.0, green: 231.0/255.0, blue: 106.0/255.0, alpha: 1.0)
  533. permanentPurchaseLabel.font = NSFont.UbuntuBoldFontWithSize(20)
  534. permanentPurchaseLabel.textColor = NSColor(red: 1.0, green: 231.0/255.0, blue: 106.0/255.0, alpha: 1.0)
  535. backgroundImage1.wantsLayer = true
  536. backgroundImage1.layer?.cornerRadius = 12
  537. backgroundImage1.layer?.masksToBounds = true
  538. backgroundImage3.wantsLayer = true
  539. backgroundImage3.layer?.cornerRadius = 12
  540. backgroundImage3.layer?.masksToBounds = true
  541. advancedPlanPurchaseButton.wantsLayer = true
  542. advancedPlanPurchaseButton.layer?.backgroundColor = NSColor(red: 1, green: 94/255, blue: 44/255, alpha: 1).cgColor
  543. advancedPlanPurchaseButton.layer?.cornerRadius = value1PurchaseButton.frame.height / 2
  544. standardPlanPurchaseLbl.textColor = NSColor(named: "5528FF") ?? .blue
  545. advancedPlanPurchaseLbl.textColor = NSColor(named: "FFFFFF") ?? .white
  546. permanentPurchaseLbl.textColor = NSColor(named: "5528FF") ?? .blue
  547. var contentWidth = 970.0
  548. var contentHeight = 660.0
  549. if model.state == .dmg_Base {
  550. contentWidth = 970.0
  551. contentHeight = 660.0
  552. topsubBox1.contentView = freeInfoView
  553. topsubBox2.contentView = standardPlanInfoView
  554. topsubBox3.contentView = advancedPlanInfoView
  555. topsubBox4.contentView = permanentInfoView
  556. backgroundImage1.isHidden = true
  557. topSelectBox3.isHidden = false
  558. if KMMemberInfo.shared.vip_levels == "1" {
  559. giftAIImage3.isHidden = false
  560. giftAILabel3.isHidden = false
  561. }
  562. topsubBoxWidth1.constant = 149.5
  563. topsubBoxWidth2.constant = 149.5
  564. topsubBoxWidth3.constant = 149.5
  565. topsubBoxWidth3.constant = 149.5
  566. } else if model.state == .dmg_Upgrades1 {
  567. contentWidth = 689.0
  568. contentHeight = 660.0
  569. topsubBox2.isHidden = true
  570. topsubBox3.isHidden = true
  571. topsubBox4.isHidden = true
  572. topsubBox1.contentView = advancedPlanInfoView
  573. topSelectBox1.isHidden = false
  574. if KMMemberInfo.shared.vip_levels == "1" {
  575. giftAIImage1.isHidden = false
  576. giftAILabel1.isHidden = false
  577. }
  578. topsubBoxWidth1.constant = 320.0
  579. } else if model.state == .dmg_Upgrades2 {
  580. contentWidth = 689.0
  581. contentHeight = 660.0
  582. topsubBox2.isHidden = true
  583. topsubBox3.isHidden = true
  584. topsubBox4.isHidden = true
  585. topsubBox1.contentView = advancedPlanInfoView
  586. topSelectBox1.isHidden = false
  587. if KMMemberInfo.shared.vip_levels == "1" {
  588. giftAIImage1.isHidden = false
  589. giftAILabel1.isHidden = false
  590. }
  591. topsubBoxWidth1.constant = 320.0
  592. } else if model.state == .lite_Base {
  593. contentWidth = 970.0
  594. contentHeight = 660.0
  595. topsubBox4.isHidden = true
  596. topsubBox1.contentView = freeInfoView
  597. topsubBox2.contentView = value1InfoView
  598. topsubBox3.contentView = permanentInfoView
  599. topSelectBox2.isHidden = false
  600. if KMMemberInfo.shared.vip_levels == "1" {
  601. giftAIImage2.isHidden = false
  602. giftAILabel2.isHidden = false
  603. }
  604. topsubBoxWidth1.constant = 179.0
  605. topsubBoxWidth2.constant = 240.0
  606. topsubBoxWidth3.constant = 179.0
  607. } else if model.state == .lite_MacWindows {
  608. contentWidth = 689.0
  609. contentHeight = 660.0
  610. topsubBox2.isHidden = true
  611. topsubBox3.isHidden = true
  612. topsubBox4.isHidden = true
  613. topsubBox1.contentView = advancedPlanInfoView
  614. topSelectBox1.isHidden = false
  615. if KMMemberInfo.shared.vip_levels == "1" {
  616. giftAIImage1.isHidden = false
  617. giftAILabel1.isHidden = false
  618. }
  619. topsubBoxWidth1.constant = 320.0
  620. } else if model.state == .pro_Base {
  621. contentWidth = 970.0
  622. contentHeight = 660.0
  623. topsubBox3.isHidden = true
  624. topsubBox4.isHidden = true
  625. topsubBox1.contentView = advancedPlanInfoView
  626. topsubBox2.contentView = permanentInfoView
  627. backgroundImage1.isHidden = true
  628. topSelectBox1.isHidden = false
  629. if KMMemberInfo.shared.vip_levels == "1" {
  630. giftAIImage1.isHidden = false
  631. giftAILabel1.isHidden = false
  632. }
  633. topsubBoxWidth1.constant = 299.0
  634. topsubBoxWidth2.constant = 299.0
  635. } else if model.state == .pro_Advanced {
  636. contentWidth = 689.0
  637. contentHeight = 660.0
  638. topsubBox2.isHidden = true
  639. topsubBox3.isHidden = true
  640. topsubBox4.isHidden = true
  641. topsubBox1.contentView = advancedPlanInfoView
  642. topSelectBox1.isHidden = false
  643. if KMMemberInfo.shared.vip_levels == "1" {
  644. giftAIImage1.isHidden = false
  645. giftAILabel1.isHidden = false
  646. }
  647. topsubBoxWidth1.constant = 320.0
  648. } else {
  649. // model.state == .trial
  650. contentWidth = 785.0
  651. contentHeight = 660.0
  652. topsubBox3.isHidden = true
  653. topsubBox4.isHidden = true
  654. topsubBox1.contentView = freeInfoView
  655. topsubBox2.contentView = advancedPlanInfoView
  656. backgroundImage1.isHidden = true
  657. topSelectBox2.isHidden = false
  658. if KMMemberInfo.shared.vip_levels == "1" {
  659. giftAIImage2.isHidden = false
  660. giftAILabel2.isHidden = false
  661. }
  662. topsubBoxWidth1.constant = 179.0
  663. topsubBoxWidth2.constant = 240.0
  664. }
  665. self.window?.setContentSize(NSSize(width: contentWidth, height: contentHeight))
  666. self.window?.maxSize = NSSize(width: contentWidth, height: contentHeight)
  667. self.window?.minSize = NSSize(width: contentWidth, height: contentHeight)
  668. box.fillColor = KMAppearance.Layout.l1Color()
  669. labelbox.fillColor = .clear
  670. tableView.backgroundColor = KMAppearance.Layout.l0Color()
  671. textView.backgroundColor = .clear
  672. textView.textColor = NSColor.white.withAlphaComponent(0.5)
  673. value1PurchaseSubLabel.textColor = KMAppearance.Layout.w0Color()
  674. standardPlanPurchaseSubLabel.textColor = KMAppearance.Layout.w0Color()
  675. standardPlanPurchaseSubLabel2.textColor = KMAppearance.Layout.w0Color()
  676. advancedPlanPurchaseSubLabel.textColor = KMAppearance.Layout.w0Color()
  677. advancedPlanPurchaseSubLabel2.textColor = KMAppearance.Layout.w0Color()
  678. permanentPurchaseSubLabel.textColor = KMAppearance.Layout.w0Color()
  679. permanentPurchaseSubLabel2.textColor = KMAppearance.Layout.w0Color()
  680. #if VERSION_FREE
  681. #if VERSION_DMG
  682. // DMG
  683. #else
  684. // AppStore 免费版本
  685. refreshPurchaseSwitch()
  686. #endif
  687. #else
  688. // AppStore 付费版
  689. #endif
  690. }
  691. @objc func reloadData() {
  692. saleBox.isHidden = true
  693. saleIv.isHidden = true
  694. if model.isShowSale {
  695. if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first,
  696. let url = URL(string: KMAdvertisementModelTransition.transitionImagePath(image: info.saleImage, highlight: true)) {
  697. KMAdvertisementImage.imageWithURL(url: url) { [weak self] image in
  698. guard let self = self else { return }
  699. self.saleIv.image = image
  700. self.saleBox.isHidden = false
  701. self.saleIv.isHidden = false
  702. self.trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Exposure": "PUW_7OffUpgrade"], platform: .AppCenter)
  703. }
  704. }
  705. } else {
  706. saleBox.isHidden = true
  707. }
  708. // if KMMemberInfo.shared.isMemberAllFunction == true {
  709. // value1PurchaseButton.isEnabled = false
  710. // permanentPurchaseButton.isEnabled = false
  711. // permanentPurchaseLbl.textColor = NSColor(red: 85/255.0, green: 40/255.0, blue: 255/255.0, alpha: 0.5)
  712. // } else {
  713. // value1PurchaseButton.isEnabled = true
  714. // permanentPurchaseButton.isEnabled = true
  715. // permanentPurchaseLbl.textColor = NSColor(red: 85/255.0, green: 40/255.0, blue: 255/255.0, alpha: 1.0)
  716. // }
  717. permanentPurchaseLbl.font = NSFont.UbuntuBoldFontWithSize(16)
  718. value1PurchaseOriPriceLbl.font = NSFont.SFProTextRegularFont(12)
  719. }
  720. func refreshPurchaseSwitch() -> Void {
  721. #if VERSION_FREE
  722. #if VERSION_DMG
  723. // DMG
  724. #else
  725. // AppStore 免费版本
  726. reloadData()
  727. if model.isPurchaseSwitch {
  728. discountYearly.isHidden = false
  729. sixMouthProLabel.textColor = NSColor(red: 117/255.0, green: 119/255.0, blue: 128/255.0, alpha: 1.0)
  730. oneYearProLabel.textColor = NSColor.white
  731. switchCircleLeftConst.constant = 22
  732. value1InfoLabel.stringValue = NSLocalizedString("1-year Plan", comment: "")
  733. } else {
  734. discountYearly.isHidden = true
  735. sixMouthProLabel.textColor = NSColor.white
  736. oneYearProLabel.textColor = NSColor(red: 117/255.0, green: 119/255.0, blue: 128/255.0, alpha: 1.0)
  737. switchCircleLeftConst.constant = 4
  738. value1InfoLabel.stringValue = NSLocalizedString("6-Month Plan", comment: "")
  739. }
  740. value1PurchaseBtnLblBtn.isEnabled = value1PurchaseButton.isEnabled
  741. value1PurchaseBtnLbl.stringValue = NSLocalizedString("Subscribe", comment: "")
  742. let fourDevicesAllAccessPackNew6Months_lite = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite
  743. let fourDevicesAllAccessPackNew12months_lite = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite
  744. let isTrialPeriod_newlyMonth = fourDevicesAllAccessPackNew6Months_lite?.isTrialPeriod ?? false
  745. let isSubscribed_newlyMonth = fourDevicesAllAccessPackNew6Months_lite?.isSubscribed ?? false
  746. let isTrialPeriod_year = fourDevicesAllAccessPackNew12months_lite?.isTrialPeriod ?? false
  747. let isSubscribed_year = fourDevicesAllAccessPackNew12months_lite?.isSubscribed ?? false
  748. let introductoryPrice_newlyMonth = fourDevicesAllAccessPackNew6Months_lite?.product?.introductoryPrice
  749. let introductoryPrice_year = fourDevicesAllAccessPackNew12months_lite?.product?.introductoryPrice
  750. if(isSubscribed_newlyMonth || isSubscribed_year) {
  751. value1PurchaseBtnLbl.stringValue = NSLocalizedString("Subscribed", comment: "")
  752. } else {
  753. if(model.isPurchaseSwitch == true) {
  754. if(!isTrialPeriod_year &&
  755. KMMemberInfo.shared.canTrail) {
  756. value1PurchaseBtnLbl.stringValue = NSLocalizedString("Free Trial", comment: "")
  757. } else {
  758. value1PurchaseBtnLbl.stringValue = NSLocalizedString("Subscribe", comment: "")
  759. }
  760. } else {
  761. value1PurchaseBtnLbl.stringValue = NSLocalizedString("Subscribe", comment: "")
  762. }
  763. }
  764. value1PurchaseBtnLbl.textColor = value1PurchaseBtnLblBtn.isEnabled ? NSColor.white : NSColor.white.withAlphaComponent(0.5)
  765. permanentPurchaseLblBtn.isEnabled = permanentPurchaseButton.isEnabled
  766. standardPlanPurchaseLblBtn.isEnabled = standardPlanPurchaseButton.isEnabled
  767. advancedPlanPurchaseLblBtn.isEnabled = advancedPlanPurchaseButton.isEnabled
  768. let averageMonthPrice: String?
  769. let monthPrice: String?
  770. let averageMonthPriceDiscount: String?
  771. let monthPriceDiscount: String?
  772. var allPrice: String?
  773. let isOffers_newlyMonth = fourDevicesAllAccessPackNew6Months_lite?.isOffers ?? false
  774. let isOffers_year = fourDevicesAllAccessPackNew12months_lite?.isOffers ?? false
  775. if isOffers_newlyMonth {
  776. specialView1.isHidden = false
  777. averageMonthPrice = fourDevicesAllAccessPackNew6Months_lite?.offersAveragePrice()
  778. monthPrice = fourDevicesAllAccessPackNew6Months_lite?.offersPrice()
  779. averageMonthPriceDiscount = fourDevicesAllAccessPackNew6Months_lite?.discountAveragePrice()
  780. monthPriceDiscount = fourDevicesAllAccessPackNew6Months_lite?.discountPrice()
  781. } else if isOffers_year {
  782. averageMonthPrice = fourDevicesAllAccessPackNew12months_lite?.offersAveragePrice()
  783. monthPrice = fourDevicesAllAccessPackNew12months_lite?.offersPrice()
  784. averageMonthPriceDiscount = fourDevicesAllAccessPackNew12months_lite?.discountAveragePrice()
  785. monthPriceDiscount = fourDevicesAllAccessPackNew12months_lite?.discountPrice()
  786. } else {
  787. specialView1.isHidden = true
  788. if !model.isPurchaseSwitch {
  789. averageMonthPrice = fourDevicesAllAccessPackNew6Months_lite?.averagePrice()
  790. monthPrice = fourDevicesAllAccessPackNew6Months_lite?.price()
  791. averageMonthPriceDiscount = fourDevicesAllAccessPackNew6Months_lite?.discountAveragePrice()
  792. monthPriceDiscount = fourDevicesAllAccessPackNew6Months_lite?.discountPrice()
  793. } else {
  794. averageMonthPrice = fourDevicesAllAccessPackNew12months_lite?.averagePrice()
  795. monthPrice = fourDevicesAllAccessPackNew12months_lite?.price()
  796. averageMonthPriceDiscount = fourDevicesAllAccessPackNew12months_lite?.discountAveragePrice()
  797. monthPriceDiscount = fourDevicesAllAccessPackNew12months_lite?.discountPrice()
  798. }
  799. }
  800. if let allAccessPackPermanent_lite = IAPProductsManager.default().allAccessPackPermanent_lite, allAccessPackPermanent_lite.isOffers {
  801. specialView.isHidden = false
  802. allPrice = allAccessPackPermanent_lite.offersPrice()
  803. } else {
  804. specialView.isHidden = true
  805. allPrice = IAPProductsManager.default().allAccessPackPermanent_lite?.price()
  806. }
  807. var off = 1 - (IAPProductsManager.default().allAccessPackPermanent_lite?.offers ?? 0)
  808. var offString = String(format: "%.f%%", off * 100)
  809. specialLabel.stringValue = String(format: NSLocalizedString("%@ off", comment: ""), offString)
  810. if model.isPurchaseSwitch {
  811. off = 1 - IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.offers
  812. } else {
  813. off = 1 - IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.offers
  814. }
  815. offString = String(format: "%.f%%", off * 100)
  816. specialLabel1.stringValue = String(format: NSLocalizedString("%@ off", comment: ""), offString)
  817. let image = NSImage(named: "KMImageNameCompareTagBG")
  818. specialImageView.image = image
  819. specialImageView1.image = image
  820. if KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice() {
  821. if model.isShowSale {
  822. value1PurchaseSubLabel.stringValue = String(format: "%@/%@", averageMonthPriceDiscount ?? "", NSLocalizedString("mon", comment: ""))
  823. value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
  824. value1PurchaseOriPriceLbl.isHidden = false
  825. billedTopConst.constant = 16
  826. } else {
  827. value1PurchaseLabel.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
  828. value1PurchaseOriPriceLbl.isHidden = true
  829. billedTopConst.constant = 0
  830. }
  831. } else {
  832. if model.isPurchaseSwitch {
  833. if model.isShowSale {
  834. value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPriceDiscount ?? "", NSLocalizedString("12 months", comment: ""))
  835. value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("12 months", comment: ""))
  836. value1PurchaseOriPriceLbl.isHidden = false
  837. billedTopConst.constant = 16
  838. } else {
  839. value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("12 months", comment: ""))
  840. value1PurchaseOriPriceLbl.isHidden = true
  841. billedTopConst.constant = 0
  842. }
  843. } else {
  844. if model.isShowSale {
  845. value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPriceDiscount ?? "", NSLocalizedString("6mon", comment: ""))
  846. value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("6mon", comment: ""))
  847. value1PurchaseOriPriceLbl.isHidden = false
  848. billedTopConst.constant = 16
  849. } else {
  850. value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("6mon", comment: ""))
  851. value1PurchaseOriPriceLbl.isHidden = true
  852. billedTopConst.constant = 0
  853. }
  854. }
  855. }
  856. value1PurchaseLabel.textColor = NSColor(red: 1.0, green: 231.0/255.0, blue: 106.0/255.0, alpha: 1.0)
  857. value1PurchaseOriPriceLbl.textColor = NSColor(white: 1.0, alpha: 0.7)
  858. value1PurchaseOriPriceLbl.attributedStringValue = NSAttributedString(string: value1PurchaseOriPriceLbl.stringValue, attributes: [
  859. .font : NSFont.SFProTextRegularFont(12),
  860. .foregroundColor: NSColor(white: 1, alpha: 0.7),
  861. .strikethroughStyle: NSUnderlineStyle.single.rawValue
  862. ])
  863. var tTips: String
  864. if model.isShowSale {
  865. tTips = String(format: NSLocalizedString("%@ for the first 6-month subscription", comment: ""), monthPriceDiscount ?? "")
  866. } else {
  867. tTips = String(format: NSLocalizedString("Billed every 6 months at %@", comment: ""), monthPrice ?? "")
  868. }
  869. if value1PurchaseBtnLbl.stringValue == NSLocalizedString("Free Trial", comment: "") {
  870. tTips = String(format: NSLocalizedString("Billed every 6 months at %@ after 7-day trial ends.", comment: ""), monthPrice ?? "")
  871. #if !VERSION_DMG
  872. if model.isPurchaseSwitch {
  873. if let fourDevicesAllAccessPackNew12months_lite = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product {
  874. if #available(macOS 10.13.2, *) {
  875. let trialDays = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product.introductoryPrice?.subscriptionPeriod.numberOfUnits
  876. tTips = String(
  877. format: NSLocalizedString("Billed every 12 months at %@ after %@-day trial ends.", comment: ""),
  878. monthPrice ?? "",
  879. "\(trialDays ?? 0)"
  880. )
  881. }
  882. }
  883. } else {
  884. if let fourDevicesAllAccessPackNew6Months_lite = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.product {
  885. if #available(macOS 10.13.2, *) {
  886. let trialDays = fourDevicesAllAccessPackNew6Months_lite.introductoryPrice?.subscriptionPeriod.numberOfUnits
  887. tTips = String(
  888. format: NSLocalizedString("Billed every 6 months at %@ after %@-day trial ends.", comment: ""),
  889. monthPrice ?? "",
  890. "\(trialDays ?? 0)"
  891. )
  892. }
  893. }
  894. }
  895. #endif
  896. }
  897. if #available(macOS 10.13.2, *) {
  898. #if !VERSION_DMG
  899. if model.isPurchaseSwitch {
  900. if (IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product?.introductoryPrice == nil) {
  901. if model.isShowSale {
  902. tTips = String(format: NSLocalizedString("%@ for the first year's subscription", comment: ""), monthPriceDiscount ?? "")
  903. } else {
  904. tTips = String(format: NSLocalizedString("Billed every 12 months at %@", comment: ""), monthPrice ?? "")
  905. }
  906. }
  907. } else {
  908. if (IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.product.introductoryPrice == nil) {
  909. if model.isShowSale {
  910. tTips = String(format: NSLocalizedString("%@ for the first 6-month subscription", comment: ""), monthPriceDiscount ?? "")
  911. } else {
  912. tTips = String(format: NSLocalizedString("Billed every 6 months at %@", comment: ""), monthPrice ?? "")
  913. }
  914. }
  915. }
  916. #endif
  917. }
  918. value1PurchaseSubLabel.stringValue = String(format: NSLocalizedString("%@", comment: ""), tTips)
  919. value1PurchaseBtnLbl.font = NSFont.UbuntuBoldFontWithSize(16)
  920. #endif
  921. #else
  922. // AppStore 付费版
  923. // value1PurchaseBtnLbl.stringValue = NSLocalizedString("Subscribe", comment: "")
  924. let fourDevicesAllAccessPack12months_pro = IAPProductsManager.default().fourDevicesAllAccessPack12months_pro
  925. let standardAddDevicesAllAccessPack12months_pro = IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro
  926. let advancedAddDevicesAllAccessPack12months_pro = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro
  927. let advancedAdd2DevicesAllAccessPack12months_pro = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro
  928. // let pdfToOfficePackPermanent_pro = IAPProductsManager.default().pdfToOfficePackPermanent_pro
  929. let isTrialPeriod_year = fourDevicesAllAccessPack12months_pro?.isTrialPeriod ?? false
  930. let isTrialPeriod_standard = standardAddDevicesAllAccessPack12months_pro?.isTrialPeriod ?? false
  931. let isTrialPeriod_advanced1 = advancedAddDevicesAllAccessPack12months_pro?.isTrialPeriod ?? false
  932. let isTrialPeriod_advanced2 = advancedAdd2DevicesAllAccessPack12months_pro?.isTrialPeriod ?? false
  933. let isSubscribed_year = fourDevicesAllAccessPack12months_pro?.isSubscribed ?? false
  934. let isSubscribed_standard = standardAddDevicesAllAccessPack12months_pro?.isSubscribed ?? false
  935. let isSubscribed_advanced1 = advancedAddDevicesAllAccessPack12months_pro?.isSubscribed ?? false
  936. let isSubscribed_advanced2 = advancedAdd2DevicesAllAccessPack12months_pro?.isSubscribed ?? false
  937. let introductoryPrice_year = fourDevicesAllAccessPack12months_pro?.product?.introductoryPrice
  938. let introductoryPrice_standard = standardAddDevicesAllAccessPack12months_pro?.product?.introductoryPrice
  939. let introductoryPrice_advanced1 = advancedAddDevicesAllAccessPack12months_pro?.product?.introductoryPrice
  940. let introductoryPrice_advanced2 = advancedAdd2DevicesAllAccessPack12months_pro?.product?.introductoryPrice
  941. #endif
  942. }
  943. @objc func reloadDataContent() {
  944. tableView.reloadData()
  945. }
  946. func addWaitingView(to view: NSView) {
  947. removeWaitingView(from: view)
  948. let waitingView = WaitingView(frame: view.bounds)
  949. waitingView.autoresizingMask = [.width, .height]
  950. view.addSubview(waitingView)
  951. waitingView.startAnimation()
  952. }
  953. func removeWaitingView(from view: NSView) {
  954. for subview in view.subviews {
  955. if subview is WaitingView {
  956. subview.removeFromSuperview()
  957. break
  958. }
  959. }
  960. }
  961. func showDiscount() {
  962. discountYearly.isHidden = true
  963. discountPermanent.isHidden = true
  964. discountPermanent2.isHidden = true
  965. discountPermanent.isHidden = true
  966. #if VERSION_FREE
  967. #if VERSION_DMG
  968. // DMG
  969. if model.state != .dmg_Base { return }
  970. #else
  971. // AppStore 免费版本
  972. if model.state != .lite_Base { return }
  973. #endif
  974. #else
  975. // AppStore 付费版
  976. if model.state != .pro_Base { return }
  977. #endif
  978. let content = KMAdvertisementManager.manager.info.StoreUserRecovery?.content ?? []
  979. if content.count > 0 {
  980. for (index, item) in content.enumerated() {
  981. switch index {
  982. case 1:
  983. configureDiscountView(discountYearly, with: item)
  984. case 2:
  985. configureDiscountView(discountPermanent4, with: item)
  986. case 3:
  987. configureDiscountView(discountPermanent2, with: item)
  988. case 4:
  989. configureDiscountView(discountPermanent, with: item)
  990. default:
  991. break
  992. }
  993. }
  994. }
  995. }
  996. private func configureDiscountView(_ view: NSImageView, with itemInfo: KMAdvertisementItemInfo) {
  997. if KMAdvertisementManager.checkAdvertisementValid(itemInfo) {
  998. view.isHidden = false
  999. let urlString = KMAdvertisementModelTransition.transitionImagePath(image: itemInfo.image, highlight: false)
  1000. if let url = URL(string: urlString) {
  1001. view.image = KMAdvertisementImage.imageWithURL(url: url) { image in
  1002. view.image = image
  1003. }
  1004. }
  1005. } else {
  1006. view.isHidden = true
  1007. }
  1008. }
  1009. private func showAlert(message: String) {
  1010. let alert = NSAlert()
  1011. alert.alertStyle = .critical
  1012. alert.messageText = message
  1013. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  1014. alert.runModal()
  1015. }
  1016. private var alertingForRefreshUserInfo_ = false
  1017. private var alertingCodeForRefreshUserInfo_: Int?
  1018. private func handleVerificationFailure(msg: KMMemberProductResult?) {
  1019. if self.alertingForRefreshUserInfo_ {
  1020. KMPrint("刷新用户信息-Alert中。。。")
  1021. return
  1022. }
  1023. if msg?.code == 500 {
  1024. KMPrint("错误信息: One record is expected, but the query result is multiple records。。。")
  1025. return
  1026. }
  1027. if msg?.code == alertingCodeForRefreshUserInfo_ {
  1028. KMPrint("刷新用户信息-Alert中 重复Code 。。。")
  1029. return
  1030. }
  1031. var message = msg?.msg ?? ""
  1032. if !message.isEmpty {
  1033. alertingForRefreshUserInfo_ = true
  1034. alertingCodeForRefreshUserInfo_ = msg?.code
  1035. KMMemberCenterManager.showAlert(code: .init(rawValue: msg?.code ?? 0), message: msg?.msg) { [weak self] resp, _ in
  1036. DispatchQueue.main.async {
  1037. self?.alertingForRefreshUserInfo_ = false
  1038. // self?.alertingCodeForRefreshUserInfo_ = nil
  1039. }
  1040. }
  1041. }
  1042. }
  1043. // MARK: Button Actions
  1044. @IBAction func buttonItemClicked_Subscribe(_ sender: Any) {
  1045. if KMMemberInfo.shared.validFlag == "5" {
  1046. KMMemberPromptWC.shared.showWindow(nil)
  1047. KMMemberPromptWC.shared.tipType = .signouting
  1048. } else {
  1049. if model.isPurchaseSwitch {
  1050. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, discount: model.isCancelAutoRenew)
  1051. } else {
  1052. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, discount: model.isCancelAutoRenew)
  1053. }
  1054. addWaitingView(to: window?.contentView ?? NSView())
  1055. FMTrackEventManager.defaultManager.trackEvent(event: "PUW", withProperties: ["PUW_Btn": "PUW_Btn_Upgrade_6Mon"])
  1056. if model.isShowSale {
  1057. kEventTag = 1
  1058. if model.isPurchaseSwitch {
  1059. trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Btn": "PUW_7OffUpgrade_12Mon"], platform: .AppCenter)
  1060. } else {
  1061. trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Btn": "PUW_7OffUpgrade_6Mon"], platform: .AppCenter)
  1062. }
  1063. }
  1064. }
  1065. }
  1066. func showDiscountToSaveWindow() {
  1067. guard KMDiscountToSaveWindowController.needShow() else { return }
  1068. guard let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first,
  1069. let url = URL(string: KMAdvertisementModelTransition.transitionImagePath(image: info.image, highlight: true)) else { return }
  1070. addWaitingView(to: window?.contentView ?? NSView())
  1071. KMAdvertisementImage.imageWithURL(url: url) { [weak self] image in
  1072. guard let self = self else { return }
  1073. self.removeWaitingView(from: self.window?.contentView ?? NSView())
  1074. self.trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Exposure": "PUW_PromotionalOffer"], platform: .AppCenter)
  1075. let winC = KMDiscountToSaveWindowController(windowNibName: "KMDiscountToSaveWindowController")
  1076. self.discountToSaveWinC = winC
  1077. self.window?.beginSheet(winC.window!) { _ in }
  1078. winC.imgIv.image = image
  1079. winC.itemClick = { idx in
  1080. self.window?.endSheet(self.discountToSaveWinC?.window ?? NSWindow())
  1081. self.discountToSaveWinC = nil
  1082. if idx == 2 {
  1083. self.trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Btn": "PUW_PromotionalOffer_Subscribe"], platform: .AppCenter)
  1084. } else if idx == 1 {
  1085. self.trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Btn": "PUW_PromotionalOffer_Cancel"], platform: .AppCenter)
  1086. }
  1087. }
  1088. }
  1089. }
  1090. @IBAction func buttonItemClicked_Restore(_ sender: Any) {
  1091. model.productRestore()
  1092. addWaitingView(to: window?.contentView ?? NSView())
  1093. }
  1094. @IBAction func buttonItemClicked_Upgrade(_ sender: Any) {
  1095. NSWorkspace.shared.open(URL(string: "macappstore://apps.apple.com/app/id825459243?mt=12")!)
  1096. FMTrackEventManager.defaultManager.trackEvent(event: "PUW", withProperties: ["PUW_Btn": "PUW_Btn_Upgrade_Premium"])
  1097. }
  1098. @IBAction func privacyPolicyAction(_ sender: NSButton) {
  1099. model.privacyPolicyAction()
  1100. }
  1101. @IBAction func termOfSerAction(_ sender: NSButton) {
  1102. model.termOfSerAction()
  1103. }
  1104. @IBAction func buttonItemClicked_LicenseUpgrade(_ sender: Any) {
  1105. IAPProductsManager.default().make(IAPProductsManager.default().allAccessPackPermanent_lite)
  1106. addWaitingView(to: window?.contentView ?? NSView())
  1107. FMTrackEventManager.defaultManager.trackEvent(event: "PUW", withProperties: ["PUW_Btn": "PUW_Btn_Upgrade_Permanent"])
  1108. }
  1109. @IBAction func buttonItemClicked_AboutSubscriptions(_ sender: Any) {
  1110. let tMessage = """
  1111. Subscription plans:
  1112. Subscriptions: USD $39.99/(6 months), USD $79.99/(one-time purchase)
  1113. - Subscriptions will be charged through your iTunes account at the confirmation of purchase.
  1114. - Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period.
  1115. - Your iTunes account will be charged for renewal within 24-hours prior to the end of the current period, for the same duration and at the current subscription price.
  1116. - You may manage your subscriptions in your iTunes Account Settings after purchase.
  1117. - No cancellation of the current subscription is allowed during an active subscription period.
  1118. - Terms of service: \nhttps://www.pdfreaderpro.com/terms_of_service
  1119. - Privacy Policy: \nhttps://www.pdfreaderpro.com/privacy-policy
  1120. """
  1121. let alert = NSAlert()
  1122. alert.alertStyle = .informational
  1123. alert.messageText = NSLocalizedString(tMessage, comment: "")
  1124. alert.runModal()
  1125. }
  1126. @IBAction func buttonItemClicked_CloseWindow(_ sender: Any) {
  1127. close()
  1128. }
  1129. @objc func switchAction(_ sender: NSButton) {
  1130. model.isPurchaseSwitch.toggle()
  1131. }
  1132. @IBAction func appstorePurchaseAction(_ sender: NSButton) {
  1133. if KMMemberInfo.shared.validFlag == "5" {
  1134. KMMemberPromptWC.shared.showWindow(nil)
  1135. KMMemberPromptWC.shared.tipType = .signouting
  1136. } else {
  1137. #if !VERSION_DMG
  1138. addWaitingView(to: window?.contentView ?? NSView())
  1139. #endif
  1140. model.appstorePurchaseAction(sender.tag) { [weak self] success, msg in
  1141. guard let self = self else { return }
  1142. }
  1143. #if VERSION_DMG
  1144. close()
  1145. #endif
  1146. }
  1147. }
  1148. // MARK: - InAppPurchaseManager Notification
  1149. @objc func IAPProductFailedNotification(_ notification: Notification) {
  1150. removeWaitingView(from: window?.contentView ?? NSView())
  1151. }
  1152. @objc func IAPProductPurchasedNotification(_ notification: Notification) {
  1153. removeWaitingView(from: window?.contentView ?? NSView())
  1154. reloadData()
  1155. #if VERSION_FREE
  1156. #if VERSION_DMG
  1157. // DMG
  1158. #else
  1159. // AppStore 免费版本
  1160. if IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.isSubscribed {
  1161. if kEventTag == 1 {
  1162. trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Btn": "PUW_7OffUpgrade_6MonthPaid"], platform: .AppCenter)
  1163. }
  1164. } else if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isSubscribed {
  1165. if kEventTag == 1 {
  1166. trackEvent_free(eventName: "PromotionalOffer", params: ["PUW_Btn": "PUW_7OffUpgrade_12MonthPaid"], platform: .AppCenter)
  1167. }
  1168. }
  1169. #endif
  1170. #else
  1171. // AppStore 付费版
  1172. #endif
  1173. }
  1174. @objc func IAPProductLoadedNotification(_ notification: Notification) {
  1175. reloadData()
  1176. }
  1177. @objc func IAPProductRestoreFinishedNotification(_ notification: Notification) {
  1178. removeWaitingView(from: window?.contentView ?? NSView())
  1179. reloadData()
  1180. }
  1181. @objc func IAPProductRestoreFailedNotification(_ notification: Notification) {
  1182. removeWaitingView(from: window?.contentView ?? NSView())
  1183. }
  1184. @objc func IAPSubscriptionLoadedNotification(_ notification: Notification) {
  1185. removeWaitingView(from: window?.contentView ?? NSView())
  1186. reloadData()
  1187. DispatchQueue.global().async { [weak self] in
  1188. guard let self = self else { return }
  1189. if KMMemberInfo.shared.isLogin {
  1190. self.model.appStoreEquityVerification(notification) { success, msg in
  1191. DispatchQueue.main.async {
  1192. if success {
  1193. // self.showAlert(message: NSLocalizedString("Binding Interest Success!", comment: ""))
  1194. KMUserInfoVCModel().refreshUserInfo { success, msg,dic in
  1195. if(success) {
  1196. NotificationCenter.default.post(name: NSNotification.Name.KMMemberInfoChange, object: self)
  1197. }
  1198. }
  1199. self.window?.close()
  1200. } else {
  1201. self.handleVerificationFailure(msg: msg)
  1202. }
  1203. }
  1204. }
  1205. }
  1206. }
  1207. }
  1208. @objc func themeChanged(_ notification: Notification) {
  1209. DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
  1210. self.box.fillColor = KMAppearance.Layout.l1Color()
  1211. self.labelbox.fillColor = .clear
  1212. self.tableView.backgroundColor = KMAppearance.Layout.l0Color()
  1213. self.textView.backgroundColor = .clear
  1214. self.textView.textColor = NSColor.white.withAlphaComponent(0.5)
  1215. self.value1PurchaseSubLabel.textColor = KMAppearance.Layout.w0Color()
  1216. self.permanentPurchaseSubLabel.textColor = KMAppearance.Layout.w0Color()
  1217. }
  1218. }
  1219. // MARK: Bind Method
  1220. func bindViewModel() -> Void {
  1221. model.$state
  1222. .receive(on: RunLoop.main)
  1223. .sink { [weak self] newValue in
  1224. }
  1225. .store(in: &cancellables)
  1226. model.$isPurchaseSwitch
  1227. .receive(on: RunLoop.main)
  1228. .sink { [weak self] newValue in
  1229. self?.reloadDataContent()
  1230. #if VERSION_FREE
  1231. #if VERSION_DMG
  1232. // DMG
  1233. #else
  1234. // AppStore 免费版本
  1235. self?.refreshPurchaseSwitch()
  1236. #endif
  1237. #else
  1238. // AppStore 付费版
  1239. #endif
  1240. }
  1241. .store(in: &cancellables)
  1242. }
  1243. }
  1244. extension KMProductCompareWC: NSTableViewDelegate, NSTableViewDataSource {
  1245. // MARK: NSTableViewDataSource Methods
  1246. func numberOfRows(in tableView: NSTableView) -> Int {
  1247. return model.dataSource.count
  1248. }
  1249. // tableView:viewForTableColumn:row
  1250. func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
  1251. let object = model.dataSource[row]
  1252. if let stringObject = object as? String {
  1253. if let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("KMProductCompareTableHeaderCell"), owner: self) as? KMProductCompareTableHeaderCell {
  1254. cellView.textField?.stringValue = NSLocalizedString(stringObject, comment: "")
  1255. if model.state == .dmg_Base {
  1256. cellView.selectBoxLeft.constant = 352.0 + 149.5 + 149.5
  1257. cellView.selectBoxWidth.constant = 149.5
  1258. } else if model.state == .dmg_Upgrades1 {
  1259. cellView.selectBoxLeft.constant = 352.0
  1260. cellView.selectBoxWidth.constant = 320.0
  1261. } else if model.state == .dmg_Upgrades2 {
  1262. cellView.selectBoxLeft.constant = 352.0
  1263. cellView.selectBoxWidth.constant = 320.0
  1264. } else if model.state == .lite_Base {
  1265. cellView.selectBoxLeft.constant = 352.0 + 179.0
  1266. cellView.selectBoxWidth.constant = 240.0
  1267. } else if model.state == .lite_MacWindows {
  1268. cellView.selectBoxLeft.constant = 352.0
  1269. cellView.selectBoxWidth.constant = 320.0
  1270. } else if model.state == .pro_Base {
  1271. cellView.selectBoxLeft.constant = 352.0
  1272. cellView.selectBoxWidth.constant = 299.0
  1273. } else if model.state == .pro_Advanced {
  1274. cellView.selectBoxLeft.constant = 352.0
  1275. cellView.selectBoxWidth.constant = 320.0
  1276. } else {
  1277. // model.state == .trial
  1278. cellView.selectBoxLeft.constant = 352.0 + 179.0
  1279. cellView.selectBoxWidth.constant = 240.0
  1280. }
  1281. return cellView
  1282. }
  1283. } else if let arrayObject = object as? [String] {
  1284. if let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("KMProductCompareTableCell"), owner: self) as? KMProductCompareTableCell {
  1285. let value1 = arrayObject.indices.contains(0) ? arrayObject[0] : ""
  1286. let value2 = arrayObject.indices.contains(1) ? arrayObject[1] : ""
  1287. let value3 = arrayObject.indices.contains(2) ? arrayObject[2] : ""
  1288. let value4 = arrayObject.indices.contains(3) ? arrayObject[3] : ""
  1289. let value5 = arrayObject.indices.contains(4) ? arrayObject[4] : ""
  1290. let value6 = arrayObject.indices.contains(5) ? arrayObject[5] : ""
  1291. cellView.textField?.stringValue = NSLocalizedString(value1, comment: "")
  1292. cellView.lineBox?.isHidden = false
  1293. if row + 1 == model.dataSource.count || model.dataSource[row + 1] is String {
  1294. cellView.lineBox?.isHidden = true
  1295. }
  1296. checkOrNot(cellView)
  1297. cellView.boxBottomConst?.constant = (row + 2 == model.dataSource.count) ? 0 : -4
  1298. updateCellView(cellView, value1: value2, value2: value3, value3: value4, value4: value5, value5: value6)
  1299. return cellView
  1300. }
  1301. } else if object is [String: Any] {
  1302. if let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("KMProductCompareTableEmptyCell"), owner: self) as? KMProductCompareTableEmptyCell {
  1303. return cellView
  1304. }
  1305. }
  1306. return nil
  1307. }
  1308. // tableView:heightOfRow
  1309. func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
  1310. let object = model.dataSource[row]
  1311. var cellView: NSTableCellView?
  1312. if let stringObject = object as? String {
  1313. if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("KMProductCompareTableHeaderCell"), owner: self) as? KMProductCompareTableHeaderCell {
  1314. cell.textField?.stringValue = NSLocalizedString(stringObject, comment: "")
  1315. cellView = cell
  1316. }
  1317. } else if let arrayObject = object as? [String] {
  1318. if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("KMProductCompareTableCell"), owner: self) as? KMProductCompareTableCell {
  1319. cell.textField?.stringValue = NSLocalizedString(arrayObject[0], comment: "")
  1320. cellView = cell
  1321. }
  1322. } else if object is [String: Any] {
  1323. return 40
  1324. }
  1325. if let view = cellView {
  1326. view.layoutSubtreeIfNeeded()
  1327. return view.frame.size.height
  1328. } else {
  1329. return 44
  1330. }
  1331. }
  1332. // Helper function to update cell view for multiple values
  1333. private func updateCellView(_ cellView: KMProductCompareTableCell, value1: String, value2: String, value3: String, value4: String, value5: String) {
  1334. if model.state == .dmg_Base {
  1335. configureCellView(cellView, value: value1, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1336. configureCellView(cellView, value: value2, label: cellView.value2Label, imageView: cellView.value2ImageView, platformsBox: cellView.platformsBox2)
  1337. configureCellView(cellView, value: value3, label: cellView.value3Label, imageView: cellView.value3ImageView, platformsBox: cellView.platformsBox3)
  1338. configureCellView(cellView, value: value4, label: cellView.value4Label, imageView: cellView.value4ImageView, platformsBox: cellView.platformsBox4)
  1339. } else if model.state == .dmg_Upgrades1 {
  1340. configureCellView(cellView, value: value3, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1341. } else if model.state == .dmg_Upgrades2 {
  1342. configureCellView(cellView, value: value3, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1343. } else if model.state == .lite_Base {
  1344. configureCellView(cellView, value: value1, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1345. configureCellView(cellView, value: value3, label: cellView.value2Label, imageView: cellView.value2ImageView, platformsBox: cellView.platformsBox2)
  1346. configureCellView(cellView, value: value4, label: cellView.value3Label, imageView: cellView.value3ImageView, platformsBox: cellView.platformsBox3)
  1347. } else if model.state == .lite_MacWindows {
  1348. configureCellView(cellView, value: value3, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1349. } else if model.state == .pro_Base {
  1350. configureCellView(cellView, value: value3, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1351. configureCellView(cellView, value: value5, label: cellView.value2Label, imageView: cellView.value2ImageView, platformsBox: cellView.platformsBox2)
  1352. } else if model.state == .pro_Advanced {
  1353. configureCellView(cellView, value: value3, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1354. } else {
  1355. // model.state == .trial
  1356. configureCellView(cellView, value: value1, label: cellView.value1Label, imageView: cellView.value1ImageView, platformsBox: cellView.platformsBox1)
  1357. configureCellView(cellView, value: value3, label: cellView.value2Label, imageView: cellView.value2ImageView, platformsBox: cellView.platformsBox2)
  1358. }
  1359. }
  1360. // Helper function to configure each individual value
  1361. private func configureCellView(_ cellView: KMProductCompareTableCell, value: String, label: NSTextField?, imageView: NSImageView?, platformsBox: NSBox?) {
  1362. platformsBox?.isHidden = true
  1363. label?.isHidden = false
  1364. imageView?.isHidden = false
  1365. switch value {
  1366. case "X":
  1367. label?.stringValue = ""
  1368. imageView?.image = NSImage(named: "compare_nosupport")
  1369. case "✓":
  1370. label?.stringValue = ""
  1371. imageView?.image = NSImage(named: "compare_support")
  1372. case "∞":
  1373. label?.stringValue = ""
  1374. imageView?.image = NSImage(named: "compare_00")
  1375. default:
  1376. if value == "mac, windows, ios, android" ||
  1377. value == "mac, windows" ||
  1378. value == "mac" {
  1379. platformsBox?.isHidden = false
  1380. label?.isHidden = true
  1381. imageView?.isHidden = true
  1382. if value == "mac, windows, ios, android" {
  1383. // platformsBox?.contentView = platformsView4
  1384. } else if value == "mac, windows" {
  1385. platformsBox?.contentView = platformsView2
  1386. } else if value == "mac" {
  1387. platformsBox?.contentView = platformsView1
  1388. }
  1389. } else {
  1390. label?.stringValue = NSLocalizedString(value, comment: "")
  1391. imageView?.image = nil
  1392. }
  1393. }
  1394. }
  1395. private func checkOrNot(_ cellView: KMProductCompareTableCell) {
  1396. cellView.selectBox1.isHidden = true
  1397. cellView.selectBox2.isHidden = true
  1398. cellView.selectBox3.isHidden = true
  1399. cellView.selectBox4.isHidden = true
  1400. cellView.cellView1.isHidden = true
  1401. cellView.cellView2.isHidden = true
  1402. cellView.cellView3.isHidden = true
  1403. cellView.cellView4.isHidden = true
  1404. if model.state == .dmg_Base {
  1405. cellView.selectBox3.isHidden = false
  1406. cellView.cellView1.isHidden = false
  1407. cellView.cellView2.isHidden = false
  1408. cellView.cellView3.isHidden = false
  1409. cellView.cellView4.isHidden = false
  1410. cellView.viewWidth1.constant = 149.5
  1411. cellView.viewWidth2.constant = 149.5
  1412. cellView.viewWidth3.constant = 149.5
  1413. cellView.viewWidth4.constant = 149.5
  1414. } else if model.state == .dmg_Upgrades1 {
  1415. cellView.selectBox1.isHidden = false
  1416. cellView.cellView1.isHidden = false
  1417. cellView.viewWidth1.constant = 320.0
  1418. } else if model.state == .dmg_Upgrades2 {
  1419. cellView.selectBox1.isHidden = false
  1420. cellView.cellView1.isHidden = false
  1421. cellView.viewWidth1.constant = 320.0
  1422. } else if model.state == .lite_Base {
  1423. cellView.selectBox2.isHidden = false
  1424. cellView.cellView1.isHidden = false
  1425. cellView.cellView2.isHidden = false
  1426. cellView.cellView3.isHidden = false
  1427. cellView.viewWidth1.constant = 179.0
  1428. cellView.viewWidth2.constant = 240.0
  1429. cellView.viewWidth3.constant = 240.0
  1430. } else if model.state == .lite_MacWindows {
  1431. cellView.selectBox1.isHidden = false
  1432. cellView.viewWidth1.constant = 320.0
  1433. cellView.cellView1.isHidden = false
  1434. } else if model.state == .pro_Base {
  1435. cellView.selectBox1.isHidden = false
  1436. cellView.viewWidth1.constant = 299.0
  1437. cellView.cellView1.isHidden = false
  1438. cellView.cellView2.isHidden = false
  1439. cellView.viewWidth2.constant = 299.0
  1440. } else if model.state == .pro_Advanced {
  1441. cellView.selectBox1.isHidden = false
  1442. cellView.viewWidth1.constant = 320.0
  1443. cellView.cellView1.isHidden = false
  1444. } else {
  1445. // model.state == .trial
  1446. cellView.cellView1.isHidden = false
  1447. cellView.cellView2.isHidden = false
  1448. cellView.selectBox2.isHidden = false
  1449. cellView.viewWidth1.constant = 179.0
  1450. cellView.viewWidth2.constant = 240.0
  1451. }
  1452. }
  1453. }
  1454. class KMProductCompareTableCell: NSTableCellView {
  1455. @IBOutlet weak var bgColorView: NSView!
  1456. @IBOutlet @objc weak var cellView1: NSView!
  1457. @IBOutlet @objc weak var cellView2: NSView!
  1458. @IBOutlet @objc weak var cellView3: NSView!
  1459. @IBOutlet @objc weak var cellView4: NSView!
  1460. @IBOutlet weak var value1Label: NSTextField!
  1461. @IBOutlet weak var value2Label: NSTextField!
  1462. @IBOutlet weak var value3Label: NSTextField!
  1463. @IBOutlet weak var value4Label: NSTextField!
  1464. @IBOutlet weak var value1ImageView: NSImageView!
  1465. @IBOutlet weak var value2ImageView: NSImageView!
  1466. @IBOutlet weak var value3ImageView: NSImageView!
  1467. @IBOutlet weak var value4ImageView: NSImageView!
  1468. @IBOutlet weak var lineBox: NSBox!
  1469. @IBOutlet weak var boxBottomConst: NSLayoutConstraint!
  1470. @IBOutlet @objc weak var platformsBox1: NSBox!
  1471. @IBOutlet @objc weak var platformsBox2: NSBox!
  1472. @IBOutlet @objc weak var platformsBox3: NSBox!
  1473. @IBOutlet @objc weak var platformsBox4: NSBox!
  1474. @IBOutlet @objc weak var selectBox1: NSBox!
  1475. @IBOutlet @objc weak var selectBox2: NSBox!
  1476. @IBOutlet @objc weak var selectBox3: NSBox!
  1477. @IBOutlet @objc weak var selectBox4: NSBox!
  1478. @IBOutlet weak var viewWidth1: NSLayoutConstraint!
  1479. @IBOutlet weak var viewWidth2: NSLayoutConstraint!
  1480. @IBOutlet weak var viewWidth3: NSLayoutConstraint!
  1481. @IBOutlet weak var viewWidth4: NSLayoutConstraint!
  1482. override func awakeFromNib() {
  1483. super.awakeFromNib()
  1484. bgColorView.wantsLayer = true
  1485. updateViewColor()
  1486. NotificationCenter.default.addObserver(
  1487. self,
  1488. selector: #selector(themeChanged(_:)),
  1489. name: NSNotification.Name("AppleInterfaceThemeChangedNotification"),
  1490. object: nil
  1491. )
  1492. }
  1493. deinit {
  1494. NotificationCenter.default.removeObserver(self)
  1495. }
  1496. @objc func themeChanged(_ notification: Notification) {
  1497. DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
  1498. self.updateViewColor()
  1499. }
  1500. }
  1501. private func updateViewColor() {
  1502. var textColor = NSColor(red: 68.0 / 255.0, green: 68.0 / 255.0, blue: 68.0 / 255.0, alpha: 1.0)
  1503. var subtextColor = NSColor(red: 141.0 / 255.0, green: 141.0 / 255.0, blue: 141.0 / 255.0, alpha: 1.0)
  1504. var lineColor = NSColor(red: 204.0 / 255.0, green: 204.0 / 255.0, blue: 204.0 / 255.0, alpha: 0.4)
  1505. if let layer = bgColorView.layer {
  1506. if KMAppearance.isDarkMode() {
  1507. layer.backgroundColor = NSColor(red: 24.0 / 255.0, green: 22.0 / 255.0, blue: 31.0 / 255.0, alpha: 1.0).cgColor
  1508. textColor = NSColor(red: 255.0 / 255.0, green: 255.0 / 255.0, blue: 255.0 / 255.0, alpha: 0.8)
  1509. subtextColor = NSColor(red: 255.0 / 255.0, green: 255.0 / 255.0, blue: 255.0 / 255.0, alpha: 0.6)
  1510. lineColor = NSColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.15)
  1511. } else {
  1512. layer.backgroundColor = NSColor(red: 247.0 / 255.0, green: 245.0 / 255.0, blue: 1.0, alpha: 1.0).cgColor
  1513. }
  1514. }
  1515. value1Label.textColor = subtextColor
  1516. value2Label.textColor = subtextColor
  1517. value3Label.textColor = subtextColor
  1518. value4Label.textColor = subtextColor
  1519. lineBox.fillColor = lineColor
  1520. textField?.textColor = textColor
  1521. }
  1522. }
  1523. class KMProductCompareTableHeaderCell: NSTableCellView {
  1524. @IBOutlet weak var contentView: NSView?
  1525. @IBOutlet weak var selectBoxLeft: NSLayoutConstraint!
  1526. @IBOutlet weak var selectBoxWidth: NSLayoutConstraint!
  1527. deinit {
  1528. NotificationCenter.default.removeObserver(self)
  1529. }
  1530. override func awakeFromNib() {
  1531. super.awakeFromNib()
  1532. contentView?.wantsLayer = true
  1533. updateViewColor()
  1534. NotificationCenter.default.addObserver(
  1535. self,
  1536. selector: #selector(themeChanged(_:)),
  1537. name: NSNotification.Name("AppleInterfaceThemeChangedNotification"),
  1538. object: nil
  1539. )
  1540. }
  1541. @objc private func themeChanged(_ notification: Notification) {
  1542. DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
  1543. self.updateViewColor()
  1544. }
  1545. }
  1546. private func updateViewColor() {
  1547. if KMAppearance.isDarkMode() {
  1548. contentView?.layer?.backgroundColor = NSColor(red: 40/255, green: 38/255, blue: 47/255, alpha: 1).cgColor
  1549. } else {
  1550. contentView?.layer?.backgroundColor = NSColor(red: 237/255, green: 231/255, blue: 255/255, alpha: 1).cgColor
  1551. }
  1552. textField?.textColor = KMAppearance.Layout.h0Color()
  1553. textField?.font = NSFont.boldSystemFont(ofSize: 14.0)
  1554. }
  1555. }
  1556. class KMProductCompareTableEmptyCell: NSTableCellView {
  1557. override func awakeFromNib() {
  1558. super.awakeFromNib()
  1559. self.wantsLayer = true
  1560. updateViewColor()
  1561. DistributedNotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
  1562. }
  1563. deinit {
  1564. DistributedNotificationCenter.default.removeObserver(self)
  1565. }
  1566. @objc private func themeChanged(_ notification: Notification) {
  1567. DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
  1568. self.updateViewColor()
  1569. }
  1570. }
  1571. private func updateViewColor() {
  1572. if KMAppearance.isDarkMode() {
  1573. self.layer?.backgroundColor = NSColor(red: 24/255.0, green: 22/255.0, blue: 31/255.0, alpha: 1.0).cgColor
  1574. } else {
  1575. self.layer?.backgroundColor = NSColor(red: 247/255.0, green: 245/255.0, blue: 1.0, alpha: 1.0).cgColor
  1576. }
  1577. }
  1578. }