KMCloseAccountWC.swift 3.9 KB

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