// // TabsVC.swift // KMComponentLibrary // // Created by Niehaoyu on 2024/9/11. // import Cocoa import KMComponentLibrary class TabsVC: NSViewController { @IBOutlet weak var tabsItem: ComponentTabsItem! @IBOutlet weak var tabsView: ComponentTabs! @IBOutlet weak var typeBox: NSComboBox! @IBOutlet weak var showIconBtn: NSButton! @IBOutlet weak var itemWidthConst: NSLayoutConstraint! @IBOutlet weak var itemHeightConst: NSLayoutConstraint! override func viewDidLoad() { super.viewDidLoad() // Do view setup here. self.typeBox.selectItem(at: 0) self.reloadData() } func reloadData() { var type: ComponentTabsType = .fill if typeBox.indexOfSelectedItem == 0 { type = .underline_Center } else if typeBox.indexOfSelectedItem == 1 { type = .underline_Fill } else if typeBox.indexOfSelectedItem == 2 { type = .onlyText } //tabsItem let properties: ComponentTabsProperty = ComponentTabsProperty(tabsType: type, state: .normal, showIcon: self.showIconBtn.state == .on, title: "Tab Title Item") self.tabsItem.properties = properties self.itemWidthConst.constant = self.tabsItem.properties.propertyInfo.viewWidth //Tabs var itemArr: [ComponentTabsProperty] = [] for i in 0...2 { let property = ComponentTabsProperty(tabsType: type, state: .normal, showIcon: self.showIconBtn.state == .on, title: "Tab Title") if i == 0 { property.state = .pressed } itemArr.append(property) } self.tabsView.updateItemProperty(itemArr) } @IBAction func chooseAction(_ sender: Any) { self.reloadData() } }