ListVC.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // ListVC.swift
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by Niehaoyu on 2024/9/23.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. class ListVC: NSViewController {
  10. @IBOutlet weak var listBasicItem: ComponentListBasicItem!
  11. @IBOutlet weak var showSortBtn: NSButton!
  12. @IBOutlet weak var showLefticon: NSButton!
  13. @IBOutlet weak var showRightIconBtn: NSButton!
  14. @IBOutlet weak var disableBtn: NSButton!
  15. @IBOutlet weak var floatingToolbarShowBtn: NSButton!
  16. var basicProperty: ComponentListBasicItemProperty = ComponentListBasicItemProperty()
  17. var floatingToolbar: ComponentFloatingToolbar = ComponentFloatingToolbar()
  18. override func viewDidLoad() {
  19. super.viewDidLoad()
  20. // Do view setup here.
  21. self.listBasicItem.properties = basicProperty
  22. self.reloadData()
  23. }
  24. func reloadData() {
  25. self.listBasicItem.properties.showSort = self.showSortBtn.state == .on
  26. if self.showLefticon.state == .on {
  27. self.listBasicItem.properties.leftIcon = ComponentLibrary.shared.image(forResource: "segmented_active")
  28. } else {
  29. self.listBasicItem.properties.leftIcon = nil
  30. }
  31. if self.showRightIconBtn.state == .on {
  32. self.listBasicItem.properties.rightIcon = ComponentLibrary.shared.image(forResource: "segmented_active")
  33. } else {
  34. self.listBasicItem.properties.rightIcon = nil
  35. }
  36. self.listBasicItem.properties.text = "XXXX XXXX"
  37. self.listBasicItem.properties.isDisable = self.disableBtn.state == .on
  38. self.listBasicItem.reloadData()
  39. }
  40. @IBAction func buttonClicked(_ sender: Any) {
  41. self.reloadData()
  42. }
  43. @IBAction func showFloatingToolbar(_ sender: Any) {
  44. self.floatingToolbar.frame = CGRectMake(0, 0, 200, 40)
  45. self.floatingToolbar.showWithPoint(CGPoint(x: self.floatingToolbarShowBtn.frame.origin.x + 40, y: self.floatingToolbarShowBtn.frame.origin.y + 80), inView: self.view)
  46. }
  47. }