KMCloseApplyWC.swift 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // KMCloseApplyWC.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/11/5.
  6. // 手动撤销申请WindowController
  7. //
  8. import Cocoa
  9. class KMCloseApplyWC: NSWindowController {
  10. @IBOutlet weak var titleLabel: NSTextField!
  11. @IBOutlet weak var subTitleLabel: NSTextField!
  12. @IBOutlet weak var yesButton: NSButton!
  13. var currentTime: String = ""
  14. var logOffTime: String = "7"
  15. private var viewModel = KMUserInfoVCModel()
  16. static let shared: KMCloseApplyWC = {
  17. let windowC = KMCloseApplyWC(windowNibName: "KMCloseApplyWC")
  18. return windowC
  19. }()
  20. override func windowDidLoad() {
  21. super.windowDidLoad()
  22. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  23. languageLocalized()
  24. initializeUI()
  25. NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
  26. }
  27. @objc func changeEffectiveAppearance() {
  28. self.initializeUI()
  29. }
  30. // MARK: Private Method
  31. private func languageLocalized() -> Void {
  32. self.window?.title = NSLocalizedString("Remove Account", tableName: "MemberCenterLocalizable", comment: "")
  33. titleLabel.stringValue = NSLocalizedString("Account cancellation application has been submitted", tableName: "MemberCenterLocalizable", comment: "")
  34. subTitleLabel.stringValue = String(format: NSLocalizedString("Your account will be automatically deleted in %@ days. Welcome to use PDF Reader Pro again!\nYou can log in with this account and choose to Undo Remove Account within %ld days, and continue to use. The benefits and product services you enjoy will be retained.", tableName: "MemberCenterLocalizable", comment: ""), logOffTime, logOffTime)
  35. yesButton.title = NSLocalizedString("Got it", tableName: "MemberCenterLocalizable", comment: "")
  36. }
  37. private func initializeUI() -> Void {
  38. self.window?.contentView?.wantsLayer = true
  39. let isDarkModel = KMAdvertisementConfig.isDarkModel()
  40. if isDarkModel {
  41. self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "0E1114").cgColor;
  42. } else {
  43. self.window?.contentView?.layer?.backgroundColor = NSColor(hex: "FFFFFF").cgColor;
  44. }
  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. yesButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  50. }
  51. // MARK: Button Action
  52. @IBAction func yesButtonAction(_ sender: NSButton) {
  53. KMUserInfoVCModel().refreshUserInfo { success, msg in
  54. self.window?.close()
  55. }
  56. }
  57. }