KMUserInfoViewController.swift 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  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 var buyView2: NSView!
  77. @IBOutlet weak var buyNow3Box: KMBox!
  78. @IBOutlet weak var buyNow3ImageView: NSImageView!
  79. @IBOutlet weak var buyNow3Label: NSTextField!
  80. @IBOutlet weak var arrow3ImageView: NSImageView!
  81. @IBOutlet weak var accountCenterBox: KMBox!
  82. @IBOutlet weak var accountImageView: NSImageView!
  83. @IBOutlet weak var accountLabel: NSTextField!
  84. @IBOutlet weak var signOutBox: KMBox!
  85. @IBOutlet weak var signOutImageView: NSImageView!
  86. @IBOutlet weak var signOutLabel: NSTextField!
  87. @IBOutlet weak var closeAccountBox: KMBox!
  88. @IBOutlet weak var closeAccountImageView: NSImageView!
  89. @IBOutlet weak var closeAccountLabel: NSTextField!
  90. private var viewModel = KMUserInfoVCModel()
  91. private var cancellables = Set<AnyCancellable>()
  92. override func viewDidLoad() {
  93. super.viewDidLoad()
  94. // Do view setup here.
  95. self.view.wantsLayer = true
  96. self.view.layer?.backgroundColor = .white
  97. bindViewModel()
  98. languageLocalized()
  99. initializeUI()
  100. NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
  101. }
  102. @objc func changeEffectiveAppearance() {
  103. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  104. if isDarkModel {
  105. self.view.appearance = NSAppearance(named: .darkAqua)
  106. } else {
  107. self.view.appearance = NSAppearance(named: .aqua)
  108. }
  109. initializeUI()
  110. }
  111. // MARK: Private Method
  112. private func languageLocalized() -> Void {
  113. emailLabel.stringValue = KMMemberInfo.shared.userEmail
  114. productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
  115. endDateLabel.stringValue = KMMemberInfo.shared.vip_endDate
  116. membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
  117. buyNow3Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  118. accountLabel.stringValue = NSLocalizedString("Account Center", tableName: "MemberCenterLocalizable", comment: "")
  119. signOutLabel.stringValue = NSLocalizedString("Sign out", tableName: "MemberCenterLocalizable", comment: "")
  120. if KMMemberInfo.shared.validFlag == "5" {
  121. closeAccountLabel.stringValue = NSLocalizedString("Undo Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  122. } else {
  123. closeAccountLabel.stringValue = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  124. }
  125. if KMMemberInfo.shared.vip_maxDeviceNum == 1 {
  126. number4Label.stringValue = NSLocalizedString("device", tableName: "MemberCenterLocalizable", comment: "")
  127. } else {
  128. number4Label.stringValue = NSLocalizedString("devices", tableName: "MemberCenterLocalizable", comment: "")
  129. }
  130. number4_1Label.stringValue = String(KMMemberInfo.shared.vip_maxDeviceNum)
  131. number5Label.stringValue = NSLocalizedString("Devices Access", tableName: "MemberCenterLocalizable", comment: "")
  132. let platforms = viewModel.getPlatformsImages()
  133. if platforms.count == 4 {
  134. number3Label.stringValue = NSLocalizedString("All-platform Available", tableName: "MemberCenterLocalizable", comment: "")
  135. } else {
  136. number3Label.stringValue = NSLocalizedString("Platform", tableName: "MemberCenterLocalizable", comment: "")
  137. }
  138. if KMMemberInfo.shared.userScenarioType == .lite_type1 || KMMemberInfo.shared.userScenarioType == .lite_type9 {
  139. buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  140. buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
  141. } else if KMMemberInfo.shared.userScenarioType == .lite_type3 || KMMemberInfo.shared.userScenarioType == .lite_type11 {
  142. buyNow3Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
  143. } else if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  144. KMMemberInfo.shared.userScenarioType == .pro_type1 ||
  145. KMMemberInfo.shared.userScenarioType == .pro_type3 ||
  146. KMMemberInfo.shared.userScenarioType == .pro_type4 {
  147. buyNow3Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
  148. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
  149. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  150. KMMemberInfo.shared.userScenarioType == .lite_type13 {
  151. buyNow3Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
  152. }
  153. }
  154. private func refreshEquity() -> Void {
  155. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  156. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  157. lockedImageView.image = NSImage(named: "LockedImage")
  158. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  159. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  160. number1ImageView.isHidden = true
  161. number1Label.isHidden = false
  162. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  163. number1Label.textColor = NSColor(hex: "0E1114")
  164. number2Label.textColor = NSColor(hex:"42464D")
  165. number3Label.textColor = NSColor(hex:"42464D")
  166. number4Label.textColor = NSColor(hex: "42464D")
  167. number4_1Label.textColor = NSColor(hex: "42464D")
  168. number5Label.textColor = NSColor(hex: "42464D")
  169. } else if KMMemberInfo.shared.userScenarioType == .lite_type2 {
  170. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  171. lockedImageView.image = NSImage(named: "UpgradeImage2")
  172. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  173. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  174. number1ImageView.isHidden = false
  175. number1Label.isHidden = true
  176. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  177. number2Label.textColor = NSColor(named: "FFFFFF")
  178. number3Label.textColor = NSColor(named: "FFFFFF")
  179. number4Label.textColor = NSColor(named: "FFFFFF")
  180. number4_1Label.textColor = NSColor(named: "FFFFFF")
  181. number5Label.textColor = NSColor(named: "FFFFFF")
  182. } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
  183. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  184. lockedImageView.image = NSImage(named: "LockedImage")
  185. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  186. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  187. number1ImageView.isHidden = true
  188. number1Label.isHidden = false
  189. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  190. number1Label.textColor = NSColor(hex: "0E1114")
  191. number2Label.textColor = NSColor(hex:"42464D")
  192. number3Label.textColor = NSColor(hex:"42464D")
  193. number4Label.textColor = NSColor(hex: "42464D")
  194. number4_1Label.textColor = NSColor(hex: "42464D")
  195. number5Label.textColor = NSColor(hex: "42464D")
  196. } else if KMMemberInfo.shared.userScenarioType == .lite_type4 {
  197. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  198. lockedImageView.image = NSImage(named: "UpgradeImage2")
  199. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  200. if KMMemberInfo.shared.vip_levels == "2" {
  201. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  202. } else {
  203. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  204. }
  205. number1ImageView.isHidden = false
  206. number1Label.isHidden = true
  207. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  208. number2Label.textColor = NSColor(named: "FFFFFF")
  209. number3Label.textColor = NSColor(named: "FFFFFF")
  210. number4Label.textColor = NSColor(named: "FFFFFF")
  211. number4_1Label.textColor = NSColor(named: "FFFFFF")
  212. number5Label.textColor = NSColor(named: "FFFFFF")
  213. } else if KMMemberInfo.shared.userScenarioType == .lite_type5 {
  214. lockedLabel.stringValue = NSLocalizedString("Permanent Plan", tableName: "MemberCenterLocalizable", comment: "")
  215. lockedImageView.image = NSImage(named: "UpgradeImage2")
  216. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  217. if KMMemberInfo.shared.vip_levels == "2" {
  218. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  219. } else {
  220. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  221. }
  222. number1ImageView.isHidden = false
  223. number1Label.isHidden = true
  224. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  225. number2Label.textColor = NSColor(named: "FFFFFF")
  226. number3Label.textColor = NSColor(named: "FFFFFF")
  227. number4Label.textColor = NSColor(named: "FFFFFF")
  228. number4_1Label.textColor = NSColor(named: "FFFFFF")
  229. number5Label.textColor = NSColor(named: "FFFFFF")
  230. } else if KMMemberInfo.shared.userScenarioType == .lite_type6 {
  231. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  232. lockedImageView.image = NSImage(named: "UpgradeImage2")
  233. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  234. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  235. number1ImageView.isHidden = false
  236. number1Label.isHidden = true
  237. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  238. number2Label.textColor = NSColor(named: "FFFFFF")
  239. number3Label.textColor = NSColor(named: "FFFFFF")
  240. number4Label.textColor = NSColor(named: "FFFFFF")
  241. number4_1Label.textColor = NSColor(named: "FFFFFF")
  242. number5Label.textColor = NSColor(named: "FFFFFF")
  243. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 {
  244. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  245. lockedImageView.image = NSImage(named: "LockedImage")
  246. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  247. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  248. number1ImageView.isHidden = true
  249. number1Label.isHidden = false
  250. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  251. number1Label.textColor = NSColor(hex: "0E1114")
  252. number2Label.textColor = NSColor(hex:"42464D")
  253. number3Label.textColor = NSColor(hex:"42464D")
  254. number4Label.textColor = NSColor(hex: "42464D")
  255. number4_1Label.textColor = NSColor(hex: "42464D")
  256. number5Label.textColor = NSColor(hex: "42464D")
  257. } else if KMMemberInfo.shared.userScenarioType == .lite_type8 {
  258. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  259. lockedImageView.image = NSImage(named: "UpgradeImage2")
  260. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  261. if KMMemberInfo.shared.vip_levels == "2" {
  262. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  263. } else {
  264. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  265. }
  266. number1ImageView.isHidden = false
  267. number1Label.isHidden = true
  268. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  269. number2Label.textColor = NSColor(named: "FFFFFF")
  270. number3Label.textColor = NSColor(named: "FFFFFF")
  271. number4Label.textColor = NSColor(named: "FFFFFF")
  272. number4_1Label.textColor = NSColor(named: "FFFFFF")
  273. number5Label.textColor = NSColor(named: "FFFFFF")
  274. } else if KMMemberInfo.shared.userScenarioType == .lite_type9 {
  275. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  276. lockedImageView.image = NSImage(named: "LockedImage")
  277. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  278. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  279. number1ImageView.isHidden = true
  280. number1Label.isHidden = false
  281. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  282. number1Label.textColor = NSColor(hex: "0E1114")
  283. number2Label.textColor = NSColor(hex:"42464D")
  284. number3Label.textColor = NSColor(hex:"42464D")
  285. number4Label.textColor = NSColor(hex: "42464D")
  286. number4_1Label.textColor = NSColor(hex: "42464D")
  287. number5Label.textColor = NSColor(hex: "42464D")
  288. } else if KMMemberInfo.shared.userScenarioType == .lite_type10 {
  289. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  290. lockedImageView.image = NSImage(named: "UpgradeImage2")
  291. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  292. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  293. number1ImageView.isHidden = false
  294. number1Label.isHidden = true
  295. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  296. number2Label.textColor = NSColor(named: "FFFFFF")
  297. number3Label.textColor = NSColor(named: "FFFFFF")
  298. number4Label.textColor = NSColor(named: "FFFFFF")
  299. number4_1Label.textColor = NSColor(named: "FFFFFF")
  300. number5Label.textColor = NSColor(named: "FFFFFF")
  301. } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
  302. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  303. lockedImageView.image = NSImage(named: "LockedImage")
  304. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  305. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  306. number1ImageView.isHidden = true
  307. number1Label.isHidden = false
  308. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  309. number1Label.textColor = NSColor(hex: "0E1114")
  310. number2Label.textColor = NSColor(hex:"42464D")
  311. number3Label.textColor = NSColor(hex:"42464D")
  312. number4Label.textColor = NSColor(hex: "42464D")
  313. number4_1Label.textColor = NSColor(hex: "42464D")
  314. number5Label.textColor = NSColor(hex: "42464D")
  315. } else if KMMemberInfo.shared.userScenarioType == .lite_type12 {
  316. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  317. lockedImageView.image = NSImage(named: "UpgradeImage2")
  318. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  319. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  320. number1ImageView.isHidden = false
  321. number1Label.isHidden = true
  322. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  323. number2Label.textColor = NSColor(named: "FFFFFF")
  324. number3Label.textColor = NSColor(named: "FFFFFF")
  325. number4Label.textColor = NSColor(named: "FFFFFF")
  326. number4_1Label.textColor = NSColor(named: "FFFFFF")
  327. number5Label.textColor = NSColor(named: "FFFFFF")
  328. } else if KMMemberInfo.shared.userScenarioType == .lite_type13 {
  329. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  330. lockedImageView.image = NSImage(named: "UpgradeImage2")
  331. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  332. if KMMemberInfo.shared.vip_levels == "2" {
  333. number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
  334. } else {
  335. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  336. }
  337. number1ImageView.isHidden = false
  338. number1Label.isHidden = true
  339. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  340. number2Label.textColor = NSColor(named: "FFFFFF")
  341. number3Label.textColor = NSColor(named: "FFFFFF")
  342. number4Label.textColor = NSColor(named: "FFFFFF")
  343. number4_1Label.textColor = NSColor(named: "FFFFFF")
  344. number5Label.textColor = NSColor(named: "FFFFFF")
  345. } else if KMMemberInfo.shared.userScenarioType == .pro_type1 {
  346. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  347. lockedImageView.image = NSImage(named: "LockedImage")
  348. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  349. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  350. number1ImageView.isHidden = true
  351. number1Label.isHidden = false
  352. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  353. number1Label.textColor = NSColor(hex: "0E1114")
  354. number2Label.textColor = NSColor(hex:"42464D")
  355. number3Label.textColor = NSColor(hex:"42464D")
  356. number4Label.textColor = NSColor(hex: "42464D")
  357. number4_1Label.textColor = NSColor(hex: "42464D")
  358. number5Label.textColor = NSColor(hex: "42464D")
  359. } else if KMMemberInfo.shared.userScenarioType == .pro_type2 {
  360. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  361. lockedImageView.image = NSImage(named: "UpgradeImage2")
  362. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  363. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  364. number1ImageView.isHidden = false
  365. number1Label.isHidden = true
  366. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  367. number2Label.textColor = NSColor(named: "FFFFFF")
  368. number3Label.textColor = NSColor(named: "FFFFFF")
  369. number4Label.textColor = NSColor(named: "FFFFFF")
  370. number4_1Label.textColor = NSColor(named: "FFFFFF")
  371. number5Label.textColor = NSColor(named: "FFFFFF")
  372. } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  373. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  374. lockedImageView.image = NSImage(named: "LockedImage")
  375. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  376. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  377. number1ImageView.isHidden = true
  378. number1Label.isHidden = false
  379. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  380. number1Label.textColor = NSColor(hex: "0E1114")
  381. number2Label.textColor = NSColor(hex:"42464D")
  382. number3Label.textColor = NSColor(hex:"42464D")
  383. number4Label.textColor = NSColor(hex: "42464D")
  384. number4_1Label.textColor = NSColor(hex: "42464D")
  385. number5Label.textColor = NSColor(hex: "42464D")
  386. } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
  387. lockedLabel.stringValue = NSLocalizedString("Permanent Plan", tableName: "MemberCenterLocalizable", comment: "")
  388. lockedImageView.image = NSImage(named: "UpgradeImage2")
  389. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  390. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  391. number1ImageView.isHidden = false
  392. number1Label.isHidden = true
  393. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
  394. number2Label.textColor = NSColor(named: "FFFFFF")
  395. number3Label.textColor = NSColor(named: "FFFFFF")
  396. number4Label.textColor = NSColor(named: "FFFFFF")
  397. number4_1Label.textColor = NSColor(named: "FFFFFF")
  398. number5Label.textColor = NSColor(named: "FFFFFF")
  399. } else if KMMemberInfo.shared.userScenarioType == .pro_type5 {
  400. lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
  401. lockedImageView.image = NSImage(named: "UpgradeImage2")
  402. number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
  403. number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
  404. number1ImageView.isHidden = false
  405. number1Label.isHidden = true
  406. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
  407. number2Label.textColor = NSColor(named: "FFFFFF")
  408. number3Label.textColor = NSColor(named: "FFFFFF")
  409. number4Label.textColor = NSColor(named: "FFFFFF")
  410. number4_1Label.textColor = NSColor(named: "FFFFFF")
  411. number5Label.textColor = NSColor(named: "FFFFFF")
  412. } else {
  413. lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
  414. lockedImageView.image = NSImage(named: "LockedImage")
  415. number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
  416. number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
  417. number1ImageView.isHidden = true
  418. number1Label.isHidden = false
  419. centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
  420. number1Label.textColor = NSColor(hex: "0E1114")
  421. number2Label.textColor = NSColor(hex:"42464D")
  422. number3Label.textColor = NSColor(hex:"42464D")
  423. number4Label.textColor = NSColor(hex: "42464D")
  424. number4_1Label.textColor = NSColor(hex: "42464D")
  425. number5Label.textColor = NSColor(hex: "42464D")
  426. }
  427. }
  428. private func initializeUI() -> Void {
  429. refreshEquity()
  430. self.view.wantsLayer = true
  431. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  432. if isDarkModel {
  433. self.view.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  434. } else {
  435. self.view.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  436. }
  437. userImageView.image = NSImage(named: "UserProfilePicture_Size")
  438. emailLabel.textColor = NSColor(named: "0E1114")
  439. emailLabel.font = NSFont.SFMediumFontWithSize(14)
  440. productLabel.textColor = NSColor(named: "42464D_1")
  441. productLabel.font = NSFont.SFProTextRegularFont(12)
  442. endDateLabel.textColor = NSColor(named: "42464D_1")
  443. endDateLabel.font = NSFont.SFProTextRegularFont(12)
  444. spliLineImageView.isHidden = true
  445. endDateLabel.isHidden = true
  446. if KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  447. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  448. KMMemberInfo.shared.userScenarioType == .lite_type7 ||
  449. KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  450. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  451. KMMemberInfo.shared.userScenarioType == .lite_type13 ||
  452. KMMemberInfo.shared.userScenarioType == .pro_type3 {
  453. if KMMemberInfo.shared.vip_endDate.count > 0 {
  454. spliLineImageView.isHidden = false
  455. endDateLabel.isHidden = false
  456. }
  457. }
  458. membershipLabel.font = NSFont.SFMediumFontWithSize(16)
  459. lockedLabel.font = NSFont.SFMediumFontWithSize(12)
  460. rightsBox.contentView = rightsView
  461. number1Label.font = NSFont.SFMediumFontWithSize(24)
  462. number1ImageView.image = NSImage(named: "UpgradeImage")
  463. number2Label.font = NSFont.SFProTextRegularFont(12)
  464. number3Label.font = NSFont.SFProTextRegularFont(12)
  465. number5Label.font = NSFont.SFProTextRegularFont(12)
  466. buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  467. buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  468. buyNow3ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  469. buyNow3ImageView.wantsLayer = true
  470. buyNow3ImageView.layer?.cornerRadius = 4.0
  471. buyNow1Label.textColor = NSColor(named: "FFFFFF")
  472. buyNow1Label.font = NSFont.SFProTextRegularFont(14)
  473. buyNow2Label.textColor = NSColor(named: "FFFFFF")
  474. buyNow2Label.font = NSFont.SFProTextRegularFont(14)
  475. buyNow3Label.textColor = NSColor(named: "000000")
  476. buyNow3Label.font = NSFont.SFProTextRegularFont(14)
  477. accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
  478. accountCenterBox.fillColor = .clear
  479. accountLabel.textColor = NSColor(named: "065CBC")
  480. accountLabel.font = NSFont.SFProTextRegularFont(14)
  481. accountImageView.image = NSImage(named: "AccountCenterImage")
  482. signOutLabel.textColor = NSColor(named: "065CBC")
  483. signOutLabel.font = NSFont.SFProTextRegularFont(14)
  484. signOutImageView.image = NSImage(named: "SignOutImage")
  485. closeAccountLabel.textColor = NSColor(named: "065CBC")
  486. closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
  487. closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  488. buyNow3Box.fillColor = NSColor(named: "FFFFFF") ?? .white
  489. if KMMemberInfo.shared.userScenarioType == .lite_type1 ||
  490. KMMemberInfo.shared.userScenarioType == .lite_type2 ||
  491. KMMemberInfo.shared.userScenarioType == .lite_type3 ||
  492. KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  493. KMMemberInfo.shared.userScenarioType == .lite_type10 ||
  494. KMMemberInfo.shared.userScenarioType == .lite_type11 {
  495. rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
  496. membershipLabel.textColor = NSColor(hex: "0E1114")
  497. lockedLabel.textColor = NSColor(hex: "42464D")
  498. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  499. buyBox.contentView = buyView1
  500. buyNow1ImageView.isHidden = false
  501. buyNow2ImageView.isHidden = false
  502. arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
  503. arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
  504. } else if KMMemberInfo.shared.userScenarioType == .lite_type3 ||
  505. KMMemberInfo.shared.userScenarioType == .lite_type11 ||
  506. KMMemberInfo.shared.userScenarioType == .lite_type9 {
  507. buyNow3Label.textColor = NSColor(named: "FFFFFF")
  508. buyBox.contentView = buyView2
  509. buyNow3ImageView.isHidden = false
  510. arrow3ImageView.image = NSImage(named: "BuyNewArrowImage1")
  511. }
  512. } else if KMMemberInfo.shared.userScenarioType == .lite_type4 ||
  513. KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  514. KMMemberInfo.shared.userScenarioType == .lite_type6 ||
  515. KMMemberInfo.shared.userScenarioType == .lite_type12 ||
  516. KMMemberInfo.shared.userScenarioType == .pro_type1 ||
  517. KMMemberInfo.shared.userScenarioType == .pro_type2 ||
  518. KMMemberInfo.shared.userScenarioType == .pro_type3 ||
  519. KMMemberInfo.shared.userScenarioType == .pro_type4 ||
  520. KMMemberInfo.shared.userScenarioType == .pro_type5 {
  521. membershipLabel.textColor = NSColor(named: "FFFFFF")
  522. lockedLabel.textColor = NSColor(hex: "FCFDFF")
  523. number5Label.textColor = NSColor(named: "FFFFFF")
  524. rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
  525. if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  526. KMMemberInfo.shared.userScenarioType == .pro_type1 ||
  527. KMMemberInfo.shared.userScenarioType == .pro_type3 ||
  528. KMMemberInfo.shared.userScenarioType == .pro_type4 {
  529. buyBox.contentView = buyView2
  530. buyNow3ImageView.isHidden = true
  531. arrow3ImageView.image = NSImage(named: "BuyNewArrowImage2")
  532. }
  533. } else if KMMemberInfo.shared.userScenarioType == .lite_type7 {
  534. membershipLabel.textColor = NSColor(hex: "0E1114")
  535. lockedLabel.textColor = NSColor(hex: "42464D")
  536. rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
  537. buyBox.contentView = buyView2
  538. buyNow3ImageView.isHidden = false
  539. buyNow3Label.textColor = NSColor(named: "FFFFFF")
  540. arrow3ImageView.image = NSImage(named: "BuyNewArrowImage1")
  541. } else if KMMemberInfo.shared.userScenarioType == .lite_type8 ||
  542. KMMemberInfo.shared.userScenarioType == .lite_type13 {
  543. membershipLabel.textColor = NSColor(hex: "FCFDFF")
  544. lockedLabel.textColor = NSColor(hex: "FCFDFF")
  545. rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
  546. }
  547. let platforms = viewModel.getPlatformsImages()
  548. if platforms.count == 4 {
  549. iconBox.contentView = iconView1
  550. icon1ImageView.image = platforms[0]
  551. icon2ImageView.image = platforms[1]
  552. icon3ImageView.image = platforms[2]
  553. icon4ImageView.image = platforms[3]
  554. } else if platforms.count == 3 {
  555. iconBox.contentView = iconView2
  556. icon5ImageView.image = platforms[0]
  557. icon6ImageView.image = platforms[1]
  558. icon7ImageView.image = platforms[2]
  559. } else if platforms.count == 2 {
  560. iconBox.contentView = iconView3
  561. icon8ImageView.image = platforms[0]
  562. icon9ImageView.image = platforms[1]
  563. } else if platforms.count == 1 {
  564. iconBox.contentView = iconView4
  565. icon10ImageView.image = platforms[0]
  566. }
  567. buyNow1Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  568. guard let self = self else { return }
  569. if mouseEntered {
  570. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  571. } else {
  572. self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  573. }
  574. }
  575. buyNow1Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  576. guard let self = self else { return }
  577. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  578. self.viewModel.skipCompare(.lite_Base)
  579. }
  580. }
  581. buyNow2Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  582. guard let self = self else { return }
  583. if mouseEntered {
  584. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  585. } else {
  586. self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  587. }
  588. }
  589. buyNow2Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  590. guard let self = self else { return }
  591. if KMMemberInfo.shared.userScenarioType == .lite_type1 {
  592. self.viewModel.skipCompare(.trial)
  593. }
  594. }
  595. buyNow3Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  596. guard let self = self else { return }
  597. if KMMemberInfo.shared.userScenarioType == .lite_type3 ||
  598. KMMemberInfo.shared.userScenarioType == .lite_type11 {
  599. if mouseEntered {
  600. self.buyNow3ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
  601. } else {
  602. self.buyNow3ImageView.image = NSImage(named: "ButtonBackgroundImage2")
  603. }
  604. }
  605. }
  606. buyNow3Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  607. guard let self = self else { return }
  608. if KMMemberInfo.shared.userScenarioType == .lite_type3 ||
  609. KMMemberInfo.shared.userScenarioType == .lite_type7 ||
  610. KMMemberInfo.shared.userScenarioType == .lite_type8 {
  611. self.viewModel.skipCompare(.lite_Base)
  612. } else if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
  613. KMMemberInfo.shared.userScenarioType == .lite_type9 ||
  614. KMMemberInfo.shared.userScenarioType == .lite_type11 ||
  615. KMMemberInfo.shared.userScenarioType == .lite_type13 {
  616. self.viewModel.skipCompare(.lite_MacWindows)
  617. } else if KMMemberInfo.shared.userScenarioType == .pro_type1 ||
  618. KMMemberInfo.shared.userScenarioType == .pro_type4 {
  619. self.viewModel.skipCompare(.pro_Advanced)
  620. } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  621. self.viewModel.skipCompare(.pro_Base)
  622. }
  623. }
  624. accountCenterBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  625. guard let self = self else { return }
  626. if mouseEntered {
  627. self.accountCenterBox.fillColor = NSColor(named: "F5FAFF") ?? .white
  628. self.accountLabel.textColor = NSColor(named: "3091FF")
  629. self.accountImageView.image = NSImage(named: "AccountCenterImage_Hov")
  630. } else {
  631. self.accountCenterBox.fillColor = .clear
  632. self.accountLabel.textColor = NSColor(named: "065CBC")
  633. self.accountImageView.image = NSImage(named: "AccountCenterImage")
  634. }
  635. }
  636. accountCenterBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  637. guard let self = self else { return }
  638. self.viewModel.skipAccountCenter()
  639. }
  640. signOutBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  641. guard let self = self else { return }
  642. if mouseEntered {
  643. self.signOutLabel.textColor = NSColor(named: "3091FF")
  644. self.signOutImageView.image = NSImage(named: "SignOutImage_Hov")
  645. } else {
  646. self.signOutLabel.textColor = NSColor(named: "065CBC")
  647. self.signOutImageView.image = NSImage(named: "SignOutImage")
  648. }
  649. }
  650. signOutBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  651. guard let self = self else { return }
  652. self.viewModel.signOutAction()
  653. }
  654. closeAccountBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
  655. guard let self = self else { return }
  656. if mouseEntered {
  657. self.closeAccountLabel.textColor = NSColor(named: "3091FF")
  658. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage_hover")
  659. } else {
  660. self.closeAccountLabel.textColor = NSColor(named: "065CBC")
  661. self.closeAccountImageView.image = NSImage(named: "CloseAccountImage")
  662. }
  663. }
  664. closeAccountBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
  665. guard let self = self else { return }
  666. self.viewModel.closeAccountAction()
  667. }
  668. buyNow1BoxLeftConst.constant = 0
  669. buyNow2Box.isHidden = false
  670. //远程控制
  671. if let userViewInfoContent = KMAdvertisementManager.manager.info.userViewInfoContent {
  672. if userViewInfoContent.content?.isEmpty == false {
  673. buyNow2Box.isHidden = true
  674. buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
  675. }
  676. }
  677. }
  678. // MARK: Bind Method
  679. func bindViewModel() -> Void {
  680. }
  681. // MARK: Action Method
  682. }