123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- //
- // 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
-
- 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;
- } else {
- self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "FFFFFF").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")
- productView.wantsLayer = true
- productView.layer?.backgroundColor = NSColor(named: "000000_0.05")?.cgColor
-
- proView.wantsLayer = true
- proView.layer?.backgroundColor = NSColor(named: "000000_0.76")?.cgColor
- aiView.wantsLayer = true
- aiView.layer?.backgroundColor = NSColor(named: "000000_0.76")?.cgColor
- 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()
- }
- }
|