FLEXCollectionContentSection.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // FLEXCollectionContentSection.h
  3. // FLEX
  4. //
  5. // Created by Tanner Bennett on 8/28/19.
  6. // Copyright © 2019 Flipboard. All rights reserved.
  7. //
  8. #import "FLEXTableViewSection.h"
  9. #import "FLEXObjectInfoSection.h"
  10. @class FLEXCollectionContentSection;
  11. @protocol FLEXCollection;
  12. typedef id<FLEXCollection>(^FLEXCollectionContentFuture)(__kindof FLEXCollectionContentSection *section);
  13. #pragma mark Collection
  14. /// A protocol that enables \c FLEXCollectionContentSection to operate on any arbitrary collection.
  15. /// \c NSArray, \c NSDictionary, \c NSSet, and \c NSOrderedSet all conform to this protocol.
  16. @protocol FLEXCollection <NSObject, NSFastEnumeration>
  17. @property (nonatomic, readonly) NSUInteger count;
  18. - (id)copy;
  19. - (id)mutableCopy;
  20. @optional
  21. /// Unordered, unkeyed collections must implement this
  22. @property (nonatomic, readonly) NSArray *allObjects;
  23. /// Keyed collections must implement this and \c objectForKeyedSubscript:
  24. @property (nonatomic, readonly) NSArray *allKeys;
  25. /// Ordered, indexed collections must implement this.
  26. - (id)objectAtIndexedSubscript:(NSUInteger)idx;
  27. /// Keyed, unordered collections must implement this and \c allKeys
  28. - (id)objectForKeyedSubscript:(id)idx;
  29. @end
  30. @interface NSArray (FLEXCollection) <FLEXCollection> @end
  31. @interface NSDictionary (FLEXCollection) <FLEXCollection> @end
  32. @interface NSSet (FLEXCollection) <FLEXCollection> @end
  33. @interface NSOrderedSet (FLEXCollection) <FLEXCollection> @end
  34. #pragma mark - FLEXCollectionContentSection
  35. /// A custom section for viewing collection elements.
  36. ///
  37. /// Tapping on a row pushes an object explorer for that element.
  38. @interface FLEXCollectionContentSection : FLEXTableViewSection <FLEXObjectInfoSection>
  39. + (instancetype)forCollection:(id<FLEXCollection>)collection;
  40. /// The future given should be safe to call more than once.
  41. /// The result of calling this future multiple times may yield
  42. /// different results each time if the data is changing by nature.
  43. + (instancetype)forReusableFuture:(FLEXCollectionContentFuture)collectionFuture;
  44. @end