KMCancellationSuccessView.swift 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // KMCancellationSuccessView.swift
  3. // PDF Master
  4. //
  5. // Created by lizhe on 2023/4/20.
  6. //
  7. import Cocoa
  8. typealias KMCancellationSuccessViewCancelAction = (_ view: KMCancellationSuccessView) -> Void
  9. class KMCancellationSuccessView: KMBaseXibView {
  10. @IBOutlet weak var closeBox: KMBox!
  11. @IBOutlet weak var closeButton: NSButton!
  12. @IBOutlet weak var titleLabel: NSTextField!
  13. @IBOutlet weak var subTitleLabel: NSTextField!
  14. @IBOutlet weak var doneView: NSView!
  15. var doneButtonVC: KMDesignButton!
  16. var cancelAction: KMCancellationSuccessViewCancelAction?
  17. override func draw(_ dirtyRect: NSRect) {
  18. super.draw(dirtyRect)
  19. // Drawing code here.
  20. }
  21. override func setup() {
  22. super.setup()
  23. self.closeBox.moveCallback = { [weak self] (mouseEntered, mouseBox) in
  24. if mouseEntered {
  25. self?.closeButton?.image = NSImage(named: "control_btn_icon_close_hov")
  26. } else {
  27. self?.closeButton?.image = NSImage(named: "control_btn_icon_close")
  28. }
  29. }
  30. self.titleLabel.font = NSFont.SFProTextSemiboldFont(19.0)
  31. self.titleLabel.textColor = NSColor.km_init(hex: "#252629")
  32. self.subTitleLabel.font = NSFont.SFProTextRegularFont(14.0)
  33. self.subTitleLabel.textColor = NSColor.km_init(hex: "#616469")
  34. self.subTitleLabel.maximumNumberOfLines = 0
  35. self.doneButtonVC = KMDesignButton(withType: .Text)
  36. self.doneView.addSubview(self.doneButtonVC.view)
  37. self.doneButtonVC?.view.frame = self.doneView.bounds
  38. self.doneButtonVC.target = self
  39. self.doneButtonVC.action = #selector(closeButtonAction)
  40. self.doneButtonVC.button(type: .Cta, size: .m)
  41. self.doneButtonVC.button.keyEquivalent = KMKeyEquivalent.enter
  42. self.doneButtonVC.stringValue = NSLocalizedString("OK", comment: "")
  43. self.doneButtonVC.updateUI()
  44. }
  45. override func reloadData() {
  46. super.reloadData()
  47. }
  48. override func updateLanguage() {
  49. super.updateLanguage()
  50. self.titleLabel.stringValue = NSLocalizedString("Cancellation Submitted", comment: "")
  51. self.subTitleLabel.stringValue = NSLocalizedString("Your account will be canceled within 3 working days and there is no need to submit the application for cancellation again", comment: "")
  52. self.doneButtonVC.stringValue = NSLocalizedString("OK", comment: "")
  53. }
  54. }
  55. extension KMCancellationSuccessView {
  56. @IBAction func closeButtonAction(_ sender: Any) {
  57. guard let callBack = cancelAction else { return }
  58. callBack(self)
  59. }
  60. }