FLEXGlobalsEntry.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // FLEXGlobalsEntry.h
  3. // FLEX
  4. //
  5. // Created by Javier Soto on 7/26/14.
  6. // Copyright (c) 2014 f. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "FLEXTableViewSection.h"
  10. @class FLEXGlobalsTableViewController;
  11. typedef NS_ENUM(NSUInteger, FLEXGlobalsRow) {
  12. FLEXGlobalsRowProcessInfo,
  13. FLEXGlobalsRowNetworkHistory,
  14. FLEXGlobalsRowSystemLog,
  15. FLEXGlobalsRowLiveObjects,
  16. FLEXGlobalsRowAddressInspector,
  17. FLEXGlobalsRowCookies,
  18. FLEXGlobalsRowSystemLibraries,
  19. FLEXGlobalsRowAppClasses,
  20. FLEXGlobalsRowAppDelegate,
  21. FLEXGlobalsRowRootViewController,
  22. FLEXGlobalsRowUserDefaults,
  23. FLEXGlobalsRowMainBundle,
  24. FLEXGlobalsRowBrowseBundle,
  25. FLEXGlobalsRowBrowseContainer,
  26. FLEXGlobalsRowApplication,
  27. FLEXGlobalsRowKeyWindow,
  28. FLEXGlobalsRowMainScreen,
  29. FLEXGlobalsRowCurrentDevice,
  30. FLEXGlobalsRowPasteboard,
  31. FLEXGlobalsRowCount
  32. };
  33. typedef NSString *(^FLEXGlobalsEntryNameFuture)(void);
  34. /// Simply return a view controller to be pushed on the navigation stack
  35. typedef UIViewController *(^FLEXGlobalsTableViewControllerViewControllerFuture)(void);
  36. /// Do something like present an alert, then use the host
  37. /// view controller to present or push another view controller.
  38. typedef void (^FLEXGlobalsTableViewControllerRowAction)(FLEXGlobalsTableViewController *host);
  39. /// For view controllers to conform to to indicate they support being used
  40. /// in the globals table view controller. These methods help create concrete entries.
  41. ///
  42. /// Previously, the concrete entries relied on "futures" for the view controller and title.
  43. /// With this protocol, the conforming class itself can act as a future, since the methods
  44. /// will not be invoked until the title and view controller / row action are needed.
  45. @protocol FLEXGlobalsEntry <NSObject>
  46. + (NSString *)globalsEntryTitle:(FLEXGlobalsRow)row;
  47. // Must respond to at least one of the below
  48. @optional
  49. + (UIViewController *)globalsEntryViewController:(FLEXGlobalsRow)row;
  50. + (FLEXGlobalsTableViewControllerRowAction)globalsEntryRowAction:(FLEXGlobalsRow)row;
  51. @end
  52. @interface FLEXGlobalsEntry : NSObject <FLEXPatternMatching>
  53. @property (nonatomic, readonly) FLEXGlobalsEntryNameFuture entryNameFuture;
  54. @property (nonatomic, readonly) FLEXGlobalsTableViewControllerViewControllerFuture viewControllerFuture;
  55. @property (nonatomic, readonly) FLEXGlobalsTableViewControllerRowAction rowAction;
  56. + (instancetype)entryWithEntry:(Class<FLEXGlobalsEntry>)entry row:(FLEXGlobalsRow)row;
  57. + (instancetype)entryWithNameFuture:(FLEXGlobalsEntryNameFuture)nameFuture viewControllerFuture:(FLEXGlobalsTableViewControllerViewControllerFuture)viewControllerFuture;
  58. + (instancetype)entryWithNameFuture:(FLEXGlobalsEntryNameFuture)nameFuture action:(FLEXGlobalsTableViewControllerRowAction)rowSelectedAction;
  59. @end
  60. @interface NSObject (FLEXGlobalsEntry)
  61. /// @return The result of passing self to +[FLEXGlobalsEntry entryWithEntry:]
  62. /// if the class conforms to FLEXGlobalsEntry, else, nil.
  63. + (FLEXGlobalsEntry *)flex_concreteGlobalsEntry:(FLEXGlobalsRow)row;
  64. @end