123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- //
- // KMMemberPromptWC.swift
- // PDF Reader Pro
- //
- // Created by wanjun on 2024/11/4.
- //
- import Cocoa
- @objc enum KMMemberTipType : Int {
- case logout = 0 // 验证码
- case unsubscribe // 注销账户 存在会员中
- case signout // 注销账户
- }
- class KMMemberPromptWC: NSWindowController {
-
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var subTitleLabel: NSTextField!
- @IBOutlet weak var cancelButton: NSButton!
- @IBOutlet weak var yesButton: NSButton!
- private var viewModel = KMUserInfoVCModel()
-
- var tipType: KMMemberTipType = .logout
-
- static let shared: KMMemberPromptWC = {
- let windowC = KMMemberPromptWC(windowNibName: "KMMemberPromptWC")
- return windowC
- }()
- override func windowDidLoad() {
- super.windowDidLoad()
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
-
- languageLocalized()
- initializeUI()
- }
-
- // MARK: Private Method
-
- private func languageLocalized() -> Void {
- var title = ""
- var subTitle = ""
- var cance = ""
- var yes = ""
- if tipType == .logout {
- title = "退出登录"
- subTitle = "确定要退出当前账号吗?"
- cance = "Cancel"
- yes = "Yes"
- } else if tipType == .unsubscribe {
- title = "提示"
- subTitle = "您当前处于会员订阅中,以防下个周期继续扣费,请先在支付平台取消订阅后,再操作注销账户"
- yes = "知道了"
- } else if tipType == .signout {
- title = "警告"
- subTitle = "注销账号会永久删除一切账号数据,包括您在此账号下购买的其他端的PDF Reader Pro的权益。您确定要继续吗?"
- cance = "Cancel"
- yes = "Yes"
- }
- titleLabel.stringValue = NSLocalizedString(title, tableName: "MemberCenterLocalizable", comment: "")
- subTitleLabel.stringValue = NSLocalizedString(subTitle, tableName: "MemberCenterLocalizable", comment: "")
- cancelButton.title = NSLocalizedString(cance, tableName: "MemberCenterLocalizable", comment: "")
- yesButton.title = NSLocalizedString(yes, tableName: "MemberCenterLocalizable", comment: "")
- }
-
- private func initializeUI() -> Void {
- if tipType == .logout {
- titleLabel.textColor = NSColor(named: "000000_0.85")
- titleLabel.font = NSFont.SFProTextSemiboldFont(13)
- subTitleLabel.textColor = NSColor(named: "000000_0.85")
- subTitleLabel.font = NSFont.SFProTextRegularFont(12)
- cancelButton.setTitleColor(color: NSColor(named: "000000") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
- yesButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
- } else if tipType == .unsubscribe {
- titleLabel.textColor = NSColor(named: "000000_0.85")
- titleLabel.font = NSFont.SFProTextSemiboldFont(13)
- subTitleLabel.textColor = NSColor(named: "000000_0.85")
- subTitleLabel.font = NSFont.SFProTextRegularFont(12)
- cancelButton.isHidden = true
- yesButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
- } else if tipType == .signout {
- titleLabel.textColor = NSColor(named: "000000_0.85")
- titleLabel.font = NSFont.SFProTextSemiboldFont(13)
- subTitleLabel.textColor = NSColor(named: "000000_0.85")
- subTitleLabel.font = NSFont.SFProTextRegularFont(12)
- cancelButton.setTitleColor(color: NSColor(named: "000000") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
- yesButton.setTitleColor(color: NSColor(named: "FFFFFF") ?? NSColor.white, font: NSFont.SFProTextRegularFont(13))
- }
- }
-
- // MARK: Button Action
-
- @IBAction func cancelButtonAction(_ sender: NSButton) {
- self.window?.close()
- viewModel.expandPersonalCenter()
- }
-
- @IBAction func yesButtonAction(_ sender: NSButton) {
- self.window?.close()
- viewModel.confirmExitAction()
- }
- }
|