1919 * under the License.
2020 */
2121
22- #import < UIKit/UIKit.h>
23-
24- #import " HUBComponentType.h"
22+ #import " HUBHeaderMacros.h"
2523#import " HUBComponentLayoutTraits.h"
24+ #import " HUBComponentType.h"
2625#import " HUBScrollPosition.h"
2726
28- @protocol HUBViewController;
2927@protocol HUBViewModel;
30- @protocol HUBComponent;
3128@protocol HUBComponentModel;
29+ @protocol HUBImageLoader;
30+ @protocol HUBContentReloadPolicy;
31+ @protocol HUBComponentLayoutManager;
32+ @protocol HUBActionHandler;
33+ @protocol HUBViewControllerScrollHandler;
34+ @protocol HUBComponentRegistry;
35+ @class HUBViewController;
36+ @class HUBViewModelLoaderImplementation;
37+ @class HUBCollectionViewFactory;
38+ @class HUBInitialViewModelRegistry;
39+ @class HUBActionRegistryImplementation;
3240
3341NS_ASSUME_NONNULL_BEGIN
3442
@@ -48,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
4856 * You can use this method to perform any custom UI operations on the whole view controller right before
4957 * a new model will be rendered.
5058 */
51- - (void )viewController : (UIViewController< HUBViewController> *)viewController willUpdateWithViewModel : (id <HUBViewModel>)viewModel ;
59+ - (void )viewController : (HUBViewController *)viewController willUpdateWithViewModel : (id <HUBViewModel>)viewModel ;
5260
5361/* *
5462 * Sent to a Hub Framework view controller's delegate when it was updated with a new view model
@@ -58,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
5866 * You can use this method to perform any custom UI operations on the whole view controller when a new
5967 * view model has been rendered.
6068 */
61- - (void )viewControllerDidUpdate : (UIViewController< HUBViewController> *)viewController ;
69+ - (void )viewControllerDidUpdate : (HUBViewController *)viewController ;
6270
6371/* *
6472 * Sent to a Hub Framework view controller's delegate when it failed to be updated because of an error
@@ -71,17 +79,17 @@ NS_ASSUME_NONNULL_BEGIN
7179 *
7280 * Note that you can also use content operations (`HUBContentOperation`) to react to errors, and adjust the UI.
7381 */
74- - (void )viewController : (UIViewController< HUBViewController> *)viewController didFailToUpdateWithError : (NSError *)error ;
82+ - (void )viewController : (HUBViewController *)viewController didFailToUpdateWithError : (NSError *)error ;
7583
7684/* *
7785 * Sent to a Hub Framework view controller's delegate when the view finished rendering, due to a view model update.
78-
86+
7987 * @param viewController The view controller that finished rendering.
8088 *
8189 * You can use this method to perform any custom UI operations on the whole view controller right after
8290 * a new view model was rendered.
8391 */
84- - (void )viewControllerDidFinishRendering : (UIViewController< HUBViewController> *)viewController ;
92+ - (void )viewControllerDidFinishRendering : (HUBViewController *)viewController ;
8593
8694/* *
8795 * Sent to a Hub Framework view controller's delegate to ask it whenever the view controller should start scrolling
@@ -91,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
9199 * This method can be used to veto a scroll event from being started. It will be called every time the user starts
92100 * scrolling the view that is rendering body components.
93101 */
94- - (BOOL )viewControllerShouldStartScrolling : (UIViewController< HUBViewController> *)viewController ;
102+ - (BOOL )viewControllerShouldStartScrolling : (HUBViewController *)viewController ;
95103
96104/* *
97105 * Sent to a Hub Framework view controller's delegate when a component is about to appear on the screen
@@ -101,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
101109 * @param layoutTraits The layout traits of the component that is about to appear
102110 * @param componentView The view that the component is about to appear in
103111 */
104- - (void )viewController : (UIViewController< HUBViewController> *)viewController
112+ - (void )viewController : (HUBViewController *)viewController
105113 componentWithModel : (id <HUBComponentModel>)componentModel
106114 layoutTraits : (NSSet <HUBComponentLayoutTrait> *)layoutTraits
107115 willAppearInView : (UIView *)componentView ;
@@ -114,7 +122,7 @@ NS_ASSUME_NONNULL_BEGIN
114122 * @param layoutTraits The layout traits of the component that disappeared
115123 * @param componentView The view that the component disappeared from
116124 */
117- - (void )viewController : (UIViewController< HUBViewController> *)viewController
125+ - (void )viewController : (HUBViewController *)viewController
118126 componentWithModel : (id <HUBComponentModel>)componentModel
119127 layoutTraits : (NSSet <HUBComponentLayoutTrait> *)layoutTraits
120128 didDisappearFromView : (UIView *)componentView ;
@@ -125,17 +133,19 @@ NS_ASSUME_NONNULL_BEGIN
125133 * @param viewController The view controller in which the component was selected
126134 * @param componentModel The model of the component that was selected
127135 */
128- - (void )viewController : (UIViewController< HUBViewController> *)viewController componentSelectedWithModel : (id <HUBComponentModel>)componentModel ;
136+ - (void )viewController : (HUBViewController *)viewController componentSelectedWithModel : (id <HUBComponentModel>)componentModel ;
129137
130138@end
131139
132140/* *
133- * Protocol defining the public API of a Hub Framework view controller
141+ * View controller used to render a Hub Framework-powered view
142+ *
143+ * You don't create instances of this class directly. Instead, you use `HUBViewControllerFactory` to do so.
134144 *
135- * You don't conform to this protocol yourself, instead the Hub Framework will create view controllers conforming
136- * to this protocol through `HUBViewControllerFactory `.
145+ * This view controller renders `HUBComponent` instances using a collection view. What components that are rendered
146+ * are determined by `HUBContentOperation`s that build a `HUBViewModel `.
137147 */
138- @protocol HUBViewController < NSObject >
148+ @interface HUBViewController : UIViewController
139149
140150// / The view controller's delegate. See `HUBViewControllerDelegate` for more information.
141151@property (nonatomic , weak , nullable ) id <HUBViewControllerDelegate> delegate;
@@ -193,15 +203,16 @@ NS_ASSUME_NONNULL_BEGIN
193203 * @param indexPath The index path of the component to scroll to.
194204 * @param scrollPosition The preferred position of the component after scrolling.
195205 * @param animated Whether or not the scrolling should be animated.
196- * @param completion A block that is called once the component at the provided index path is visible.
206+ * @param completion A block that is called for each step of the scrolling, providing the index path of the component
207+ * that became visible.
197208 *
198209 * @seealso HUBComponentWithScrolling
199210 */
200211- (void )scrollToComponentOfType : (HUBComponentType)componentType
201212 indexPath : (NSIndexPath *)indexPath
202213 scrollPosition : (HUBScrollPosition)scrollPosition
203214 animated : (BOOL )animated
204- completion : (void (^ _Nullable)(void ))completion ;
215+ completion : (void (^ _Nullable)(NSIndexPath * ))completion ;
205216
206217/* *
207218 * Returns the views of the components of the given type that are currently visible on screen, keyed by their index path
@@ -251,6 +262,21 @@ NS_ASSUME_NONNULL_BEGIN
251262 */
252263- (void )cancelComponentSelection ;
253264
265+ #pragma mark - Unavailable initializers
266+
267+ // / Use `HUBViewControllerFactory` to create instances of this class
268+ + (instancetype )new NS_UNAVAILABLE;
269+
270+ // / Use `HUBViewControllerFactory` to create instances of this class
271+ - (instancetype )init NS_UNAVAILABLE;
272+
273+ // / Use `HUBViewControllerFactory` to create instances of this class
274+ - (instancetype )initWithCoder : (NSCoder *)decoder NS_UNAVAILABLE;
275+
276+ // / Use `HUBViewControllerFactory` to create instances of this class
277+ - (instancetype )initWithNibName : (nullable NSString *)nibNameOrNil
278+ bundle : (nullable NSBundle *)nibBundleOrNil NS_UNAVAILABLE;
279+
254280@end
255281
256282NS_ASSUME_NONNULL_END
0 commit comments