123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783 |
- //
- // KMUserInfoViewController.swift
- // PDF Reader Pro
- //
- // Created by wanjun on 2024/10/30.
- //
- import Cocoa
- import Combine
- class KMGradationBox: NSBox {
- override func draw(_ dirtyRect: NSRect){
- super.draw(dirtyRect)
-
- guard let context = NSGraphicsContext.current?.cgContext else { return }
-
- // 定义渐变颜色
- let colors = [NSColor(hex: "EBDABD").cgColor, NSColor(hex: "E5CCA8").cgColor]
- let gradient = CGGradient(colorsSpace: nil, colors: colors as CFArray, locations: nil)
-
- // 定义渐变起始和结束点
- let startPoint = CGPoint(x: bounds.minX, y: bounds.minY)
- let endPoint = CGPoint(x: bounds.maxX, y: bounds.maxY)
-
- // 绘制圆角矩形路径
- let roundedPath = NSBezierPath(roundedRect: bounds, xRadius: 4, yRadius: 4) // 你的圆角半径
- roundedPath.addClip() // 添加路径为剪切区域
-
- context.clip() // 使路径生效
-
- // 绘制渐变
- context.drawLinearGradient(gradient!, start: startPoint, end: endPoint, options: [])
-
- context.restoreGState()
- }
- }
- @objcMembers
- class KMUserInfoViewController: NSViewController {
-
- @IBOutlet weak var userImageView: NSImageView!
- @IBOutlet weak var emailLabel: NSTextField!
- @IBOutlet weak var productLabel: NSTextField!
- @IBOutlet weak var spliLineImageView: NSImageView!
- @IBOutlet weak var endDateLabel: NSTextField!
- @IBOutlet weak var membershipLabel: NSTextField!
- @IBOutlet weak var lockedImageView: NSImageView!
- @IBOutlet weak var lockedLabel: NSTextField!
- @IBOutlet var lockedLabelWidthffset:NSLayoutConstraint!
- @IBOutlet var lockedBox:KMGradationBox!
- @IBOutlet weak var centerBackgroud: NSImageView!
- @IBOutlet weak var rightsBox: NSBox!
- @IBOutlet var rightsView: NSView!
- @IBOutlet weak var number1Label: NSTextField!
- @IBOutlet weak var number1ImageView: NSImageView!
- @IBOutlet weak var number2Label: NSTextField!
- @IBOutlet weak var iconBox: NSBox!
- @IBOutlet var iconView1: NSView!
- @IBOutlet weak var icon1ImageView: NSImageView!
- @IBOutlet weak var icon2ImageView: NSImageView!
- @IBOutlet weak var icon3ImageView: NSImageView!
- @IBOutlet weak var icon4ImageView: NSImageView!
- @IBOutlet var iconView2: NSView!
- @IBOutlet weak var icon5ImageView: NSImageView!
- @IBOutlet weak var icon6ImageView: NSImageView!
- @IBOutlet weak var icon7ImageView: NSImageView!
- @IBOutlet var iconView3: NSView!
- @IBOutlet weak var icon8ImageView: NSImageView!
- @IBOutlet weak var icon9ImageView: NSImageView!
- @IBOutlet var iconView4: NSView!
- @IBOutlet weak var icon10ImageView: NSImageView!
- @IBOutlet weak var number3Label: NSTextField!
- @IBOutlet weak var number4Label: NSTextField!
- @IBOutlet weak var number4_1Label: NSTextField!
- @IBOutlet weak var number5Label: NSTextField!
-
- @IBOutlet weak var buyBox: NSBox!
- @IBOutlet var buyView1: NSView!
- @IBOutlet weak var buyNow1Box: KMBox!
- @IBOutlet weak var buyNow1ImageView: NSImageView!
- @IBOutlet weak var buyNow1Label: NSTextField!
- @IBOutlet weak var arrow1ImageView: NSImageView!
- @IBOutlet weak var buyNow2Box: KMBox!
- @IBOutlet weak var buyNow2ImageView: NSImageView!
- @IBOutlet weak var buyNow2Label: NSTextField!
- @IBOutlet weak var arrow2ImageView: NSImageView!
- @IBOutlet var buyNow1BoxLeftConst: NSLayoutConstraint!
-
-
- @IBOutlet var buyView2: NSView!
- @IBOutlet weak var buyNow3Box: KMBox!
- @IBOutlet weak var buyNow3ImageView: NSImageView!
- @IBOutlet weak var buyNow3Label: NSTextField!
- @IBOutlet weak var arrow3ImageView: NSImageView!
-
- @IBOutlet weak var accountCenterBox: KMBox!
- @IBOutlet weak var accountImageView: NSImageView!
- @IBOutlet weak var accountLabel: NSTextField!
- @IBOutlet weak var signOutBox: KMBox!
- @IBOutlet weak var signOutImageView: NSImageView!
- @IBOutlet weak var signOutLabel: NSTextField!
- @IBOutlet weak var closeAccountBox: KMBox!
- @IBOutlet weak var closeAccountImageView: NSImageView!
- @IBOutlet weak var closeAccountLabel: NSTextField!
-
- private var viewModel = KMUserInfoVCModel()
- private var cancellables = Set<AnyCancellable>()
-
- deinit {
- KMPrint("KMUserInfoViewController deinit.")
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- self.view.wantsLayer = true
- self.view.layer?.backgroundColor = .white
-
- bindViewModel()
- languageLocalized()
- initializeUI()
-
- NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
- }
-
- @objc func changeEffectiveAppearance() {
- let isDarkModel = KMAdvertisementConfig.isDarkModel()
- if isDarkModel {
- self.view.appearance = NSAppearance(named: .darkAqua)
- } else {
- self.view.appearance = NSAppearance(named: .aqua)
- }
- initializeUI()
- }
-
- // MARK: Private Method
-
- private func languageLocalized() -> Void {
- emailLabel.stringValue = KMMemberInfo.shared.userEmail
- productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
- endDateLabel.stringValue = KMMemberInfo.shared.vip_endDate
- membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
- buyNow3Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- accountLabel.stringValue = NSLocalizedString("Account Center", tableName: "MemberCenterLocalizable", comment: "")
- signOutLabel.stringValue = NSLocalizedString("Sign out", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.validFlag == "5" {
- closeAccountLabel.stringValue = NSLocalizedString("Undo Remove Account", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- closeAccountLabel.stringValue = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
- }
- if KMMemberInfo.shared.vip_maxDeviceNum == 1 {
- number4Label.stringValue = NSLocalizedString("device", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number4Label.stringValue = NSLocalizedString("devices", tableName: "MemberCenterLocalizable", comment: "")
- }
- number4_1Label.stringValue = String(KMMemberInfo.shared.vip_maxDeviceNum)
-
- number5Label.stringValue = NSLocalizedString("Devices Access", tableName: "MemberCenterLocalizable", comment: "")
- let platforms = viewModel.getPlatformsImages()
- if platforms.count == 4 {
- number3Label.stringValue = NSLocalizedString("All-platform Available", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number3Label.stringValue = NSLocalizedString("Platform", tableName: "MemberCenterLocalizable", comment: "")
- }
-
- if KMMemberInfo.shared.userScenarioType == .lite_type1 || KMMemberInfo.shared.userScenarioType == .lite_type9 {
- buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
- buyNow3Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
- buyNow3Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
- KMMemberInfo.shared.userScenarioType == .pro_type1 ||
- KMMemberInfo.shared.userScenarioType == .pro_type3 ||
- KMMemberInfo.shared.userScenarioType == .pro_type4 {
- buyNow3Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
- KMMemberInfo.shared.userScenarioType == .lite_type8 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 {
- buyNow3Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
- }
- }
-
- private func refreshEquity() -> Void {
- if KMMemberInfo.shared.userScenarioType == .lite_type1 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type2 {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type4 {
- if(KMMemberInfo.shared.vip_cycle == 1) {
- lockedLabel.stringValue = NSLocalizedString("Monthly Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 2) {
- lockedLabel.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 3) {
- lockedLabel.stringValue = NSLocalizedString("6-Month Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 4) {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- }
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.vip_levels == "2" {
- number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- }
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type5 {
- lockedLabel.stringValue = NSLocalizedString("Permanent Plan", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.vip_levels == "2" {
- number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- }
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type6 {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.vip_levels == "2" {
- number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- }
-
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type7 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type8 {
- if(KMMemberInfo.shared.vip_cycle == 1) {
- lockedLabel.stringValue = NSLocalizedString("Monthly Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 2) {
- lockedLabel.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 3) {
- lockedLabel.stringValue = NSLocalizedString("6-Month Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 4) {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- }
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.vip_levels == "2" {
- number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- }
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type9 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type10 {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type12 {
- if(KMMemberInfo.shared.vip_cycle == 1) {
- lockedLabel.stringValue = NSLocalizedString("Monthly Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 2) {
- lockedLabel.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 3) {
- lockedLabel.stringValue = NSLocalizedString("6-Month Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 4) {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- }
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- if(KMMemberInfo.shared.vip_levels == "2") {
- number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
- } else if((KMMemberInfo.shared.vip_levels == "3")) {
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- }
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type13 {
- if(KMMemberInfo.shared.vip_cycle == 1) {
- lockedLabel.stringValue = NSLocalizedString("Monthly Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 2) {
- lockedLabel.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 3) {
- lockedLabel.stringValue = NSLocalizedString("6-Month Plan", tableName: "MemberCenterLocalizable", comment: "")
- } else if(KMMemberInfo.shared.vip_cycle == 4) {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- }
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.vip_levels == "2" {
- number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- }
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type1 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type2 {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
- lockedLabel.stringValue = NSLocalizedString("Permanent Plan", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type5 {
- lockedLabel.stringValue = NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1Label.stringValue = NSLocalizedString("", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = false
- number1Label.isHidden = true
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- number2Label.textColor = NSColor(named: "FFFFFF")
- number3Label.textColor = NSColor(named: "FFFFFF")
- number4Label.textColor = NSColor(named: "FFFFFF")
- number4_1Label.textColor = NSColor(named: "FFFFFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- } else {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.textColor = NSColor(hex:"42464D")
- number3Label.textColor = NSColor(hex:"42464D")
- number4Label.textColor = NSColor(hex: "42464D")
- number4_1Label.textColor = NSColor(hex: "42464D")
- number5Label.textColor = NSColor(hex: "42464D")
- }
- }
-
- private func initializeUI() -> Void {
- refreshEquity()
-
- self.view.wantsLayer = true
- let isDarkModel = KMAdvertisementConfig.isDarkModel()
- if isDarkModel {
- self.view.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
- } else {
- self.view.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
- }
- userImageView.image = NSImage(named: "UserProfilePicture_Size")
- emailLabel.textColor = NSColor(named: "0E1114")
- emailLabel.font = NSFont.SFMediumFontWithSize(14)
- productLabel.textColor = NSColor(named: "42464D_1")
- productLabel.font = NSFont.SFProTextRegularFont(12)
- endDateLabel.textColor = NSColor(named: "42464D_1")
- endDateLabel.font = NSFont.SFProTextRegularFont(12)
- spliLineImageView.isHidden = true
- endDateLabel.isHidden = true
- if KMMemberInfo.shared.userScenarioType == .lite_type4 ||
- KMMemberInfo.shared.userScenarioType == .lite_type6 ||
- KMMemberInfo.shared.userScenarioType == .lite_type7 ||
- KMMemberInfo.shared.userScenarioType == .lite_type8 ||
- KMMemberInfo.shared.userScenarioType == .lite_type12 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 ||
- KMMemberInfo.shared.userScenarioType == .pro_type3 {
- if KMMemberInfo.shared.vip_endDate.count > 0 {
- spliLineImageView.isHidden = false
- endDateLabel.isHidden = false
- }
- }
- membershipLabel.font = NSFont.SFMediumFontWithSize(16)
- lockedLabel.font = NSFont.SFMediumFontWithSize(12)
- rightsBox.contentView = rightsView
- number1Label.font = NSFont.SFMediumFontWithSize(24)
- number1ImageView.image = NSImage(named: "UpgradeImage")
- number2Label.font = NSFont.SFProTextRegularFont(12)
- number3Label.font = NSFont.SFProTextRegularFont(12)
- number5Label.font = NSFont.SFProTextRegularFont(12)
- buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- buyNow3ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- buyNow3ImageView.wantsLayer = true
- buyNow3ImageView.layer?.cornerRadius = 4.0
- buyNow1Label.textColor = NSColor(named: "FFFFFF")
- buyNow1Label.font = NSFont.SFProTextRegularFont(14)
- buyNow2Label.textColor = NSColor(named: "FFFFFF")
- buyNow2Label.font = NSFont.SFProTextRegularFont(14)
- buyNow3Label.textColor = NSColor(named: "000000")
- buyNow3Label.font = NSFont.SFProTextRegularFont(14)
- accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
- accountCenterBox.fillColor = .clear
- accountLabel.textColor = NSColor(named: "065CBC")
- accountLabel.font = NSFont.SFProTextRegularFont(14)
- accountImageView.image = NSImage(named: "AccountCenterImage")
- signOutLabel.textColor = NSColor(named: "065CBC")
- signOutLabel.font = NSFont.SFProTextRegularFont(14)
- signOutImageView.image = NSImage(named: "SignOutImage")
- closeAccountLabel.textColor = NSColor(named: "065CBC")
- closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
- closeAccountImageView.image = NSImage(named: "CloseAccountImage")
- buyNow3Box.fillColor = NSColor(named: "FFFFFF") ?? .white
-
- let isNoOldSubscribed = IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == false && IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == false
- if KMMemberInfo.shared.userScenarioType == .lite_type1 ||
- KMMemberInfo.shared.userScenarioType == .lite_type2 ||
- KMMemberInfo.shared.userScenarioType == .lite_type3 ||
- KMMemberInfo.shared.userScenarioType == .lite_type10 {
- rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
- membershipLabel.textColor = NSColor(hex: "0E1114")
- lockedLabel.textColor = NSColor(hex: "42464D")
- if KMMemberInfo.shared.userScenarioType == .lite_type1 {
- buyBox.contentView = buyView1
- buyNow1ImageView.isHidden = false
- buyNow2ImageView.isHidden = false
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
- arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
- #if !VERSION_DMG
- if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- }
- #else
- #endif
- } else if KMMemberInfo.shared.userScenarioType == .lite_type3{
- buyNow3Label.textColor = NSColor(named: "FFFFFF")
- buyBox.contentView = buyView2
- buyNow3ImageView.isHidden = false
- arrow3ImageView.image = NSImage(named: "BuyNewArrowImage1")
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type4 ||
- KMMemberInfo.shared.userScenarioType == .lite_type5 ||
- KMMemberInfo.shared.userScenarioType == .lite_type6 ||
- KMMemberInfo.shared.userScenarioType == .lite_type12 ||
- KMMemberInfo.shared.userScenarioType == .pro_type1 ||
- KMMemberInfo.shared.userScenarioType == .pro_type2 ||
- KMMemberInfo.shared.userScenarioType == .pro_type3 ||
- KMMemberInfo.shared.userScenarioType == .pro_type4 ||
- KMMemberInfo.shared.userScenarioType == .pro_type5 {
- membershipLabel.textColor = NSColor(named: "FFFFFF")
- lockedLabel.textColor = NSColor(hex: "FCFDFF")
- number5Label.textColor = NSColor(named: "FFFFFF")
- rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
- if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
- KMMemberInfo.shared.userScenarioType == .pro_type1 ||
- KMMemberInfo.shared.userScenarioType == .pro_type3 ||
- KMMemberInfo.shared.userScenarioType == .pro_type4 {
- buyBox.contentView = buyView2
- buyNow3ImageView.isHidden = true
- arrow3ImageView.image = NSImage(named: "BuyNewArrowImage2")
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
- (KMMemberInfo.shared.userScenarioType == .lite_type9 && KMMemberInfo.shared.vip_paymentModel == "2" && isNoOldSubscribed) || (KMMemberInfo.shared.userScenarioType == .lite_type11 && KMMemberInfo.shared.vip_paymentModel == "2" && isNoOldSubscribed) {
- membershipLabel.textColor = NSColor(hex: "0E1114")
- lockedLabel.textColor = NSColor(hex: "42464D")
-
- rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
- buyBox.contentView = buyView2
- buyNow3ImageView.isHidden = false
- buyNow3Label.textColor = NSColor(named: "FFFFFF")
- arrow3ImageView.image = NSImage(named: "BuyNewArrowImage1")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type8 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 {
- membershipLabel.textColor = NSColor(hex: "FCFDFF")
- lockedLabel.textColor = NSColor(hex: "FCFDFF")
- rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
- }
- let platforms = viewModel.getPlatformsImages()
- if platforms.count == 4 {
- iconBox.contentView = iconView1
- icon1ImageView.image = platforms[0]
- icon2ImageView.image = platforms[1]
- icon3ImageView.image = platforms[2]
- icon4ImageView.image = platforms[3]
- } else if platforms.count == 3 {
- iconBox.contentView = iconView2
- icon5ImageView.image = platforms[0]
- icon6ImageView.image = platforms[1]
- icon7ImageView.image = platforms[2]
- } else if platforms.count == 2 {
- iconBox.contentView = iconView3
- icon8ImageView.image = platforms[0]
- icon9ImageView.image = platforms[1]
- } else if platforms.count == 1 {
- iconBox.contentView = iconView4
- icon10ImageView.image = platforms[0]
- }
-
- buyNow1Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
- guard let self = self else { return }
- if mouseEntered {
- self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
- } else {
- self.buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- }
- }
- buyNow1Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
- guard let self = self else { return }
- if KMMemberInfo.shared.userScenarioType == .lite_type1 {
- self.viewModel.skipCompare(.lite_Base)
- }
- }
-
- buyNow2Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
- guard let self = self else { return }
- if mouseEntered {
- self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
- } else {
- self.buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- }
- }
- buyNow2Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
- guard let self = self else { return }
- if KMMemberInfo.shared.userScenarioType == .lite_type1 {
- self.viewModel.skipCompare(.trial)
- }
- }
-
- buyNow3Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
- guard let self = self else { return }
- if KMMemberInfo.shared.userScenarioType == .lite_type3 ||
- KMMemberInfo.shared.userScenarioType == .lite_type11 {
- if mouseEntered {
- self.buyNow3ImageView.image = NSImage(named: "ButtonBackgroundImage2_Hov")
- } else {
- self.buyNow3ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- }
- }
- }
- buyNow3Box.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
- guard let self = self else { return }
- if KMMemberInfo.shared.userScenarioType == .lite_type3 ||
- KMMemberInfo.shared.userScenarioType == .lite_type7 ||
- KMMemberInfo.shared.userScenarioType == .lite_type8 {
- self.viewModel.skipCompare(.lite_Base)
- } else if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
- KMMemberInfo.shared.userScenarioType == .lite_type9 ||
- KMMemberInfo.shared.userScenarioType == .lite_type11 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 {
- self.viewModel.skipCompare(.lite_MacWindows)
- } else if KMMemberInfo.shared.userScenarioType == .pro_type1 ||
- KMMemberInfo.shared.userScenarioType == .pro_type4 {
- self.viewModel.skipCompare(.pro_Advanced)
- } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
- self.viewModel.skipCompare(.pro_Base)
- }
- }
-
- accountCenterBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
- guard let self = self else { return }
- if mouseEntered {
- self.accountCenterBox.fillColor = NSColor(named: "F5FAFF") ?? .white
- self.accountLabel.textColor = NSColor(named: "3091FF")
- self.accountImageView.image = NSImage(named: "AccountCenterImage_Hov")
- } else {
- self.accountCenterBox.fillColor = .clear
- self.accountLabel.textColor = NSColor(named: "065CBC")
- self.accountImageView.image = NSImage(named: "AccountCenterImage")
- }
- }
- accountCenterBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
- guard let self = self else { return }
- self.viewModel.skipAccountCenter()
- }
-
- signOutBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
- guard let self = self else { return }
- if mouseEntered {
- self.signOutLabel.textColor = NSColor(named: "3091FF")
- self.signOutImageView.image = NSImage(named: "SignOutImage_Hov")
- } else {
- self.signOutLabel.textColor = NSColor(named: "065CBC")
- self.signOutImageView.image = NSImage(named: "SignOutImage")
- }
- }
- signOutBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
- guard let self = self else { return }
- self.viewModel.signOutAction()
- }
-
- closeAccountBox.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
- guard let self = self else { return }
- if mouseEntered {
- self.closeAccountLabel.textColor = NSColor(named: "3091FF")
- self.closeAccountImageView.image = NSImage(named: "CloseAccountImage_hover")
- } else {
- self.closeAccountLabel.textColor = NSColor(named: "065CBC")
- self.closeAccountImageView.image = NSImage(named: "CloseAccountImage")
- }
- }
- closeAccountBox.downCallback = { [weak self](downEntered: Bool, mouseBox: KMBox, event) -> Void in
- guard let self = self else { return }
- self.viewModel.closeAccountAction()
- }
-
- buyNow1BoxLeftConst.constant = 0
- buyNow2Box.isHidden = false
-
- //远程控制
- if let userViewInfoContent = KMAdvertisementManager.manager.info.userViewInfoContent {
- if userViewInfoContent.content?.isEmpty == false {
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- }
- }
- }
-
- // MARK: Bind Method
-
- func bindViewModel() -> Void {
-
- }
-
- // MARK: Action Method
- }
|