KMCloseAccountWC.swift 4.7 KB

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