KMCreateBatesController.swift 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // KMCreateBatesController.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2022/12/28.
  6. //
  7. import Cocoa
  8. typealias KMCreateBatesModelDidChange = (_ model: KMBatesModel) -> ()
  9. class KMCreateBatesController: KMWatermarkAdjectivePropertyBaseController {
  10. /// 是否是编辑类型
  11. var isEdit: Bool = false
  12. /// 是否已编辑
  13. var isEdited: Bool = false
  14. var modelDidChange: KMCreateBatesModelDidChange!
  15. override func viewWillAppear() {
  16. super.viewWillAppear()
  17. let controller: KMBatesPropertyInfoController = childViewController[0] as! KMBatesPropertyInfoController
  18. controller.model = self.model as! KMBatesModel
  19. }
  20. override func viewDidLoad() {
  21. super.viewDidLoad()
  22. self.backButtton.title = NSLocalizedString("", comment: "")
  23. self.showBack(show: true)
  24. if (self.isEdit) {
  25. self.titleLabel.stringValue = NSLocalizedString("Edit Bates Number", comment: "")
  26. self.addButton.attributedTitle = NSAttributedString(string: NSLocalizedString("", comment: ""), attributes: [NSAttributedString.Key.foregroundColor : NSColor(red: 24.0/255.0, green: 160.0/255.0, blue: 251.0/255.0, alpha: 1.0),NSAttributedString.Key.font : NSFont.systemFont(ofSize: 12), NSAttributedString.Key.underlineStyle : true])
  27. } else {
  28. self.titleLabel.stringValue = NSLocalizedString("Add Bates Number", comment: "")
  29. self.addButton.attributedTitle = NSAttributedString(string: NSLocalizedString("", comment: ""), attributes: [NSAttributedString.Key.foregroundColor : NSColor(red: 24.0/255.0, green: 160.0/255.0, blue: 251.0/255.0, alpha: 1.0),NSAttributedString.Key.font : NSFont.systemFont(ofSize: 12), NSAttributedString.Key.underlineStyle : true])
  30. }
  31. self.segementControl.isHidden = true
  32. self.segementControlHeightConst.constant = 0
  33. let item = NSTabViewItem(identifier: "tabID")
  34. item.label = "tab1";
  35. let controller = KMBatesPropertyInfoController()
  36. item.viewController = controller
  37. controller.delegate = self
  38. self.tabView.addTabViewItem(item)
  39. childViewController.append(controller)
  40. }
  41. override func resume() {
  42. if (self.needResume() == false) {
  43. return
  44. }
  45. (childViewController[0] as! KMBatesPropertyInfoController).model = self.flagModel?.copy() as! KMBatesModel
  46. }
  47. }
  48. extension KMCreateBatesController: KMWatermarkAdjectivePropertyDelegate {
  49. func propertyInfoDidChange(model: AnyObject) {
  50. self.isEdited = true
  51. guard let callback = modelDidChange else {
  52. return
  53. }
  54. callback(model as! KMBatesModel)
  55. }
  56. }