LKS_PerspectiveDataSource.h 2.0 KB

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