// // KMPrintSettingView.swift // PDF Reader Pro // // Created by lizhe on 2023/12/4. // import Cocoa typealias KMPrintSettingViewPageSettingChange = (_ view: KMPrintSettingView, _ model: KMPrintModel) -> Void typealias KMPrintSettingViewPrintSettingChange = (_ view: KMPrintSettingView, _ model: KMPrintModel) -> Void class KMPrintSettingView: BaseXibView { @IBOutlet weak var defaultView: KMPrintDefaultView! @IBOutlet weak var posterView: KMPrintPosterView! @IBOutlet weak var multipageView: KMPrintMultipageView! @IBOutlet weak var pamphletView: KMPrintPamphletView! var pageSettingChange: KMPrintSettingViewPageSettingChange? var printSettingChange: KMPrintSettingViewPrintSettingChange? var type: KMPrintModelType = .size { didSet { self.reloadData() } } var printModel: KMPrintModel = KMPrintModel() { didSet { self.defaultView.printModel = printModel self.posterView.printModel = printModel self.multipageView.printModel = printModel self.pamphletView.printModel = printModel } } func setup() { defaultView.pageSettingChange = { [unowned self] view, model in self.pageSettingChange?(self, model) } defaultView.printSettingChange = { [unowned self] view, model in self.printSettingChange?(self, model) } posterView.pageSettingChangeAction = { [unowned self] view, model in self.pageSettingChange?(self, model) } posterView.printSettingChangeAction = { [unowned self] view, model in self.printSettingChange?(self, model) } multipageView.pageSettingChangeAction = { [unowned self] view, model in self.pageSettingChange?(self, model) } multipageView.printSettingChangeAction = { [unowned self] view, model in self.printSettingChange?(self, model) } pamphletView.pageSettingChangeAction = { [unowned self] view, model in self.pageSettingChange?(self, model) } pamphletView.printSettingChangeAction = { [unowned self] view, model in self.printSettingChange?(self, model) } } func reloadData() { self.defaultView.isHidden = true self.posterView.isHidden = true self.multipageView.isHidden = true self.pamphletView.isHidden = true switch type { case .size: self.defaultView.isHidden = false case .poster: self.posterView.isHidden = false case .multipage: self.multipageView.isHidden = false case .pamphlet: self.pamphletView.isHidden = false default: break } } }