1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342 |
- //
- // 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 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.")
- }
-
- @objc class func refreshTokenUserInfo(callback: ((Bool,KMMemberCenterResult?)->Void)?) -> Void {
- if KMMemberCenterManager.manager.isConnectionAvailable() == false {
- let alert = NSAlert()
- alert.alertStyle = .critical
- alert.messageText = NSLocalizedString("Error Information", comment: "")
- alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
- alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
- alert.runModal()
- let res = KMMemberCenterResult(code: 500, msg: "", result: false)
- callback?(false,res)
- return
- }
-
- KMUserInfoVCModel().refreshUserInfo(networkAlert: false) { success, msg,resDic in
- callback?(success,resDic)
- if success {
- KMMemberInfo.shared.isLogin = true
- } else {
- KMMemberInfo.shared.isLogin = false
- }
- }
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- self.view.wantsLayer = true
- self.view.layer?.backgroundColor = .white
-
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- languageLocalized_DMG()
- initializeUI_DMG()
- #else
- // AppStore 免费版本
- languageLocalized()
- initializeUI()
- #endif
- #else
- // AppStore 付费版
- languageLocalized()
- initializeUI()
- #endif
-
- if let data = KMMemberInfo.shared.avatarImage {
- userImageView.image = data
- } else {
- userImageView.image = KMAdvertisementImage.imageWithURL(url: URL(string: KMMemberInfo.shared.avatarUrl) , completion: { [weak self] image in
- self?.userImageView.image = image
- KMMemberInfo.shared.avatarImage = image
- })
- }
- NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
-
- addWaitingView(to: self.view)
- KMUserInfoViewController.refreshTokenUserInfo {[weak self] success, resDic in
- DispatchQueue.main.async {
- self?.removeWaitingView(from: self?.view ?? NSView())
- if(success) {
- if KMMemberInfo.shared.isLogin {
- }
- } else {
- NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
- let code = resDic?.code
- if code == 304 {
- KMLoginWindowsController.shared.showWindow(nil)
- }
- }
- }
- }
-
- }
-
- @objc func changeEffectiveAppearance() {
- let isDarkModel = KMAdvertisementConfig.isDarkModel()
- if isDarkModel {
- self.view.appearance = NSAppearance(named: .darkAqua)
- } else {
- self.view.appearance = NSAppearance(named: .aqua)
- }
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- initializeUI_DMG()
- #else
- // AppStore 免费版本
- initializeUI()
- #endif
- #else
- // AppStore 付费版
- initializeUI()
- #endif
- }
-
- // MARK: Private Method
-
- private func languageLocalized() -> Void {
- emailLabel.stringValue = KMMemberInfo.shared.userEmail
- productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
- endDateLabel.stringValue = String(format: "%@ %@", KMMemberInfo.shared.vip_endDate,NSLocalizedString("expires", tableName: "MemberCenterLocalizable", comment: ""))
- membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
- buyNow1Label.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 {
- buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- var isTrialPeriod = false
- #if !VERSION_DMG
- if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
- isTrialPeriod = true
- }
- #else
- #endif
- if isTrialPeriod {
- buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- buyNow2Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type9 {
- if(KMMemberInfo.shared.vip_status == 2) {
- buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
- } else if (KMMemberInfo.shared.vip_status == 4) {
- buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type3 {
- buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type11 {
- buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type5 ||
- KMMemberInfo.shared.userScenarioType == .pro_type1 ||
- KMMemberInfo.shared.userScenarioType == .pro_type4 {
- buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
- if(KMMemberInfo.shared.vip_status == 2) {
- buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
- KMMemberInfo.shared.userScenarioType == .lite_type8 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 {
- buyNow1Label.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")
- membershipLabel.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")
- } 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")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type4 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type5 {
- lockedLabel.stringValue = NSLocalizedString("Permanent", 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")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type6 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- } 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")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type8 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type9 ||
- KMMemberInfo.shared.userScenarioType == .pro_type1 {
- if(KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1") { //永久
- lockedLabel.stringValue = NSLocalizedString("Permanent", 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")
- } 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")
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type10 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- } 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")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type12 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- } else if KMMemberInfo.shared.userScenarioType == .lite_type13 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type2 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- number1Label.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")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
- lockedLabel.stringValue = NSLocalizedString("Permanent", 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")
- } else if KMMemberInfo.shared.userScenarioType == .pro_type5 {
- lockedLabel.stringValue = NSLocalizedString("Subscription", 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")
- } 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")
- }
-
- if lockedLabel.stringValue == NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "") {
- lockedLabel.textColor = NSColor(hex: "#42464D")
- } else if lockedLabel.stringValue == NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "") {
- lockedLabel.textColor = NSColor(hex: "#42464D")
- } else if lockedLabel.stringValue == NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "") {
- lockedLabel.textColor = NSColor(hex: "#273C62")
- } else if lockedLabel.stringValue == NSLocalizedString("Annual Plan", tableName: "MemberCenterLocalizable", comment: "") {
- lockedLabel.textColor = NSColor(hex: "#42464D")
- }
- }
-
- func addWaitingView(to view: NSView) {
- removeWaitingView(from: view)
- let waitingView = WaitingView(frame: view.bounds)
- waitingView.autoresizingMask = [.width, .height]
- view.addSubview(waitingView)
- waitingView.startAnimation()
- }
- func removeWaitingView(from view: NSView) {
- for subview in view.subviews {
- if subview is WaitingView {
- subview.removeFromSuperview()
- break
- }
- }
- }
-
- 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.vip_levels != "1" &&
- KMMemberInfo.shared.vip_paymentModel == "1" &&
- (KMMemberInfo.shared.vip_status == 1 || KMMemberInfo.shared.vip_status == 3) {
- // 订阅中、试用中,显示到期日期
- if KMMemberInfo.shared.vip_endDate.count > 0 {
- spliLineImageView.isHidden = false
- endDateLabel.isHidden = false
- }
- } else if KMMemberInfo.shared.vip_status == 2 {
- // 订阅到期,显示到期日期
- if KMMemberInfo.shared.vip_endDate.count > 0 {
- spliLineImageView.isHidden = false
- endDateLabel.isHidden = false
- endDateLabel.textColor = NSColor(named: "FA1E5D")
- }
- }
- 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")
- buyNow1Label.textColor = NSColor(named: "FFFFFF")
- buyNow1Label.font = NSFont.SFProTextRegularFont(14)
- buyNow2Label.textColor = NSColor(named: "FFFFFF")
- buyNow2Label.font = NSFont.SFProTextRegularFont(14)
- accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
- accountCenterBox.fillColor = .clear
- accountLabel.textColor = NSColor(named: "3091FF")
- accountLabel.font = NSFont.SFProTextRegularFont(14)
- accountImageView.image = NSImage(named: "AccountCenterImage")
- signOutLabel.textColor = NSColor(named: "3091FF")
- signOutLabel.font = NSFont.SFProTextRegularFont(14)
- signOutImageView.image = NSImage(named: "SignOutImage")
- closeAccountLabel.textColor = NSColor(named: "3091FF")
- closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
- closeAccountImageView.image = NSImage(named: "CloseAccountImage")
-
- var isNoOldSubscribed = false
- var isTrialPeriod = false
- #if VERSION_FREE
- #if !VERSION_DMG
- isNoOldSubscribed = IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == false && IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == false
-
- if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
- isTrialPeriod = true
- }
- #endif
- #endif
- var isShowFreeTraalBtn = false
- 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")
- buyNow1Label.textColor = NSColor(hex: "FFFFFF")
- buyNow2Label.textColor = NSColor(hex: "FFFFFF")
- if isTrialPeriod == true {
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- } else {
- isShowFreeTraalBtn = true
- }
- } else if KMMemberInfo.shared.userScenarioType == .pro_type3 {
- buyBox.contentView = buyView1
-
- buyNow1ImageView.isHidden = false
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
- buyNow1Label.textColor = NSColor(hex: "FFFFFF")
-
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- } else if KMMemberInfo.shared.userScenarioType == .lite_type9 ||
- KMMemberInfo.shared.userScenarioType == .pro_type1 {
- buyBox.contentView = buyView1
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- if((KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1")) { //永久
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
- buyNow1Label.textColor = NSColor(hex: "42464D")
- } else {
- buyNow1ImageView.isHidden = false
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
- buyNow1Label.textColor = NSColor(hex: "FFFFFF")
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type11 { //试用过期
- if(!isNoOldSubscribed) {
- buyBox.contentView = buyView1
-
- buyNow1ImageView.isHidden = false
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
- buyNow1Label.textColor = NSColor(hex: "FFFFFF")
-
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- }
- } else if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
- KMMemberInfo.shared.userScenarioType == .lite_type4 ||
- KMMemberInfo.shared.userScenarioType == .lite_type6 ||
- KMMemberInfo.shared.userScenarioType == .lite_type8 ||
- KMMemberInfo.shared.userScenarioType == .lite_type10 ||
- KMMemberInfo.shared.userScenarioType == .lite_type12 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 ||
- KMMemberInfo.shared.userScenarioType == .pro_type2 ||
- KMMemberInfo.shared.userScenarioType == .pro_type5 { //有订阅+试用中
-
- } else if KMMemberInfo.shared.userScenarioType == .lite_type7 ||
- KMMemberInfo.shared.userScenarioType == .lite_type3 { //试用过期+会员到期
- buyBox.contentView = buyView1
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
- buyNow1Label.textColor = NSColor(hex: "FFFFFF")
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- } else {
- buyBox.contentView = buyView1
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
-
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
- buyNow1Label.textColor = NSColor(hex: "42464D")
- }
-
- if KMMemberInfo.shared.userScenarioType == .lite_type2 ||
- KMMemberInfo.shared.userScenarioType == .lite_type4 ||
- KMMemberInfo.shared.userScenarioType == .lite_type5 ||
- KMMemberInfo.shared.userScenarioType == .lite_type6 ||
- KMMemberInfo.shared.userScenarioType == .lite_type8 ||
- KMMemberInfo.shared.userScenarioType == .lite_type10 ||
- KMMemberInfo.shared.userScenarioType == .lite_type12 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 ||
- KMMemberInfo.shared.userScenarioType == .pro_type2 ||
- KMMemberInfo.shared.userScenarioType == .pro_type4 ||
- KMMemberInfo.shared.userScenarioType == .pro_type5 { //订阅或者买断
- rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
- membershipLabel.textColor = NSColor(hex: "FFFFFF")
- buyNow1ImageView.isHidden = true
- buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
-
- number2Label.textColor = NSColor(hex: "FFFFFF")
- number3Label.textColor = NSColor(hex: "FFFFFF")
- number4Label.textColor = NSColor(hex: "FFFFFF")
- number4_1Label.textColor = NSColor(hex: "FFFFFF")
- number5Label.textColor = NSColor(hex: "FFFFFF")
- membershipLabel.textColor = NSColor(hex: "FFFFFF")
- } else if(KMMemberInfo.shared.userScenarioType == .lite_type9 ||
- KMMemberInfo.shared.userScenarioType == .pro_type1) {
- if(KMMemberInfo.shared.vip_paymentModel == "2" && KMMemberInfo.shared.vip_levels != "1") { //永久
- rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
- membershipLabel.textColor = NSColor(hex: "FFFFFF")
- buyNow1ImageView.isHidden = true
- buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
-
- number2Label.textColor = NSColor(hex: "FFFFFF")
- number3Label.textColor = NSColor(hex: "FFFFFF")
- number4Label.textColor = NSColor(hex: "FFFFFF")
- number4_1Label.textColor = NSColor(hex: "FFFFFF")
- number5Label.textColor = NSColor(hex: "FFFFFF")
- membershipLabel.textColor = NSColor(hex: "FFFFFF")
- } else {
- rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
- membershipLabel.textColor = NSColor(hex: "42464D")
- buyNow1ImageView.isHidden = false
- buyNow1Box.fillColor = NSColor.clear
-
- 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")
- membershipLabel.textColor = NSColor(hex: "42464D")
- }
-
- } else {
- rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
- membershipLabel.textColor = NSColor(hex: "42464D")
- buyNow1ImageView.isHidden = false
- buyNow1Box.fillColor = NSColor.clear
-
- 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")
- membershipLabel.textColor = NSColor(hex: "42464D")
- }
- lockedLabel.textColor = NSColor(hex: "42464D")
-
- 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 KMMemberInfo.shared.userScenarioType == .lite_type2 ||
- KMMemberInfo.shared.userScenarioType == .lite_type4 ||
- KMMemberInfo.shared.userScenarioType == .lite_type5 ||
- KMMemberInfo.shared.userScenarioType == .lite_type6 ||
- KMMemberInfo.shared.userScenarioType == .lite_type8 ||
- KMMemberInfo.shared.userScenarioType == .lite_type10 ||
- KMMemberInfo.shared.userScenarioType == .lite_type12 ||
- KMMemberInfo.shared.userScenarioType == .lite_type13 ||
- KMMemberInfo.shared.userScenarioType == .pro_type2 ||
- KMMemberInfo.shared.userScenarioType == .pro_type4 ||
- KMMemberInfo.shared.userScenarioType == .pro_type5 { //订阅或者买断
- if mouseEntered {
- self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2Hover")
- self.buyNow1Label.textColor = NSColor(hex: "4982E6")
- } else {
- self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
- self.buyNow1Label.textColor = NSColor(hex: "0E1114")
- }
- } else {
- 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)
- } else {
- // 其它情况根据账号状态跳转不同比较表
- NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
-
- KMMemberInfo.shared.productCompareShow()
- }
- }
-
- 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)
- }
- }
-
- 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: "3091FF")
- 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: "3091FF")
- 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: "3091FF")
- 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()
- }
-
- if isShowFreeTraalBtn == true { //没有试用过,才能显示,不然就算远程支持,功能上也不支持远程控制
- //远程控制
- 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: Action Method
-
- private func languageLocalized_DMG() -> Void {
- emailLabel.stringValue = KMMemberInfo.shared.userEmail
- productLabel.stringValue = NSLocalizedString("Personal Account", tableName: "MemberCenterLocalizable", comment: "")
- endDateLabel.stringValue = String(format: "%@ %@", KMMemberInfo.shared.vip_endDate,NSLocalizedString("expires", tableName: "MemberCenterLocalizable", comment: ""))
- membershipLabel.stringValue = NSLocalizedString("Membership Benefits", tableName: "MemberCenterLocalizable", comment: "")
- buyNow1Label.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 == .dmg_type5 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
- lockedLabel.stringValue = NSLocalizedString("Permanent", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- buyNow1Label.stringValue = NSLocalizedString("Upgrade Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
- lockedLabel.stringValue = NSLocalizedString("Subscription", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type36 {
- number2Label.stringValue = NSLocalizedString("Standard Version", tableName: "MemberCenterLocalizable", comment: "")
- } else {
- number2Label.stringValue = NSLocalizedString("Advanced Version", tableName: "MemberCenterLocalizable", comment: "")
- }
- } else { // 免费 & 到期
- if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type34 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type48 {
- lockedLabel.stringValue = NSLocalizedString("Locked", tableName: "MemberCenterLocalizable", comment: "")
- number1Label.stringValue = NSLocalizedString("150+", tableName: "MemberCenterLocalizable", comment: "")
- number2Label.stringValue = NSLocalizedString("Benefits of Functions", tableName: "MemberCenterLocalizable", comment: "")
- if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type48 { // 到期
- buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- } else { // 免费
-
- }
- if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type34 {
- buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- buyNow2Label.stringValue = NSLocalizedString("7-Day Free Trial", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type37 {
- buyNow1Label.stringValue = NSLocalizedString("Buy Now", tableName: "MemberCenterLocalizable", comment: "")
- } else if KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type48 {
- buyNow1Label.stringValue = NSLocalizedString("Renew now", tableName: "MemberCenterLocalizable", comment: "")
- }
- }
- }
- }
-
- private func initializeUI_DMG() -> Void {
- 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;
- }
-
- rightsBox.contentView = rightsView
- buyBox.contentView = buyView1
- 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
- number1Label.font = NSFont.SFMediumFontWithSize(24)
- number1Label.textColor = NSColor(hex: "0E1114")
- number2Label.font = NSFont.SFProTextRegularFont(12)
- number3Label.font = NSFont.SFProTextRegularFont(12)
- number5Label.font = NSFont.SFProTextRegularFont(12)
- membershipLabel.font = NSFont.SFMediumFontWithSize(16)
- lockedLabel.font = NSFont.SFMediumFontWithSize(12)
- lockedLabel.textColor = NSColor(hex: "42464D")
- accountCenterBox.borderColor = NSColor(named: "3091FF") ?? .blue
- accountCenterBox.fillColor = .clear
- accountLabel.textColor = NSColor(named: "3091FF")
- accountLabel.font = NSFont.SFProTextRegularFont(14)
- accountImageView.image = NSImage(named: "AccountCenterImage")
- signOutLabel.textColor = NSColor(named: "3091FF")
- signOutLabel.font = NSFont.SFProTextRegularFont(14)
- signOutImageView.image = NSImage(named: "SignOutImage")
- closeAccountLabel.textColor = NSColor(named: "3091FF")
- closeAccountLabel.font = NSFont.SFProTextRegularFont(14)
- closeAccountImageView.image = NSImage(named: "CloseAccountImage")
- buyNow1Label.font = NSFont.SFProTextRegularFont(14)
- buyNow2Label.font = NSFont.SFProTextRegularFont(14)
- 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]
- }
- buyNow1ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- buyNow2ImageView.image = NSImage(named: "ButtonBackgroundImage2")
- if KMMemberInfo.shared.userScenarioType == .dmg_type5 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage4")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1ImageView.isHidden = false
- number1ImageView.image = NSImage(named: "UpgradeImage")
- number1Label.isHidden = true
- number2Label.textColor = NSColor(hex: "FFFFFF")
- number3Label.textColor = NSColor(hex: "FFFFFF")
- number4Label.textColor = NSColor(hex: "FFFFFF")
- number4_1Label.textColor = NSColor(hex: "FFFFFF")
- number5Label.textColor = NSColor(hex: "FFFFFF")
- membershipLabel.textColor = NSColor(hex: "FFFFFF")
- rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
- buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
- buyNow1ImageView.isHidden = true
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
- buyNow1Label.textColor = NSColor(hex: "42464D")
- } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage5")
- lockedImageView.image = NSImage(named: "UpgradeImage2")
- number1ImageView.isHidden = false
- number1ImageView.image = NSImage(named: "UpgradeImage")
- number1Label.isHidden = true
- number2Label.textColor = NSColor(hex: "FFFFFF")
- number3Label.textColor = NSColor(hex: "FFFFFF")
- number4Label.textColor = NSColor(hex: "FFFFFF")
- number4_1Label.textColor = NSColor(hex: "FFFFFF")
- number5Label.textColor = NSColor(hex: "FFFFFF")
- membershipLabel.textColor = NSColor(hex: "FFFFFF")
- if KMMemberInfo.shared.vip_endDate.count > 0 {
- spliLineImageView.isHidden = false
- endDateLabel.isHidden = false
- }
- rightsBox.fillColor = NSColor(named: "FFFFFF_0.2") ?? .white
- buyNow1Box.fillColor = NSColor(hex: "FFFFFF")
- buyNow1ImageView.isHidden = true
- buyNow1Box.isHidden = true
- buyNow2Box.isHidden = true
- } else { // 免费 & 到期
- if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type34 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type48 {
- centerBackgroud.image = NSImage(named: "ButtonBackgroundImage3")
- lockedImageView.image = NSImage(named: "LockedImage")
- number1ImageView.isHidden = true
- number1Label.isHidden = false
- 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")
- membershipLabel.textColor = NSColor(hex: "42464D")
- rightsBox.fillColor = NSColor(named: "7094F6_0.1") ?? .white
- buyNow1Box.fillColor = NSColor.clear
- buyNow2Box.fillColor = NSColor.clear
- buyNow1ImageView.isHidden = false
- buyNow2ImageView.isHidden = false
- arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
- arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
- buyNow1Label.textColor = NSColor(named: "FFFFFF")
- buyNow1Label.textColor = NSColor(hex: "FFFFFF")
- buyNow2Label.textColor = NSColor(hex: "FFFFFF")
- if KMMemberInfo.shared.userScenarioType == .dmg_type11 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type18 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type22 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type33 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type37 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type48 { // 到期
- if KMMemberInfo.shared.vip_endDate.count > 0 &&
- KMMemberInfo.shared.vip_status == 2 {
- spliLineImageView.isHidden = false
- endDateLabel.isHidden = false
- endDateLabel.textColor = NSColor(named: "FA1E5D")
- }
- spliLineImageView.isHidden = false
- endDateLabel.isHidden = false
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- } else { // 免费
- if KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type34 {
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- }
- }
- }
- }
- buyNow1Box.moveCallback = { [weak self](mouseEntered: Bool, mouseBox: KMBox) -> Void in
- guard let self = self else { return }
-
- if KMMemberInfo.shared.userScenarioType == .dmg_type5 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type6 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type7 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type28 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type29 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type30 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type43 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type44 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type45 { // 买断
- if mouseEntered {
- self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2Hover")
- self.buyNow1Label.textColor = NSColor(hex: "4982E6")
- } else {
- self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
- self.buyNow1Label.textColor = NSColor(hex: "0E1114")
- }
- } else if KMMemberInfo.shared.userScenarioType == .dmg_type8 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type9 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type10 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type12 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type13 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type14 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type15 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type16 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type17 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type20 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type21 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type23 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type24 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type25 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type26 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type27 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type31 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type32 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type35 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type36 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type38 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type39 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type40 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type41 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type42 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type46 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type47 { // 订阅
- if mouseEntered {
- self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2Hover")
- self.buyNow1Label.textColor = NSColor(hex: "4982E6")
- } else {
- self.arrow1ImageView.image = NSImage(named: "BuyNewArrowImage2")
- self.buyNow1Label.textColor = NSColor(hex: "0E1114")
- }
- } else {
- 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)
- } else {
- // 其它情况根据账号状态跳转不同比较表
- NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
-
- KMMemberInfo.shared.productCompareShow()
- }
- }
-
- 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)
- } else if KMMemberInfo.shared.userScenarioType == .dmg_type4 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type19 ||
- KMMemberInfo.shared.userScenarioType == .dmg_type34 {
- self.viewModel.skipCompare(.trial)
- }
- }
-
- 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: "3091FF")
- 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: "3091FF")
- 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: "3091FF")
- 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()
- }
- //远程控制
- if let userViewInfoContent = KMAdvertisementManager.manager.info.userViewInfoContent {
-
- buyNow1BoxLeftConst.constant = 0
- buyNow2Box.isHidden = false
-
- if userViewInfoContent.content?.isEmpty == false {
- buyNow2Box.isHidden = true
- buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
- }
- }
- }
- }
|