// // KMCloseAccountWC.swift // PDF Reader Pro // // Created by wanjun on 2024/11/5. // import Cocoa class KMCloseAccountWC: NSWindowController { @IBOutlet weak var titleLabel: NSTextField! @IBOutlet weak var subTitleLabel: NSTextField! @IBOutlet weak var productBox: NSBox! @IBOutlet weak var productView: NSView! @IBOutlet weak var productLabel: NSTextField! @IBOutlet weak var proView: NSView! @IBOutlet weak var proLabel: NSTextField! @IBOutlet weak var aiView: NSView! @IBOutlet weak var aiLabel: NSTextField! @IBOutlet weak var yesButton: NSButton! @IBOutlet weak var cancelButton: NSButton! private var viewModel = KMUserInfoVCModel() static let shared: KMCloseAccountWC = { let windowC = KMCloseAccountWC(windowNibName: "KMCloseAccountWC") return windowC }() override func windowDidLoad() { super.windowDidLoad() // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. // self.window?.backgroundColor = NSColor.gray productView.wantsLayer = true proView.wantsLayer = true aiView.wantsLayer = true languageLocalized() initializeUI() NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil) } @objc func changeEffectiveAppearance() { self.initializeUI() } // MARK: Private Method private func languageLocalized() -> Void { self.window?.title = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "") titleLabel.stringValue = NSLocalizedString("Delete your account and related authorizations", tableName: "MemberCenterLocalizable", comment: "") subTitleLabel.stringValue = NSLocalizedString("Removing your account will permanently delete all account data, including the membership benefits of PDF Reader Pro across all platforms you purchased under this account. Are you sure you want to continue?", tableName: "MemberCenterLocalizable", comment: "") productLabel.stringValue = NSLocalizedString("Your products and services:", tableName: "MemberCenterLocalizable", comment: "") proLabel.stringValue = KMMemberInfo.shared.vip_productName aiLabel.stringValue = KMMemberInfo.shared.ai_productName cancelButton.title = NSLocalizedString("Cancel", tableName: "MemberCenterLocalizable", comment: "") yesButton.title = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "") } private func initializeUI() -> Void { self.window?.contentView?.wantsLayer = true let isDarkModel = KMAdvertisementConfig.isDarkModel() if isDarkModel { self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor; productView.layer?.backgroundColor = NSColor(hex: "323232").cgColor proView.layer?.backgroundColor = NSColor(hex: "272727").cgColor aiView.layer?.backgroundColor = NSColor(hex: "272727").cgColor } else { self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor; productView.layer?.backgroundColor = NSColor(hex: "E4E4E4").cgColor proView.layer?.backgroundColor = NSColor(hex: "F0F0F0").cgColor aiView.layer?.backgroundColor = NSColor(hex: "F0F0F0").cgColor } titleLabel.textColor = NSColor(named: "000000_0.85") titleLabel.font = NSFont.SFProTextSemiboldFont(13) subTitleLabel.textColor = NSColor(named: "000000_0.85") subTitleLabel.font = NSFont.SFProTextRegularFont(12) productBox.borderColor = NSColor(named: "DADBDE") ?? .gray productLabel.textColor = NSColor(named: "42464D") productLabel.font = NSFont.SFProTextRegularFont(13) if KMMemberInfo.shared.ai_productName == "" { aiView.isHidden = true } aiLabel.textColor = NSColor(named: "42464D") aiLabel.font = NSFont.SFProTextRegularFont(13) yesButton.setTitleColor(color: NSColor(named: "000000") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13)) cancelButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13)) } // MARK: Button Action @IBAction func cancelButtonAction(_ sender: NSButton) { self.window?.close() } @IBAction func yesButtonAction(_ sender: NSButton) { self.window?.close() viewModel.deleteAccountWC() } }