KMUserInfoViewController.swift 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. //
  2. // KMUserInfoViewController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/10/30.
  6. //
  7. import Cocoa
  8. import Combine
  9. class KMGradationBox: NSBox {
  10. override func draw(_ dirtyRect: NSRect){
  11. super.draw(dirtyRect)
  12. guard let context = NSGraphicsContext.current?.cgContext else { return }
  13. // 定义渐变颜色
  14. let colors = [NSColor(hex: "EBDABD").cgColor, NSColor(hex: "E5CCA8").cgColor]
  15. let gradient = CGGradient(colorsSpace: nil, colors: colors as CFArray, locations: nil)
  16. // 定义渐变起始和结束点
  17. let startPoint = CGPoint(x: bounds.minX, y: bounds.minY)
  18. let endPoint = CGPoint(x: bounds.maxX, y: bounds.maxY)
  19. // 绘制圆角矩形路径
  20. let roundedPath = NSBezierPath(roundedRect: bounds, xRadius: 4, yRadius: 4) // 你的圆角半径
  21. roundedPath.addClip() // 添加路径为剪切区域
  22. context.clip() // 使路径生效
  23. // 绘制渐变
  24. context.drawLinearGradient(gradient!, start: startPoint, end: endPoint, options: [])
  25. context.restoreGState()
  26. }
  27. }
  28. @objcMembers
  29. class KMUserInfoViewController: NSViewController {
  30. @IBOutlet weak var userImageView: NSImageView!
  31. @IBOutlet weak var emailLabel: NSTextField!
  32. @IBOutlet weak var productLabel: NSTextField!
  33. @IBOutlet weak var spliLineImageView: NSImageView!
  34. @IBOutlet weak var endDateLabel: NSTextField!
  35. @IBOutlet weak var membershipLabel: NSTextField!
  36. @IBOutlet weak var lockedImageView: NSImageView!
  37. @IBOutlet weak var lockedLabel: NSTextField!
  38. @IBOutlet var lockedLabelWidthffset:NSLayoutConstraint!
  39. @IBOutlet var lockedBox:KMGradationBox!
  40. @IBOutlet weak var centerBackgroud: NSImageView!
  41. @IBOutlet weak var rightsBox: NSBox!
  42. @IBOutlet var rightsView: NSView!
  43. @IBOutlet weak var number1Label: NSTextField!
  44. @IBOutlet weak var number1ImageView: NSImageView!
  45. @IBOutlet weak var number2Label: NSTextField!
  46. @IBOutlet weak var iconBox: NSBox!
  47. @IBOutlet var iconView1: NSView!
  48. @IBOutlet weak var icon1ImageView: NSImageView!
  49. @IBOutlet weak var icon2ImageView: NSImageView!
  50. @IBOutlet weak var icon3ImageView: NSImageView!
  51. @IBOutlet weak var icon4ImageView: NSImageView!
  52. @IBOutlet var iconView2: NSView!
  53. @IBOutlet weak var icon5ImageView: NSImageView!
  54. @IBOutlet weak var icon6ImageView: NSImageView!
  55. @IBOutlet weak var icon7ImageView: NSImageView!
  56. @IBOutlet var iconView3: NSView!
  57. @IBOutlet weak var icon8ImageView: NSImageView!
  58. @IBOutlet weak var icon9ImageView: NSImageView!
  59. @IBOutlet var iconView4: NSView!
  60. @IBOutlet weak var icon10ImageView: NSImageView!
  61. @IBOutlet weak var number3Label: NSTextField!
  62. @IBOutlet weak var number4Label: NSTextField!
  63. @IBOutlet weak var number4_1Label: NSTextField!
  64. @IBOutlet weak var number5Label: NSTextField!
  65. @IBOutlet weak var buyBox: NSBox!
  66. @IBOutlet var buyView1: NSView!
  67. @IBOutlet weak var buyNow1Box: KMBox!
  68. @IBOutlet weak var buyNow1ImageView: NSImageView!
  69. @IBOutlet weak var buyNow1Label: NSTextField!
  70. @IBOutlet weak var arrow1ImageView: NSImageView!
  71. @IBOutlet weak var buyNow2Box: KMBox!
  72. @IBOutlet weak var buyNow2ImageView: NSImageView!
  73. @IBOutlet weak var buyNow2Label: NSTextField!
  74. @IBOutlet weak var arrow2ImageView: NSImageView!
  75. @IBOutlet var buyNow1BoxLeftConst: NSLayoutConstraint!
  76. @IBOutlet weak var accountCenterBox: KMBox!
  77. @IBOutlet weak var accountImageView: NSImageView!
  78. @IBOutlet weak var accountLabel: NSTextField!
  79. @IBOutlet weak var signOutBox: KMBox!
  80. @IBOutlet weak var signOutImageView: NSImageView!
  81. @IBOutlet weak var signOutLabel: NSTextField!
  82. @IBOutlet weak var closeAccountBox: KMBox!
  83. @IBOutlet weak var closeAccountImageView: NSImageView!
  84. @IBOutlet weak var closeAccountLabel: NSTextField!
  85. private var viewModel = KMUserInfoVCModel()
  86. private var cancellables = Set<AnyCancellable>()
  87. deinit {
  88. KMPrint("KMUserInfoViewController deinit.")
  89. }
  90. override func viewDidLoad() {
  91. super.viewDidLoad()
  92. // Do view setup here.
  93. self.view.wantsLayer = true
  94. self.view.layer?.backgroundColor = .white
  95. #if VERSION_FREE
  96. #if VERSION_DMG
  97. // DMG
  98. languageLocalized_DMG()
  99. initializeUI_DMG()
  100. #else
  101. // AppStore 免费版本
  102. languageLocalized()
  103. initializeUI()
  104. #endif
  105. #else
  106. // AppStore 付费版
  107. languageLocalized()
  108. initializeUI()
  109. #endif
  110. NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
  111. }
  112. @objc func changeEffectiveAppearance() {
  113. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  114. if isDarkModel {
  115. self.view.appearance = NSAppearance(named: .darkAqua)
  116. } else {
  117. self.view.appearance = NSAppearance(named: .aqua)
  118. }
  119. #if VERSION_FREE
  120. #if VERSION_DMG
  121. // DMG
  122. initializeUI_DMG()
  123. #else
  124. // AppStore 免费版本
  125. initializeUI()
  126. #endif
  127. #else
  128. // AppStore 付费版
  129. initializeUI()
  130. #endif
  131. }
  132. // MARK: Private Method
  133. private func languageLocalized() -> Void {
  134. emailLabel.stringValue = KMMemberInfo.shared.userEmail
  135. productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
  136. endDateLabel.stringValue = String(format: "%@ %@", KMMemberInfo.shared.vip_endDate,NSLocalizedString("expires", tableName: "MemberCenterLocalizable", comment: ""))
  137. membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
  138. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  139. accountLabel.stringValue = NSLocalizedString("Account Center", tableName: "MemberCenterLocalizable", comment: "")
  140. signOutLabel.stringValue = NSLocalizedString("Sign out", tableName: "MemberCenterLocalizable", comment: "")
  141. if KMMemberInfo.shared.validFlag == "5" {
  142. closeAccountLabel.stringValue = NSLocalizedString("Undo Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  143. } else {
  144. closeAccountLabel.stringValue = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  145. }
  146. if KMMemberInfo.shared.vip_maxDeviceNum == 1 {
  147. number4Label.stringValue = NSLocalizedString("device", tableName: "MemberCenterLocalizable", comment: "")
  148. } else {
  149. number4Label.stringValue = NSLocalizedString("devices", tableName: "MemberCenterLocalizable", comment: "")
  150. }
  151. number4_1Label.stringValue = String(KMMemberInfo.shared.vip_maxDeviceNum)
  152. number5Label.stringValue = NSLocalizedString("Devices Access", tableName: "MemberCenterLocalizable", comment: "")
  153. let platforms = viewModel.getPlatformsImages()
  154. if platforms.count == 4 {
  155. number3Label.stringValue = NSLocalizedString("All-platform Available", tableName: "MemberCenterLocalizable", comment: "")
  156. } else {
  157. number3Label.stringValue = NSLocalizedString("Platform", tableName: "MemberCenterLocalizable", comment: "")
  158. }
  159. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  160. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  161. var isTrialPeriod = false
  162. #if !VERSION_DMG
  163. if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
  164. isTrialPeriod = true
  165. }
  166. #else
  167. #endif
  168. if isTrialPeriod {
  169. buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
  170. } else {
  171. buyNow2Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  172. }
  173. } else if KMMemberInfo.shared.userScenarioType == .lite_type9 {
  174. if(KMMemberInfo.shared.vip_status == 2) {
  175. buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  176. } else if (KMMemberInfo.shared.vip_status == 4) {
  177. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  178. } else {
  179. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  180. }
  181. } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
  182. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  183. } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
  184. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  185. } else if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  186. KMMemberInfo.shared.userScenarioType == .pro_type1 ||
  187. KMMemberInfo.shared.userScenarioType == .pro_type3 ||
  188. KMMemberInfo.shared.userScenarioType == .pro_type4 {
  189. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  190. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
  191. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  192. KMMemberInfo.shared.userScenarioType == .lite_type13 {
  193. buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  194. }
  195. }
  196. private func refreshEquity() -> Void {
  197. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  198. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  199. lockedImageView.image = NSImage(named: "LockedImage")
  200. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  201. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  202. number1ImageView.isHidden = true
  203. number1Label.isHidden = false
  204. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  205. number1Label.textColor = NSColor(hex: "0E1114")
  206. membershipLabel.textColor = NSColor(hex: "42464D")
  207. } else if KMMemberInfo.shared.userScenarioType == .lite_type2 {
  208. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  209. lockedImageView.image = NSImage(named: "UpgradeImage2")
  210. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  211. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  212. number1ImageView.isHidden = false
  213. number1Label.isHidden = true
  214. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  215. } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
  216. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  217. lockedImageView.image = NSImage(named: "LockedImage")
  218. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  219. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  220. number1ImageView.isHidden = true
  221. number1Label.isHidden = false
  222. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  223. number1Label.textColor = NSColor(hex: "0E1114")
  224. } else if KMMemberInfo.shared.userScenarioType == .lite_type4 {
  225. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  226. lockedImageView.image = NSImage(named: "UpgradeImage2")
  227. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  228. if KMMemberInfo.shared.vip_levels == "2" {
  229. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  230. } else {
  231. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  232. }
  233. number1ImageView.isHidden = false
  234. number1Label.isHidden = true
  235. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  236. } else if KMMemberInfo.shared.userScenarioType == .lite_type5 {
  237. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  238. lockedImageView.image = NSImage(named: "UpgradeImage2")
  239. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  240. if KMMemberInfo.shared.vip_levels == "2" {
  241. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  242. } else {
  243. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  244. }
  245. number1ImageView.isHidden = false
  246. number1Label.isHidden = true
  247. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  248. } else if KMMemberInfo.shared.userScenarioType == .lite_type6 {
  249. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  250. lockedImageView.image = NSImage(named: "UpgradeImage2")
  251. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  252. if KMMemberInfo.shared.vip_levels == "2" {
  253. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  254. } else {
  255. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  256. }
  257. number1ImageView.isHidden = false
  258. number1Label.isHidden = true
  259. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  260. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 {
  261. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  262. lockedImageView.image = NSImage(named: "LockedImage")
  263. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  264. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  265. number1ImageView.isHidden = true
  266. number1Label.isHidden = false
  267. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  268. number1Label.textColor = NSColor(hex: "0E1114")
  269. } else if KMMemberInfo.shared.userScenarioType == .lite_type8 {
  270. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  271. lockedImageView.image = NSImage(named: "UpgradeImage2")
  272. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  273. if KMMemberInfo.shared.vip_levels == "2" {
  274. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  275. } else {
  276. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  277. }
  278. number1ImageView.isHidden = false
  279. number1Label.isHidden = true
  280. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  281. } else if KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  282. KMMemberInfo.shared.userScenarioType == .pro_type1 {
  283. if(KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1") { //永久
  284. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  285. lockedImageView.image = NSImage(named: "UpgradeImage2")
  286. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  287. if KMMemberInfo.shared.vip_levels == "2" {
  288. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  289. } else {
  290. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  291. }
  292. number1ImageView.isHidden = false
  293. number1Label.isHidden = true
  294. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  295. } else { //免费+订阅过期+试用过期
  296. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  297. lockedImageView.image = NSImage(named: "LockedImage")
  298. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  299. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  300. number1ImageView.isHidden = true
  301. number1Label.isHidden = false
  302. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  303. number1Label.textColor = NSColor(hex: "0E1114")
  304. }
  305. } else if KMMemberInfo.shared.userScenarioType == .lite_type10 {
  306. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  307. lockedImageView.image = NSImage(named: "UpgradeImage2")
  308. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  309. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  310. number1ImageView.isHidden = false
  311. number1Label.isHidden = true
  312. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  313. } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
  314. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  315. lockedImageView.image = NSImage(named: "LockedImage")
  316. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  317. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  318. number1ImageView.isHidden = true
  319. number1Label.isHidden = false
  320. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  321. number1Label.textColor = NSColor(hex: "0E1114")
  322. } else if KMMemberInfo.shared.userScenarioType == .lite_type12 {
  323. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  324. lockedImageView.image = NSImage(named: "UpgradeImage2")
  325. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  326. if(KMMemberInfo.shared.vip_levels == "2") {
  327. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  328. } else if((KMMemberInfo.shared.vip_levels == "3")) {
  329. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  330. }
  331. number1ImageView.isHidden = false
  332. number1Label.isHidden = true
  333. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  334. } else if KMMemberInfo.shared.userScenarioType == .lite_type13 {
  335. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  336. lockedImageView.image = NSImage(named: "UpgradeImage2")
  337. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  338. if KMMemberInfo.shared.vip_levels == "2" {
  339. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  340. } else {
  341. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  342. }
  343. number1ImageView.isHidden = false
  344. number1Label.isHidden = true
  345. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  346. } else if KMMemberInfo.shared.userScenarioType == .pro_type2 {
  347. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  348. lockedImageView.image = NSImage(named: "UpgradeImage2")
  349. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  350. if KMMemberInfo.shared.vip_levels == "2" {
  351. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  352. } else {
  353. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  354. }
  355. number1ImageView.isHidden = false
  356. number1Label.isHidden = true
  357. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  358. number1Label.textColor = NSColor(named: "FFFFFF")
  359. } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  360. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  361. lockedImageView.image = NSImage(named: "LockedImage")
  362. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  363. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  364. number1ImageView.isHidden = true
  365. number1Label.isHidden = false
  366. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  367. number1Label.textColor = NSColor(hex: "0E1114")
  368. } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
  369. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  370. lockedImageView.image = NSImage(named: "UpgradeImage2")
  371. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  372. if KMMemberInfo.shared.vip_levels == "2" {
  373. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  374. } else {
  375. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  376. }
  377. number1ImageView.isHidden = false
  378. number1Label.isHidden = true
  379. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  380. } else if KMMemberInfo.shared.userScenarioType == .pro_type5 {
  381. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  382. lockedImageView.image = NSImage(named: "UpgradeImage2")
  383. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  384. if KMMemberInfo.shared.vip_levels == "2" {
  385. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  386. } else {
  387. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  388. }
  389. number1ImageView.isHidden = false
  390. number1Label.isHidden = true
  391. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  392. } else {
  393. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  394. lockedImageView.image = NSImage(named: "LockedImage")
  395. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  396. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  397. number1ImageView.isHidden = true
  398. number1Label.isHidden = false
  399. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  400. number1Label.textColor = NSColor(hex: "0E1114")
  401. }
  402. }
  403. private func initializeUI() -> Void {
  404. refreshEquity()
  405. self.view.wantsLayer = true
  406. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  407. if isDarkModel {
  408. self.view.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  409. } else {
  410. self.view.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  411. }
  412. userImageView.image = NSImage(named: "UserProfilePicture_Size")
  413. emailLabel.textColor = NSColor(named: "0E1114")
  414. emailLabel.font = NSFont.SFMediumFontWithSize(14)
  415. productLabel.textColor = NSColor(named: "42464D_1")
  416. productLabel.font = NSFont.SFProTextRegularFont(12)
  417. endDateLabel.textColor = NSColor(named: "42464D_1")
  418. endDateLabel.font = NSFont.SFProTextRegularFont(12)
  419. spliLineImageView.isHidden = true
  420. endDateLabel.isHidden = true
  421. if KMMemberInfo.shared.vip_levels != "1" &&
  422. KMMemberInfo.shared.vip_paymentModel == "1" &&
  423. (KMMemberInfo.shared.vip_status == 1 || KMMemberInfo.shared.vip_status == 3) {
  424. // 订阅中、试用中,显示到期日期
  425. if KMMemberInfo.shared.vip_endDate.count > 0 {
  426. spliLineImageView.isHidden = false
  427. endDateLabel.isHidden = false
  428. }
  429. } else if KMMemberInfo.shared.vip_status == 2 {
  430. // 订阅到期,显示到期日期
  431. if KMMemberInfo.shared.vip_endDate.count > 0 {
  432. spliLineImageView.isHidden = false
  433. endDateLabel.isHidden = false
  434. }
  435. }
  436. membershipLabel.font = NSFont.SFMediumFontWithSize(16)
  437. lockedLabel.font = NSFont.SFMediumFontWithSize(12)
  438. rightsBox.contentView = rightsView
  439. number1Label.font = NSFont.SFMediumFontWithSize(24)
  440. number1ImageView.image = NSImage(named: "UpgradeImage")
  441. number2Label.font = NSFont.SFProTextRegularFont(12)
  442. number3Label.font = NSFont.SFProTextRegularFont(12)
  443. number5Label.font = NSFont.SFProTextRegularFont(12)
  444. buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  445. buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  446. buyNow1Label.textColor = NSColor(named: "FFFFFF")
  447. buyNow1Label.font = NSFont.SFProTextRegularFont(14)
  448. buyNow2Label.textColor = NSColor(named: "FFFFFF")
  449. buyNow2Label.font = NSFont.SFProTextRegularFont(14)
  450. accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
  451. accountCenterBox.fillColor = .clear
  452. accountLabel.textColor = NSColor(named: "3091FF")
  453. accountLabel.font = NSFont.SFProTextRegularFont(14)
  454. accountImageView.image = NSImage(named: "AccountCenterImage")
  455. signOutLabel.textColor = NSColor(named: "3091FF")
  456. signOutLabel.font = NSFont.SFProTextRegularFont(14)
  457. signOutImageView.image = NSImage(named: "SignOutImage")
  458. closeAccountLabel.textColor = NSColor(named: "3091FF")
  459. closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
  460. closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  461. var isNoOldSubscribed = false
  462. var isTrialPeriod = false
  463. #if VERSION_FREE
  464. #if !VERSION_DMG
  465. isNoOldSubscribed = IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == false && IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == false
  466. if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
  467. isTrialPeriod = true
  468. }
  469. #endif
  470. #endif
  471. if KMMemberInfo.shared.userScenarioType == .lite_type1 { //未试用
  472. buyBox.contentView = buyView1
  473. buyNow1ImageView.isHidden = false
  474. buyNow2ImageView.isHidden = false
  475. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  476. arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
  477. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  478. buyNow2Label.textColor = NSColor(hex: "FFFFFF")
  479. if isTrialPeriod == true {
  480. buyNow2Box.isHidden = true
  481. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  482. }
  483. } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  484. buyBox.contentView = buyView1
  485. buyNow1ImageView.isHidden = false
  486. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  487. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  488. buyNow2Box.isHidden = true
  489. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  490. } else if KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  491. KMMemberInfo.shared.userScenarioType == .pro_type1 {
  492. buyBox.contentView = buyView1
  493. buyNow2Box.isHidden = true
  494. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  495. if((KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1")) { //永久
  496. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  497. buyNow1Label.textColor = NSColor(hex: "42464D")
  498. } else {
  499. buyNow1ImageView.isHidden = false
  500. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  501. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  502. }
  503. } else if KMMemberInfo.shared.userScenarioType == .lite_type11 { //试用过期
  504. if(!isNoOldSubscribed) {
  505. buyBox.contentView = buyView1
  506. buyNow1ImageView.isHidden = false
  507. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  508. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  509. buyNow2Box.isHidden = true
  510. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  511. }
  512. } else if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
  513. KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  514. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  515. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  516. KMMemberInfo.shared.userScenarioType == .lite_type10 ||
  517. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  518. KMMemberInfo.shared.userScenarioType == .lite_type13 ||
  519. KMMemberInfo.shared.userScenarioType == .pro_type2 ||
  520. KMMemberInfo.shared.userScenarioType == .pro_type5 { //有订阅+试用中
  521. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
  522. KMMemberInfo.shared.userScenarioType == .lite_type3 { //试用过期+会员到期
  523. buyBox.contentView = buyView1
  524. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  525. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  526. buyNow2Box.isHidden = true
  527. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  528. } else {
  529. buyBox.contentView = buyView1
  530. buyNow2Box.isHidden = true
  531. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  532. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  533. buyNow1Label.textColor = NSColor(hex: "42464D")
  534. }
  535. if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
  536. KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  537. KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  538. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  539. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  540. KMMemberInfo.shared.userScenarioType == .lite_type10 ||
  541. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  542. KMMemberInfo.shared.userScenarioType == .lite_type13 ||
  543. KMMemberInfo.shared.userScenarioType == .pro_type2 ||
  544. KMMemberInfo.shared.userScenarioType == .pro_type4 ||
  545. KMMemberInfo.shared.userScenarioType == .pro_type5 { //订阅或者买断
  546. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  547. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  548. buyNow1ImageView.isHidden = true
  549. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  550. number2Label.textColor = NSColor(hex: "FFFFFF")
  551. number3Label.textColor = NSColor(hex: "FFFFFF")
  552. number4Label.textColor = NSColor(hex: "FFFFFF")
  553. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  554. number5Label.textColor = NSColor(hex: "FFFFFF")
  555. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  556. } else if(KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  557. KMMemberInfo.shared.userScenarioType == .pro_type1) {
  558. if(KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1") { //永久
  559. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  560. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  561. buyNow1ImageView.isHidden = true
  562. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  563. number2Label.textColor = NSColor(hex: "FFFFFF")
  564. number3Label.textColor = NSColor(hex: "FFFFFF")
  565. number4Label.textColor = NSColor(hex: "FFFFFF")
  566. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  567. number5Label.textColor = NSColor(hex: "FFFFFF")
  568. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  569. } else {
  570. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  571. membershipLabel.textColor = NSColor(hex: "42464D")
  572. buyNow1ImageView.isHidden = false
  573. buyNow1Box.fillColor = NSColor.clear
  574. number2Label.textColor = NSColor(hex:"42464D")
  575. number3Label.textColor = NSColor(hex:"42464D")
  576. number4Label.textColor = NSColor(hex: "42464D")
  577. number4_1Label.textColor = NSColor(hex: "42464D")
  578. number5Label.textColor = NSColor(hex: "42464D")
  579. membershipLabel.textColor = NSColor(hex: "42464D")
  580. }
  581. } else {
  582. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  583. membershipLabel.textColor = NSColor(hex: "42464D")
  584. buyNow1ImageView.isHidden = false
  585. buyNow1Box.fillColor = NSColor.clear
  586. number2Label.textColor = NSColor(hex:"42464D")
  587. number3Label.textColor = NSColor(hex:"42464D")
  588. number4Label.textColor = NSColor(hex: "42464D")
  589. number4_1Label.textColor = NSColor(hex: "42464D")
  590. number5Label.textColor = NSColor(hex: "42464D")
  591. membershipLabel.textColor = NSColor(hex: "42464D")
  592. }
  593. lockedLabel.textColor = NSColor(hex: "42464D")
  594. let platforms = viewModel.getPlatformsImages()
  595. if platforms.count == 4 {
  596. iconBox.contentView = iconView1
  597. icon1ImageView.image = platforms[0]
  598. icon2ImageView.image = platforms[1]
  599. icon3ImageView.image = platforms[2]
  600. icon4ImageView.image = platforms[3]
  601. } else if platforms.count == 3 {
  602. iconBox.contentView = iconView2
  603. icon5ImageView.image = platforms[0]
  604. icon6ImageView.image = platforms[1]
  605. icon7ImageView.image = platforms[2]
  606. } else if platforms.count == 2 {
  607. iconBox.contentView = iconView3
  608. icon8ImageView.image = platforms[0]
  609. icon9ImageView.image = platforms[1]
  610. } else if platforms.count == 1 {
  611. iconBox.contentView = iconView4
  612. icon10ImageView.image = platforms[0]
  613. }
  614. buyNow1Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  615. guard let self = self else { return }
  616. if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
  617. KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  618. KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  619. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  620. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  621. KMMemberInfo.shared.userScenarioType == .lite_type10 ||
  622. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  623. KMMemberInfo.shared.userScenarioType == .lite_type13 ||
  624. KMMemberInfo.shared.userScenarioType == .pro_type2 ||
  625. KMMemberInfo.shared.userScenarioType == .pro_type4 ||
  626. KMMemberInfo.shared.userScenarioType == .pro_type5 { //订阅或者买断
  627. } else {
  628. if mouseEntered {
  629. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  630. } else {
  631. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  632. }
  633. }
  634. }
  635. buyNow1Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  636. guard let self = self else { return }
  637. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  638. // 免费版,免费账号跳转购买比较表
  639. self.viewModel.skipCompare(.lite_Base)
  640. } else {
  641. // 其它情况根据账号状态跳转不同比较表
  642. KMMemberInfo.shared.productCompareShow()
  643. }
  644. }
  645. buyNow2Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  646. guard let self = self else { return }
  647. if mouseEntered {
  648. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  649. } else {
  650. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  651. }
  652. }
  653. buyNow2Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  654. guard let self = self else { return }
  655. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  656. // 免费版,免费账号跳转试用比较表
  657. self.viewModel.skipCompare(.trial)
  658. }
  659. }
  660. accountCenterBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  661. guard let self = self else { return }
  662. if mouseEntered {
  663. self.accountCenterBox.fillColor = NSColor(named: "F5FAFF") ?? .white
  664. self.accountLabel.textColor = NSColor(named: "3091FF")
  665. self.accountImageView.image = NSImage(named: "AccountCenterImage_Hov")
  666. } else {
  667. self.accountCenterBox.fillColor = .clear
  668. self.accountLabel.textColor = NSColor(named: "3091FF")
  669. self.accountImageView.image = NSImage(named: "AccountCenterImage")
  670. }
  671. }
  672. accountCenterBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  673. guard let self = self else { return }
  674. self.viewModel.skipAccountCenter()
  675. }
  676. signOutBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  677. guard let self = self else { return }
  678. if mouseEntered {
  679. self.signOutLabel.textColor = NSColor(named: "3091FF")
  680. self.signOutImageView.image = NSImage(named: "SignOutImage_Hov")
  681. } else {
  682. self.signOutLabel.textColor = NSColor(named: "3091FF")
  683. self.signOutImageView.image = NSImage(named: "SignOutImage")
  684. }
  685. }
  686. signOutBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  687. guard let self = self else { return }
  688. self.viewModel.signOutAction()
  689. }
  690. closeAccountBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  691. guard let self = self else { return }
  692. if mouseEntered {
  693. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  694. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage_hover")
  695. } else {
  696. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  697. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  698. }
  699. }
  700. closeAccountBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  701. guard let self = self else { return }
  702. self.viewModel.closeAccountAction()
  703. }
  704. if isTrialPeriod == false { //没有试用过,才能显示,不然就算远程支持,功能上也不支持远程控制
  705. //远程控制
  706. if let userViewInfoContent = KMAdvertisementManager.manager.info.userViewInfoContent {
  707. buyNow1BoxLeftConst.constant = 0
  708. buyNow2Box.isHidden = false
  709. if userViewInfoContent.content?.isEmpty == false {
  710. buyNow2Box.isHidden = true
  711. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  712. }
  713. }
  714. }
  715. }
  716. // MARK: Action Method
  717. private func languageLocalized_DMG() -> Void {
  718. emailLabel.stringValue = KMMemberInfo.shared.userEmail
  719. productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
  720. endDateLabel.stringValue = String(format: "%@ %@", KMMemberInfo.shared.vip_endDate,NSLocalizedString("expires", tableName: "MemberCenterLocalizable", comment: ""))
  721. membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
  722. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  723. accountLabel.stringValue = NSLocalizedString("Account Center", tableName: "MemberCenterLocalizable", comment: "")
  724. signOutLabel.stringValue = NSLocalizedString("Sign out", tableName: "MemberCenterLocalizable", comment: "")
  725. if KMMemberInfo.shared.validFlag == "5" {
  726. closeAccountLabel.stringValue = NSLocalizedString("Undo Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  727. } else {
  728. closeAccountLabel.stringValue = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  729. }
  730. if KMMemberInfo.shared.vip_maxDeviceNum == 1 {
  731. number4Label.stringValue = NSLocalizedString("device", tableName: "MemberCenterLocalizable", comment: "")
  732. } else {
  733. number4Label.stringValue = NSLocalizedString("devices", tableName: "MemberCenterLocalizable", comment: "")
  734. }
  735. number4_1Label.stringValue = String(KMMemberInfo.shared.vip_maxDeviceNum)
  736. number5Label.stringValue = NSLocalizedString("Devices Access", tableName: "MemberCenterLocalizable", comment: "")
  737. let platforms = viewModel.getPlatformsImages()
  738. if platforms.count == 4 {
  739. number3Label.stringValue = NSLocalizedString("All-platform Available", tableName: "MemberCenterLocalizable", comment: "")
  740. } else {
  741. number3Label.stringValue = NSLocalizedString("Platform", tableName: "MemberCenterLocalizable", comment: "")
  742. }
  743. if KMMemberInfo.shared.userScenarioType == .dmg_type5 ||
  744. KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
  745. KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
  746. KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
  747. KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
  748. KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
  749. KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
  750. KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
  751. KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
  752. lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
  753. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  754. buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  755. } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
  756. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  757. KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
  758. KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
  759. KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
  760. KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
  761. KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
  762. KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
  763. KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
  764. KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
  765. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  766. KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
  767. KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
  768. KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
  769. KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
  770. KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
  771. KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
  772. KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
  773. KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
  774. KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
  775. KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
  776. KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
  777. KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
  778. KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
  779. KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
  780. KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
  781. KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
  782. lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
  783. if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
  784. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  785. KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
  786. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  787. KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
  788. KMMemberInfo.shared.userScenarioType == .dmg_type36 {
  789. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  790. } else {
  791. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  792. }
  793. } else { // 免费 & 到期
  794. if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
  795. KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  796. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  797. KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  798. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  799. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  800. KMMemberInfo.shared.userScenarioType == .dmg_type34 ||
  801. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  802. KMMemberInfo.shared.userScenarioType == .dmg_type48 {
  803. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  804. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  805. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  806. if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  807. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  808. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  809. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  810. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  811. KMMemberInfo.shared.userScenarioType == .dmg_type48 { // 到期
  812. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  813. } else { // 免费
  814. }
  815. if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
  816. KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  817. KMMemberInfo.shared.userScenarioType == .dmg_type34 {
  818. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  819. buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
  820. } else if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  821. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  822. KMMemberInfo.shared.userScenarioType == .dmg_type37 {
  823. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  824. } else if KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  825. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  826. KMMemberInfo.shared.userScenarioType == .dmg_type48 {
  827. buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  828. }
  829. }
  830. }
  831. }
  832. private func initializeUI_DMG() -> Void {
  833. self.view.wantsLayer = true
  834. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  835. if isDarkModel {
  836. self.view.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  837. } else {
  838. self.view.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  839. }
  840. rightsBox.contentView = rightsView
  841. buyBox.contentView = buyView1
  842. userImageView.image = NSImage(named: "UserProfilePicture_Size")
  843. emailLabel.textColor = NSColor(named: "0E1114")
  844. emailLabel.font = NSFont.SFMediumFontWithSize(14)
  845. productLabel.textColor = NSColor(named: "42464D_1")
  846. productLabel.font = NSFont.SFProTextRegularFont(12)
  847. endDateLabel.textColor = NSColor(named: "42464D_1")
  848. endDateLabel.font = NSFont.SFProTextRegularFont(12)
  849. spliLineImageView.isHidden = true
  850. endDateLabel.isHidden = true
  851. number1Label.font = NSFont.SFMediumFontWithSize(24)
  852. number1Label.textColor = NSColor(hex: "0E1114")
  853. number2Label.font = NSFont.SFProTextRegularFont(12)
  854. number3Label.font = NSFont.SFProTextRegularFont(12)
  855. number5Label.font = NSFont.SFProTextRegularFont(12)
  856. membershipLabel.font = NSFont.SFMediumFontWithSize(16)
  857. lockedLabel.font = NSFont.SFMediumFontWithSize(12)
  858. lockedLabel.textColor = NSColor(hex: "42464D")
  859. accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
  860. accountCenterBox.fillColor = .clear
  861. accountLabel.textColor = NSColor(named: "3091FF")
  862. accountLabel.font = NSFont.SFProTextRegularFont(14)
  863. accountImageView.image = NSImage(named: "AccountCenterImage")
  864. signOutLabel.textColor = NSColor(named: "3091FF")
  865. signOutLabel.font = NSFont.SFProTextRegularFont(14)
  866. signOutImageView.image = NSImage(named: "SignOutImage")
  867. closeAccountLabel.textColor = NSColor(named: "3091FF")
  868. closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
  869. closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  870. buyNow1Label.font = NSFont.SFProTextRegularFont(14)
  871. buyNow2Label.font = NSFont.SFProTextRegularFont(14)
  872. let platforms = viewModel.getPlatformsImages()
  873. if platforms.count == 4 {
  874. iconBox.contentView = iconView1
  875. icon1ImageView.image = platforms[0]
  876. icon2ImageView.image = platforms[1]
  877. icon3ImageView.image = platforms[2]
  878. icon4ImageView.image = platforms[3]
  879. } else if platforms.count == 3 {
  880. iconBox.contentView = iconView2
  881. icon5ImageView.image = platforms[0]
  882. icon6ImageView.image = platforms[1]
  883. icon7ImageView.image = platforms[2]
  884. } else if platforms.count == 2 {
  885. iconBox.contentView = iconView3
  886. icon8ImageView.image = platforms[0]
  887. icon9ImageView.image = platforms[1]
  888. } else if platforms.count == 1 {
  889. iconBox.contentView = iconView4
  890. icon10ImageView.image = platforms[0]
  891. }
  892. buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  893. buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  894. if KMMemberInfo.shared.userScenarioType == .dmg_type5 ||
  895. KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
  896. KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
  897. KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
  898. KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
  899. KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
  900. KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
  901. KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
  902. KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
  903. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  904. lockedImageView.image = NSImage(named: "UpgradeImage2")
  905. number1ImageView.isHidden = false
  906. number1ImageView.image = NSImage(named: "UpgradeImage")
  907. number1Label.isHidden = true
  908. number2Label.textColor = NSColor(hex: "FFFFFF")
  909. number3Label.textColor = NSColor(hex: "FFFFFF")
  910. number4Label.textColor = NSColor(hex: "FFFFFF")
  911. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  912. number5Label.textColor = NSColor(hex: "FFFFFF")
  913. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  914. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  915. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  916. buyNow1ImageView.isHidden = true
  917. buyNow2Box.isHidden = true
  918. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  919. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
  920. buyNow1Label.textColor = NSColor(hex: "42464D")
  921. } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
  922. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  923. KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
  924. KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
  925. KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
  926. KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
  927. KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
  928. KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
  929. KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
  930. KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
  931. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  932. KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
  933. KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
  934. KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
  935. KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
  936. KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
  937. KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
  938. KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
  939. KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
  940. KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
  941. KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
  942. KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
  943. KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
  944. KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
  945. KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
  946. KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
  947. KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
  948. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  949. lockedImageView.image = NSImage(named: "UpgradeImage2")
  950. number1ImageView.isHidden = false
  951. number1ImageView.image = NSImage(named: "UpgradeImage")
  952. number1Label.isHidden = true
  953. number2Label.textColor = NSColor(hex: "FFFFFF")
  954. number3Label.textColor = NSColor(hex: "FFFFFF")
  955. number4Label.textColor = NSColor(hex: "FFFFFF")
  956. number4_1Label.textColor = NSColor(hex: "FFFFFF")
  957. number5Label.textColor = NSColor(hex: "FFFFFF")
  958. membershipLabel.textColor = NSColor(hex: "FFFFFF")
  959. if KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
  960. KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
  961. KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
  962. KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
  963. KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
  964. KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
  965. KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
  966. KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
  967. KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
  968. KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
  969. KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
  970. KMMemberInfo.shared.userScenarioType == .dmg_type47 {
  971. if KMMemberInfo.shared.vip_endDate.count > 0 {
  972. spliLineImageView.isHidden = false
  973. endDateLabel.isHidden = false
  974. }
  975. }
  976. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  977. buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
  978. buyNow1ImageView.isHidden = true
  979. buyNow1Box.isHidden = true
  980. buyNow2Box.isHidden = true
  981. } else { // 免费 & 到期
  982. if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
  983. KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  984. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  985. KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
  986. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  987. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  988. KMMemberInfo.shared.userScenarioType == .dmg_type34 ||
  989. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  990. KMMemberInfo.shared.userScenarioType == .dmg_type48 {
  991. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  992. lockedImageView.image = NSImage(named: "LockedImage")
  993. number1ImageView.isHidden = true
  994. number1Label.isHidden = false
  995. number2Label.textColor = NSColor(hex:"42464D")
  996. number3Label.textColor = NSColor(hex:"42464D")
  997. number4Label.textColor = NSColor(hex: "42464D")
  998. number4_1Label.textColor = NSColor(hex: "42464D")
  999. number5Label.textColor = NSColor(hex: "42464D")
  1000. membershipLabel.textColor = NSColor(hex: "42464D")
  1001. rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
  1002. buyNow1Box.fillColor = NSColor.clear
  1003. buyNow2Box.fillColor = NSColor.clear
  1004. buyNow1ImageView.isHidden = false
  1005. buyNow2ImageView.isHidden = false
  1006. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  1007. arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
  1008. buyNow1Label.textColor = NSColor(named: "FFFFFF")
  1009. buyNow1Label.textColor = NSColor(hex: "FFFFFF")
  1010. buyNow2Label.textColor = NSColor(hex: "FFFFFF")
  1011. if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
  1012. KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
  1013. KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
  1014. KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
  1015. KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
  1016. KMMemberInfo.shared.userScenarioType == .dmg_type48 { // 到期
  1017. if KMMemberInfo.shared.vip_endDate.count > 0 &&
  1018. KMMemberInfo.shared.vip_status == 2 {
  1019. spliLineImageView.isHidden = false
  1020. endDateLabel.isHidden = false
  1021. endDateLabel.textColor = NSColor(named: "FA1E5D")
  1022. }
  1023. spliLineImageView.isHidden = false
  1024. endDateLabel.isHidden = false
  1025. buyNow2Box.isHidden = true
  1026. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  1027. } else { // 免费
  1028. }
  1029. }
  1030. }
  1031. buyNow1Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1032. guard let self = self else { return }
  1033. if mouseEntered {
  1034. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  1035. } else {
  1036. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  1037. }
  1038. }
  1039. buyNow1Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1040. guard let self = self else { return }
  1041. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  1042. // 免费版,免费账号跳转购买比较表
  1043. self.viewModel.skipCompare(.lite_Base)
  1044. } else {
  1045. // 其它情况根据账号状态跳转不同比较表
  1046. KMMemberInfo.shared.productCompareShow()
  1047. }
  1048. }
  1049. buyNow2Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1050. guard let self = self else { return }
  1051. if mouseEntered {
  1052. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  1053. } else {
  1054. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  1055. }
  1056. }
  1057. buyNow2Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1058. guard let self = self else { return }
  1059. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  1060. self.viewModel.skipCompare(.trial)
  1061. }
  1062. }
  1063. accountCenterBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1064. guard let self = self else { return }
  1065. if mouseEntered {
  1066. self.accountCenterBox.fillColor = NSColor(named: "F5FAFF") ?? .white
  1067. self.accountLabel.textColor = NSColor(named: "3091FF")
  1068. self.accountImageView.image = NSImage(named: "AccountCenterImage_Hov")
  1069. } else {
  1070. self.accountCenterBox.fillColor = .clear
  1071. self.accountLabel.textColor = NSColor(named: "3091FF")
  1072. self.accountImageView.image = NSImage(named: "AccountCenterImage")
  1073. }
  1074. }
  1075. accountCenterBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1076. guard let self = self else { return }
  1077. self.viewModel.skipAccountCenter()
  1078. }
  1079. signOutBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1080. guard let self = self else { return }
  1081. if mouseEntered {
  1082. self.signOutLabel.textColor = NSColor(named: "3091FF")
  1083. self.signOutImageView.image = NSImage(named: "SignOutImage_Hov")
  1084. } else {
  1085. self.signOutLabel.textColor = NSColor(named: "3091FF")
  1086. self.signOutImageView.image = NSImage(named: "SignOutImage")
  1087. }
  1088. }
  1089. signOutBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1090. guard let self = self else { return }
  1091. self.viewModel.signOutAction()
  1092. }
  1093. closeAccountBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  1094. guard let self = self else { return }
  1095. if mouseEntered {
  1096. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  1097. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage_hover")
  1098. } else {
  1099. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  1100. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  1101. }
  1102. }
  1103. closeAccountBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  1104. guard let self = self else { return }
  1105. self.viewModel.closeAccountAction()
  1106. }
  1107. //远程控制
  1108. if let userViewInfoContent = KMAdvertisementManager.manager.info.userViewInfoContent {
  1109. buyNow1BoxLeftConst.constant = 0
  1110. buyNow2Box.isHidden = false
  1111. if userViewInfoContent.content?.isEmpty == false {
  1112. buyNow2Box.isHidden = true
  1113. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  1114. }
  1115. }
  1116. }
  1117. }