KMCloseAccountWC.swift 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. titleLabel.stringValue = NSLocalizedString("Delete your account and related authorizations", tableName: "MemberCenterLocalizable", comment: "")
  39. 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: "")
  40. productLabel.stringValue = NSLocalizedString("Your products and services:", tableName: "MemberCenterLocalizable", comment: "")
  41. proLabel.stringValue = KMMemberInfo.shared.vip_productName
  42. aiLabel.stringValue = KMMemberInfo.shared.ai_productName
  43. cancelButton.title = NSLocalizedString("Cancel", tableName: "MemberCenterLocalizable", comment: "")
  44. yesButton.title = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  45. }
  46. private func initializeUI() -> Void {
  47. self.window?.contentView?.wantsLayer = true
  48. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  49. if isDarkModel {
  50. self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  51. } else {
  52. self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  53. }
  54. titleLabel.textColor = NSColor(named: "000000_0.85")
  55. titleLabel.font = NSFont.SFProTextSemiboldFont(13)
  56. subTitleLabel.textColor = NSColor(named: "000000_0.85")
  57. subTitleLabel.font = NSFont.SFProTextRegularFont(12)
  58. productBox.borderColor = NSColor(named: "DADBDE") ?? .gray
  59. productLabel.textColor = NSColor(named: "42464D")
  60. productView.wantsLayer = true
  61. productView.layer?.backgroundColor = NSColor(named: "000000_0.05")?.cgColor
  62. proView.wantsLayer = true
  63. proView.layer?.backgroundColor = NSColor(named: "000000_0.76")?.cgColor
  64. aiView.wantsLayer = true
  65. aiView.layer?.backgroundColor = NSColor(named: "000000_0.76")?.cgColor
  66. productLabel.font = NSFont.SFProTextRegularFont(13)
  67. if KMMemberInfo.shared.ai_productName == "" {
  68. aiView.isHidden = true
  69. }
  70. aiLabel.textColor = NSColor(named: "42464D")
  71. aiLabel.font = NSFont.SFProTextRegularFont(13)
  72. yesButton.setTitleColor(color: NSColor(named: "000000") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  73. cancelButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  74. }
  75. // MARK: Button Action
  76. @IBAction func cancelButtonAction(_ sender: NSButton) {
  77. self.window?.close()
  78. }
  79. @IBAction func yesButtonAction(_ sender: NSButton) {
  80. self.window?.close()
  81. viewModel.deleteAccountWC()
  82. }
  83. }