KMCloseAccountWC.swift 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // KMCloseAccountWC.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/11/5.
  6. //
  7. import Cocoa
  8. class KMCloseAccountWC: NSWindowController {
  9. @IBOutlet weak var titleLabel: NSTextField!
  10. @IBOutlet weak var subTitleLabel: NSTextField!
  11. @IBOutlet weak var productBox: NSBox!
  12. @IBOutlet weak var productView: NSView!
  13. @IBOutlet weak var productLabel: NSTextField!
  14. @IBOutlet weak var proView: NSView!
  15. @IBOutlet weak var proLabel: NSTextField!
  16. @IBOutlet weak var aiView: NSView!
  17. @IBOutlet weak var aiLabel: NSTextField!
  18. @IBOutlet weak var yesButton: NSButton!
  19. @IBOutlet weak var cancelButton: NSButton!
  20. private var viewModel = KMUserInfoVCModel()
  21. static let shared: KMCloseAccountWC = {
  22. let windowC = KMCloseAccountWC(windowNibName: "KMCloseAccountWC")
  23. return windowC
  24. }()
  25. override func windowDidLoad() {
  26. super.windowDidLoad()
  27. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  28. // self.window?.backgroundColor = NSColor.gray
  29. languageLocalized()
  30. initializeUI()
  31. NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
  32. }
  33. @objc func changeEffectiveAppearance() {
  34. self.initializeUI()
  35. }
  36. // MARK: Private Method
  37. private func languageLocalized() -> Void {
  38. self.window?.title = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  39. titleLabel.stringValue = NSLocalizedString("Delete your account and related authorizations", tableName: "MemberCenterLocalizable", comment: "")
  40. 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: "")
  41. productLabel.stringValue = NSLocalizedString("Your products and services:", tableName: "MemberCenterLocalizable", comment: "")
  42. proLabel.stringValue = KMMemberInfo.shared.vip_productName
  43. aiLabel.stringValue = KMMemberInfo.shared.ai_productName
  44. cancelButton.title = NSLocalizedString("Cancel", tableName: "MemberCenterLocalizable", comment: "")
  45. yesButton.title = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  46. }
  47. private func initializeUI() -> Void {
  48. self.window?.contentView?.wantsLayer = true
  49. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  50. if isDarkModel {
  51. self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  52. } else {
  53. self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  54. }
  55. titleLabel.textColor = NSColor(named: "000000_0.85")
  56. titleLabel.font = NSFont.SFProTextSemiboldFont(13)
  57. subTitleLabel.textColor = NSColor(named: "000000_0.85")
  58. subTitleLabel.font = NSFont.SFProTextRegularFont(12)
  59. productBox.borderColor = NSColor(named: "DADBDE") ?? .gray
  60. productLabel.textColor = NSColor(named: "42464D")
  61. productView.wantsLayer = true
  62. productView.layer?.backgroundColor = NSColor(named: "000000_0.05")?.cgColor
  63. proView.wantsLayer = true
  64. proView.layer?.backgroundColor = NSColor(named: "000000_0.76")?.cgColor
  65. aiView.wantsLayer = true
  66. aiView.layer?.backgroundColor = NSColor(named: "000000_0.76")?.cgColor
  67. productLabel.font = NSFont.SFProTextRegularFont(13)
  68. if KMMemberInfo.shared.ai_productName == "" {
  69. aiView.isHidden = true
  70. }
  71. aiLabel.textColor = NSColor(named: "42464D")
  72. aiLabel.font = NSFont.SFProTextRegularFont(13)
  73. yesButton.setTitleColor(color: NSColor(named: "000000") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  74. cancelButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  75. }
  76. // MARK: Button Action
  77. @IBAction func cancelButtonAction(_ sender: NSButton) {
  78. self.window?.close()
  79. }
  80. @IBAction func yesButtonAction(_ sender: NSButton) {
  81. self.window?.close()
  82. viewModel.deleteAccountWC()
  83. }
  84. }