KMLogoutPromptWC.swift 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // KMMemberPromptWC.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/11/4.
  6. //
  7. import Cocoa
  8. @objc enum KMMemberTipType : Int {
  9. case logout = 0 // 验证码
  10. case unsubscribe // 注销账户 存在会员中
  11. case signout // 注销账户
  12. }
  13. class KMMemberPromptWC: NSWindowController {
  14. @IBOutlet weak var titleLabel: NSTextField!
  15. @IBOutlet weak var subTitleLabel: NSTextField!
  16. @IBOutlet weak var cancelButton: NSButton!
  17. @IBOutlet weak var yesButton: NSButton!
  18. private var viewModel = KMUserInfoVCModel()
  19. var tipType: KMMemberTipType = .logout
  20. static let shared: KMMemberPromptWC = {
  21. let windowC = KMMemberPromptWC(windowNibName: "KMMemberPromptWC")
  22. return windowC
  23. }()
  24. override func windowDidLoad() {
  25. super.windowDidLoad()
  26. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  27. languageLocalized()
  28. initializeUI()
  29. }
  30. // MARK: Private Method
  31. private func languageLocalized() -> Void {
  32. var title = ""
  33. var subTitle = ""
  34. var cance = ""
  35. var yes = ""
  36. if tipType == .logout {
  37. title = "退出登录"
  38. subTitle = "确定要退出当前账号吗?"
  39. cance = "Cancel"
  40. yes = "Yes"
  41. } else if tipType == .unsubscribe {
  42. title = "提示"
  43. subTitle = "您当前处于会员订阅中,以防下个周期继续扣费,请先在支付平台取消订阅后,再操作注销账户"
  44. yes = "知道了"
  45. } else if tipType == .signout {
  46. title = "警告"
  47. subTitle = "注销账号会永久删除一切账号数据,包括您在此账号下购买的其他端的PDF Reader Pro的权益。您确定要继续吗?"
  48. cance = "Cancel"
  49. yes = "Yes"
  50. }
  51. titleLabel.stringValue = NSLocalizedString(title, tableName: "MemberCenterLocalizable", comment: "")
  52. subTitleLabel.stringValue = NSLocalizedString(subTitle, tableName: "MemberCenterLocalizable", comment: "")
  53. cancelButton.title = NSLocalizedString(cance, tableName: "MemberCenterLocalizable", comment: "")
  54. yesButton.title = NSLocalizedString(yes, tableName: "MemberCenterLocalizable", comment: "")
  55. }
  56. private func initializeUI() -> Void {
  57. if tipType == .logout {
  58. titleLabel.textColor = NSColor(named: "000000_0.85")
  59. titleLabel.font = NSFont.SFProTextSemiboldFont(13)
  60. subTitleLabel.textColor = NSColor(named: "000000_0.85")
  61. subTitleLabel.font = NSFont.SFProTextRegularFont(12)
  62. cancelButton.setTitleColor(color: NSColor(named: "000000") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  63. yesButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  64. } else if tipType == .unsubscribe {
  65. titleLabel.textColor = NSColor(named: "000000_0.85")
  66. titleLabel.font = NSFont.SFProTextSemiboldFont(13)
  67. subTitleLabel.textColor = NSColor(named: "000000_0.85")
  68. subTitleLabel.font = NSFont.SFProTextRegularFont(12)
  69. cancelButton.isHidden = true
  70. yesButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  71. } else if tipType == .signout {
  72. titleLabel.textColor = NSColor(named: "000000_0.85")
  73. titleLabel.font = NSFont.SFProTextSemiboldFont(13)
  74. subTitleLabel.textColor = NSColor(named: "000000_0.85")
  75. subTitleLabel.font = NSFont.SFProTextRegularFont(12)
  76. cancelButton.setTitleColor(color: NSColor(named: "000000") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  77. yesButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
  78. }
  79. }
  80. // MARK: Button Action
  81. @IBAction func cancelButtonAction(_ sender: NSButton) {
  82. self.window?.close()
  83. viewModel.expandPersonalCenter()
  84. }
  85. @IBAction func yesButtonAction(_ sender: NSButton) {
  86. self.window?.close()
  87. viewModel.confirmExitAction()
  88. }
  89. }