-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add support for nested global entries #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
63ac9e3
23352da
97cb8c8
813272b
a0ef72c
d667c1f
50116df
7771063
23f0644
730d6f9
e6e9f73
3773272
94b6883
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @class FLEXUserGlobalEntriesContainer; | ||
|
|
||
| typedef NS_ENUM(NSUInteger, FLEXGlobalsRow) { | ||
| FLEXGlobalsRowProcessInfo, | ||
| FLEXGlobalsRowNetworkHistory, | ||
|
|
@@ -51,8 +53,10 @@ typedef UIViewController * _Nullable (^FLEXGlobalsEntryViewControllerFuture)(voi | |
| /// Do something like present an alert, then use the host | ||
| /// view controller to present or push another view controller. | ||
| typedef void (^FLEXGlobalsEntryRowAction)(__kindof UITableViewController * _Nonnull host); | ||
| /// Use the container to register nested global entries. | ||
| typedef void (^FLEXNestedGlobalEntriesHandler)(FLEXUserGlobalEntriesContainer * _Nonnull container); | ||
|
|
||
| /// For view controllers to conform to to indicate they support being used | ||
| /// For view controllers to conform and to indicate they support being used | ||
| /// in the globals table view controller. These methods help create concrete entries. | ||
| /// | ||
| /// Previously, the concrete entries relied on "futures" for the view controller and title. | ||
|
|
@@ -81,15 +85,20 @@ typedef void (^FLEXGlobalsEntryRowAction)(__kindof UITableViewController * _Nonn | |
| @interface FLEXGlobalsEntry : NSObject | ||
|
|
||
| @property (nonatomic, readonly, nonnull) FLEXGlobalsEntryNameFuture entryNameFuture; | ||
| @property (nonatomic, readonly) UITableViewCellAccessoryType cellAccessoryType; | ||
| @property (nonatomic, readonly, nullable) FLEXGlobalsEntryViewControllerFuture viewControllerFuture; | ||
| @property (nonatomic, readonly, nullable) FLEXGlobalsEntryRowAction rowAction; | ||
|
|
||
| + (instancetype)entryWithEntry:(Class<FLEXGlobalsEntry>)entry row:(FLEXGlobalsRow)row; | ||
| + (instancetype)entryWithEntry:(Class<FLEXGlobalsEntry>)entry | ||
| cellAccessoryType:(UITableViewCellAccessoryType)cellAccessoryType | ||
| row:(FLEXGlobalsRow)row; | ||
|
|
||
| + (instancetype)entryWithNameFuture:(FLEXGlobalsEntryNameFuture)nameFuture | ||
| cellAccessoryType:(UITableViewCellAccessoryType)cellAccessoryType | ||
| viewControllerFuture:(FLEXGlobalsEntryViewControllerFuture)viewControllerFuture; | ||
|
|
||
| + (instancetype)entryWithNameFuture:(FLEXGlobalsEntryNameFuture)nameFuture | ||
| cellAccessoryType:(UITableViewCellAccessoryType)cellAccessoryType | ||
| action:(FLEXGlobalsEntryRowAction)rowSelectedAction; | ||
|
Comment on lines
-87
to
102
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition to these new ones, can we keep the original signatures around and have them default to the disclosure indicator? Removing them is a breaking change I'd like to avoid |
||
|
|
||
| @end | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I probably need to just set up a pre-commit linter hook, but in the meantime can we discard all the trailing whitespace changes? |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of the comments on these methods are repeated for each method. Can we just describe the future blocks and their caveats (i.e. the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, can we rename this to |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // | ||
| // FLEXUserGlobalEntriesContainer.h | ||
| // FLEX | ||
| // | ||
| // Created by Iulian Onofrei on 2023-02-10. | ||
| // Copyright © 2023 FLEX Team. All rights reserved. | ||
| // | ||
|
|
||
| #import <UIKit/UIKit.h> | ||
|
|
||
| #import "FLEXGlobalsEntry.h" | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @interface FLEXUserGlobalEntriesContainer : NSObject | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// Call this method before this view controller is displayed. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param objectFutureBlock When you tap on the row, information about the object returned | ||
| /// by this block will be displayed. Passing a block that returns an object allows you to display | ||
| /// information about an object whose actual pointer may change at runtime (e.g. +currentUser) | ||
| /// @note This method must be called from the main thread. | ||
| /// The objectFutureBlock will be invoked from the main thread and may return nil. | ||
| /// @note The passed block will be copied and retain for the duration of the application, | ||
| /// you may want to use __weak references. | ||
| - (void)registerGlobalEntryWithName:(NSString *)entryName objectFutureBlock:(id (^)(void))objectFutureBlock; | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// Call this method before this view controller is displayed. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param cellAccessoryType The accessory type to be used for the cell. | ||
| /// @param objectFutureBlock When you tap on the row, information about the object returned | ||
| /// by this block will be displayed. Passing a block that returns an object allows you to display | ||
| /// information about an object whose actual pointer may change at runtime (e.g. +currentUser) | ||
| /// @note This method must be called from the main thread. | ||
| /// The objectFutureBlock will be invoked from the main thread and may return nil. | ||
| /// @note The passed block will be copied and retain for the duration of the application, | ||
| /// you may want to use __weak references. | ||
| - (void)registerGlobalEntryWithName:(NSString *)entryName | ||
| cellAccessoryType:(UITableViewCellAccessoryType)cellAccessoryType | ||
| objectFutureBlock:(id (^)(void))objectFutureBlock; | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// Call this method before this view controller is displayed. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param viewControllerFutureBlock When you tap on the row, view controller returned | ||
| /// by this block will be pushed on the navigation controller stack. | ||
| /// @note This method must be called from the main thread. | ||
| /// The viewControllerFutureBlock will be invoked from the main thread and may not return nil. | ||
| /// @note The passed block will be copied and retain for the duration of the application, | ||
| /// you may want to use __weak references as needed. | ||
| - (void)registerGlobalEntryWithName:(NSString *)entryName | ||
| viewControllerFutureBlock:(UIViewController * (^)(void))viewControllerFutureBlock; | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// Call this method before this view controller is displayed. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param cellAccessoryType The accessory type to be used for the cell. | ||
| /// @param viewControllerFutureBlock When you tap on the row, view controller returned | ||
| /// by this block will be pushed on the navigation controller stack. | ||
| /// @note This method must be called from the main thread. | ||
| /// The viewControllerFutureBlock will be invoked from the main thread and may not return nil. | ||
| /// @note The passed block will be copied and retain for the duration of the application, | ||
| /// you may want to use __weak references as needed. | ||
| - (void)registerGlobalEntryWithName:(NSString *)entryName | ||
| cellAccessoryType:(UITableViewCellAccessoryType)cellAccessoryType | ||
| viewControllerFutureBlock:(UIViewController * (^)(void))viewControllerFutureBlock; | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param rowSelectedAction When you tap on the row, this block will be invoked | ||
| /// with the host table view view controller. Use it to deselect the row or present an alert. | ||
| /// @note This method must be called from the main thread. | ||
| /// The rowSelectedAction will be invoked from the main thread. | ||
| /// @note The passed block will be copied and retained for the duration of the application, | ||
| /// you may want to use __weak references as needed. | ||
| - (void)registerGlobalEntryWithName:(NSString *)entryName action:(FLEXGlobalsEntryRowAction)rowSelectedAction; | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param cellAccessoryType The accessory type to be used for the cell. | ||
| /// @param rowSelectedAction When you tap on the row, this block will be invoked | ||
| /// with the host table view view controller. Use it to deselect the row or present an alert. | ||
| /// @note This method must be called from the main thread. | ||
| /// The rowSelectedAction will be invoked from the main thread. | ||
| /// @note The passed block will be copied and retained for the duration of the application, | ||
| /// you may want to use __weak references as needed. | ||
| - (void)registerGlobalEntryWithName:(NSString *)entryName | ||
| cellAccessoryType:(UITableViewCellAccessoryType)cellAccessoryType | ||
| action:(FLEXGlobalsEntryRowAction)rowSelectedAction; | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param nestedEntriesHandler When you tap on the row, this block will be invoked | ||
| /// with the container object. Use it to register nested entries. | ||
| /// @note This method must be called from the main thread. | ||
| /// The nestedEntriesHandler will be invoked from the main thread. | ||
| /// @note The passed block will be copied and retained for the duration of the application, | ||
| /// you may want to use __weak references as needed. | ||
| - (void)registerNestedGlobalEntryWithName:(NSString *)entryName handler:(FLEXNestedGlobalEntriesHandler)nestedEntriesHandler; | ||
|
|
||
| /// Adds an entry at the top of the list of Global State items. | ||
| /// @param entryName The string to be displayed in the cell. | ||
| /// @param cellAccessoryType The accessory type to be used for the cell. | ||
| /// @param nestedEntriesHandler When you tap on the row, this block will be invoked | ||
| /// with the container object. Use it to register nested entries. | ||
| /// @note This method must be called from the main thread. | ||
| /// The nestedEntriesHandler will be invoked from the main thread. | ||
| /// @note The passed block will be copied and retained for the duration of the application, | ||
| /// you may want to use __weak references as needed. | ||
| - (void)registerNestedGlobalEntryWithName:(NSString *)entryName | ||
| cellAccessoryType:(UITableViewCellAccessoryType)cellAccessoryType | ||
| handler:(FLEXNestedGlobalEntriesHandler)nestedEntriesHandler; | ||
|
|
||
| /// Removes all registered global entries. | ||
| - (void)clearGlobalEntries; | ||
|
Comment on lines
+116
to
+117
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this method necessary at all? I'm having a hard time imagining a scenario in which you'd want to un-register everything, or anything for that matter |
||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this little dance each time we create one of these, can we just add a convenience init that does this for us so that it becomes
[FLEXGlobalsViewController newWithCustomEntries]or something? It can even have thatBOOLparameter if you think that's useful