KMCreateHeaderFooterController.swift 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // KMCreateHeaderFooterController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2022/12/27.
  6. //
  7. import Cocoa
  8. typealias KMCreateHeaderFooterModelDidChange = (_ model: KMHeaderFooterObject) -> ()
  9. class KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyBaseController {
  10. /// 是否是编辑类型
  11. var isEdit: Bool = false
  12. /// 是否已编辑
  13. var isEdited: Bool = false
  14. var modelDidChange: KMCreateHeaderFooterModelDidChange!
  15. override func viewWillAppear() {
  16. super.viewWillAppear()
  17. let controller: KMHeaderFooterPropertyInfoController = childViewController[0] as! KMHeaderFooterPropertyInfoController
  18. controller.model = self.model as! KMHeaderFooterObject
  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.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])
  26. self.titleLabel.stringValue = NSLocalizedString("Edit HeaderFoote", comment: "")
  27. } else {
  28. self.titleLabel.stringValue = NSLocalizedString("Add HeaderFooter", 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 = KMHeaderFooterPropertyInfoController()
  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! KMHeaderFooterPropertyInfoController).model = self.flagModel?.copy() as! KMHeaderFooterObject
  46. }
  47. }
  48. extension KMCreateHeaderFooterController: KMWatermarkAdjectivePropertyDelegate {
  49. func propertyInfoDidChange(model: AnyObject) {
  50. self.isEdited = true
  51. guard let callback = modelDidChange else {
  52. return
  53. }
  54. callback(model as! KMHeaderFooterObject)
  55. }
  56. }