FLEXRuntime+UIKitHelpers.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // FLEXRuntime+UIKitHelpers.h
  3. // FLEX
  4. //
  5. // Created by Tanner Bennett on 12/16/19.
  6. // Copyright © 2019 Flipboard. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "FLEXProperty.h"
  10. #import "FLEXIvar.h"
  11. #import "FLEXMethod.h"
  12. #import "FLEXProtocol.h"
  13. @protocol FLEXRuntimeMetadata <NSObject>
  14. /// Used as the main title of the row
  15. - (NSString *)description;
  16. /// Used to compare metadata objects for uniqueness
  17. @property (nonatomic, readonly) NSString *name;
  18. /// YES for properties and ivars which surely support editing, NO for all methods.
  19. @property (nonatomic, readonly) BOOL isEditable;
  20. /// NO for ivars, YES for supported methods and properties
  21. @property (nonatomic, readonly) BOOL isCallable;
  22. /// For internal use
  23. @property (nonatomic) id tag;
  24. /// Should return \c nil if not applicable
  25. - (id)currentValueWithTarget:(id)object;
  26. /// Used as the subtitle or description of a property, ivar, or method
  27. - (NSString *)previewWithTarget:(id)object;
  28. /// For methods, a method calling screen. For all else, an object explorer.
  29. - (UIViewController *)viewerWithTarget:(id)object;
  30. /// For methods and protocols, nil. For all else, an a field editor screen.
  31. - (UIViewController *)editorWithTarget:(id)object;
  32. /// Used to determine present which interactions are possible to the user
  33. - (UITableViewCellAccessoryType)suggestedAccessoryTypeWithTarget:(id)object;
  34. /// Return nil to use the default reuse identifier
  35. - (NSString *)reuseIdentifierWithTarget:(id)object;
  36. @end
  37. // Even if a property is readonly, it still may be editable
  38. // via a setter. Checking isEditable will not reflect that
  39. // unless the property was initialized with a class.
  40. @interface FLEXProperty (UIKitHelpers) <FLEXRuntimeMetadata> @end
  41. @interface FLEXIvar (UIKitHelpers) <FLEXRuntimeMetadata> @end
  42. @interface FLEXMethodBase (UIKitHelpers) <FLEXRuntimeMetadata> @end
  43. @interface FLEXMethod (UIKitHelpers) <FLEXRuntimeMetadata> @end
  44. @interface FLEXProtocol (UIKitHelpers) <FLEXRuntimeMetadata> @end
  45. typedef NS_ENUM(NSUInteger, FLEXStaticMetadataRowStyle)
  46. {
  47. FLEXStaticMetadataRowStyleSubtitle,
  48. FLEXStaticMetadataRowStyleKeyValue,
  49. FLEXStaticMetadataRowStyleDefault = FLEXStaticMetadataRowStyleSubtitle,
  50. };
  51. /// Displays a small row as a static key-value pair of information.
  52. @interface FLEXStaticMetadata : NSObject <FLEXRuntimeMetadata>
  53. + (instancetype)style:(FLEXStaticMetadataRowStyle)style title:(NSString *)title string:(NSString *)string;
  54. + (instancetype)style:(FLEXStaticMetadataRowStyle)style title:(NSString *)title number:(NSNumber *)number;
  55. @end