// // SelectVC.swift // PDF Reader Pro Edition // // Created by Niehaoyu on 2024/9/3. // import Cocoa import KMComponentLibrary class SelectVC: NSViewController { @IBOutlet weak var selectItemView: ComponentSelect! @IBOutlet weak var selectZoom: ComponentSelectZoom! @IBOutlet weak var sizeBox: NSComboBox! @IBOutlet weak var disableBtn: NSButton! @IBOutlet weak var errorBtn: NSButton! @IBOutlet weak var showLeftIcon: NSButton! @IBOutlet weak var placeholderField: NSTextField! @IBOutlet weak var errorField: NSTextField! @IBOutlet weak var createableBtn: NSButton! @IBOutlet weak var itemheightConst: NSLayoutConstraint! @IBOutlet weak var zoomDisableBtn: NSButton! var groupView: ComponentGroup! override func viewDidLoad() { super.viewDidLoad() // Do view setup here. self.sizeBox.selectItem(at: 0) self.reloadData() } func reloadData() { var size: ComponentSize = .m if self.sizeBox.indexOfSelectedItem == 0 { size = .m } else if self.sizeBox.indexOfSelectedItem == 1 { size = .s } else if self.sizeBox.indexOfSelectedItem == 2 { size = .xs } else if self.sizeBox.indexOfSelectedItem == 3 { size = .xxs } let disable = self.disableBtn.state == .on let isError = self.errorBtn.state == .on let lefticon = self.showLeftIcon.state == .on let placeholder = self.placeholderField.stringValue let errorText = self.errorField.stringValue let properties: ComponentSelectProperties = ComponentSelectProperties.init(size: size, state: .normal, isDisabled: disable, isError: isError, leftIcon: lefticon, placeholder: placeholder, errorText: errorText, creatable: self.createableBtn.state == .on) selectItemView.properties = properties self.itemheightConst.constant = selectItemView.properties.propertyInfo.viewHeight var menuItemArr: [ComponentMenuitemProperty] = [] for i in 0...5 { let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false, itemSelected: false, isDisabled: false, keyEquivalent: nil, text: "menu item - " + String(i)) menuItemArr.append(properties_Menuitem) } selectItemView.updateMenuItemsArr(menuItemArr) selectZoom.properties = ComponentSelectZoomProperty(state: .normal, isDisabled: zoomDisableBtn.state == .on, text: "100") } @IBAction func boxAction(_ sender: Any) { self.reloadData() } @IBAction func btnAction(_ sender: Any) { self.reloadData() } }