LKS_PerspectiveDataSource.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifdef SHOULD_COMPILE_LOOKIN_SERVER
  2. //
  3. // LKS_PerspectiveDataSource.h
  4. // LookinServer
  5. //
  6. // Created by Li Kai on 2019/5/17.
  7. // https://lookin.work
  8. //
  9. #import "LookinDefines.h"
  10. @class LookinHierarchyInfo, LookinDisplayItem, LKS_PerspectiveDataSource;
  11. @protocol LKS_PerspectiveDataSourceDelegate <NSObject>
  12. @optional
  13. - (void)dataSourceDidChangeSelectedItem:(LKS_PerspectiveDataSource *)dataSource;
  14. - (void)dataSourceDidChangeDisplayItems:(LKS_PerspectiveDataSource *)dataSource;
  15. - (void)dataSourceDidChangeNoPreview:(LKS_PerspectiveDataSource *)dataSource;
  16. @end
  17. @interface LKS_PerspectiveDataSource : NSObject
  18. @property(nonatomic, weak) id<LKS_PerspectiveDataSourceDelegate> perspectiveLayer;
  19. @property(nonatomic, weak) id<LKS_PerspectiveDataSourceDelegate> hierarchyView;
  20. - (instancetype)initWithHierarchyInfo:(LookinHierarchyInfo *)info;
  21. /// 一维数组,包含所有 hierarchy 树中可见和不可见的 displayItems
  22. @property(nonatomic, copy, readonly) NSArray<LookinDisplayItem *> *flatItems;
  23. /// 一维数组,只包括在 hierarchy 树中可见的 displayItems
  24. @property(nonatomic, copy, readonly) NSArray<LookinDisplayItem *> *displayingFlatItems;
  25. /// 当前应该被显示的 rows 行数
  26. - (NSInteger)numberOfRows;
  27. /// 获取指定行的 item
  28. - (LookinDisplayItem *)itemAtRow:(NSInteger)index;
  29. /// 获取指定 item 的 row,可能为 NSNotFound
  30. - (NSInteger)rowForItem:(LookinDisplayItem *)item;
  31. /// 当前选中的 item
  32. @property(nonatomic, weak) LookinDisplayItem *selectedItem;
  33. /// 将 item 折叠起来,如果该 item 没有 subitems 或已经被折叠,则该方法不起任何作用
  34. - (void)collapseItem:(LookinDisplayItem *)item;
  35. /// 将 item 展开,如果该 item 没有 subitems 或已经被展开,则该方法不起任何作用
  36. - (void)expandItem:(LookinDisplayItem *)item;
  37. /// 某个颜色的业务别名,如果不存在则返回 nil
  38. - (NSArray<NSString *> *)aliasForColor:(UIColor *)color;
  39. @property(nonatomic, strong, readonly) LookinHierarchyInfo *rawHierarchyInfo;
  40. @end
  41. #endif /* SHOULD_COMPILE_LOOKIN_SERVER */