Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.

Commit 8d185e7

Browse files
authored
Merge branch 'master' into update-parent-on-reuse
2 parents 72af976 + a898497 commit 8d185e7

18 files changed

+171
-152
lines changed

HubFramework.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
8AD0645E1C64F45A0086C081 /* HUBConnectivityStateResolverMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0645C1C64F4510086C081 /* HUBConnectivityStateResolverMock.m */; };
9191
8AD064601C64F5460086C081 /* HUBViewModelLoaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0645F1C64F5460086C081 /* HUBViewModelLoaderTests.m */; };
9292
8AD064661C64F7C30086C081 /* HUBContentOperationMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064651C64F7C30086C081 /* HUBContentOperationMock.m */; };
93-
8AD064691C68DEA10086C081 /* HUBViewControllerImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064681C68DEA10086C081 /* HUBViewControllerImplementation.m */; };
93+
8AD064691C68DEA10086C081 /* HUBViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064681C68DEA10086C081 /* HUBViewController.m */; };
9494
8AD0646C1C68E7B00086C081 /* HUBComponentCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0646B1C68E7B00086C081 /* HUBComponentCollectionViewCell.m */; };
9595
8AD064701C68EDA20086C081 /* HUBViewControllerFactoryImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0646F1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.m */; };
9696
8AD064741C68F0820086C081 /* HUBViewModelLoaderFactoryImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064731C68F0820086C081 /* HUBViewModelLoaderFactoryImplementation.m */; };
@@ -258,7 +258,6 @@
258258
8A69DBAC1C7DF9D300F5EFC6 /* HUBCollectionViewFactoryMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBCollectionViewFactoryMock.m; sourceTree = "<group>"; };
259259
8A69DBAE1C7DFA1A00F5EFC6 /* HUBCollectionViewMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBCollectionViewMock.h; sourceTree = "<group>"; };
260260
8A69DBAF1C7DFA1A00F5EFC6 /* HUBCollectionViewMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBCollectionViewMock.m; sourceTree = "<group>"; };
261-
8A69DBB91C7F0FC400F5EFC6 /* HUBViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HUBViewController.h; sourceTree = "<group>"; };
262261
8A6ACAB21D7D893400102EA9 /* HUBActionContextImplementation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBActionContextImplementation.m; sourceTree = "<group>"; };
263262
8A6ACAB51D7D89CE00102EA9 /* HUBActionContextImplementation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HUBActionContextImplementation.h; sourceTree = "<group>"; };
264263
8A6BA04F1C899E1C0057485D /* HUBCollectionViewLayoutTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBCollectionViewLayoutTests.m; sourceTree = "<group>"; };
@@ -298,6 +297,8 @@
298297
8A9383BF1D1ADF3C0085A2D5 /* HUBJSONCompatibleBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HUBJSONCompatibleBuilder.h; sourceTree = "<group>"; };
299298
8A9C9CFD1DDC71930070258F /* HUBAsyncActionWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBAsyncActionWrapper.h; sourceTree = "<group>"; };
300299
8A9C9CFE1DDC71930070258F /* HUBAsyncActionWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBAsyncActionWrapper.m; sourceTree = "<group>"; };
300+
8A9CA05E1DDDC3D70070258F /* HUBViewController+Initializer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HUBViewController+Initializer.h"; sourceTree = "<group>"; };
301+
8A9CA05F1DDDD3230070258F /* HUBViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBViewController.h; sourceTree = "<group>"; };
301302
8A9ED75B1D4A049C006B27D8 /* HUBComponentReusePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBComponentReusePool.h; sourceTree = "<group>"; };
302303
8A9ED75C1D4A049C006B27D8 /* HUBComponentReusePool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBComponentReusePool.m; sourceTree = "<group>"; };
303304
8A9ED75E1D4A24C2006B27D8 /* HUBComponentModelTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBComponentModelTests.m; sourceTree = "<group>"; };
@@ -350,8 +351,7 @@
350351
8AD0645F1C64F5460086C081 /* HUBViewModelLoaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBViewModelLoaderTests.m; sourceTree = "<group>"; };
351352
8AD064641C64F7C30086C081 /* HUBContentOperationMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBContentOperationMock.h; sourceTree = "<group>"; };
352353
8AD064651C64F7C30086C081 /* HUBContentOperationMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBContentOperationMock.m; sourceTree = "<group>"; };
353-
8AD064671C68DEA10086C081 /* HUBViewControllerImplementation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBViewControllerImplementation.h; sourceTree = "<group>"; };
354-
8AD064681C68DEA10086C081 /* HUBViewControllerImplementation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBViewControllerImplementation.m; sourceTree = "<group>"; };
354+
8AD064681C68DEA10086C081 /* HUBViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBViewController.m; sourceTree = "<group>"; };
355355
8AD0646B1C68E7B00086C081 /* HUBComponentCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBComponentCollectionViewCell.m; sourceTree = "<group>"; };
356356
8AD0646E1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBViewControllerFactoryImplementation.h; sourceTree = "<group>"; };
357357
8AD0646F1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBViewControllerFactoryImplementation.m; sourceTree = "<group>"; };
@@ -1063,8 +1063,8 @@
10631063
8AD064751C68FCAD0086C081 /* HUBViewModelLoader.h */,
10641064
8AD064761C69069A0086C081 /* HUBViewModelLoaderFactory.h */,
10651065
8A786B911C57D53600B2AB9E /* HUBViewModelBuilder.h */,
1066+
8A9CA05F1DDDD3230070258F /* HUBViewController.h */,
10661067
8AD064771C6906B00086C081 /* HUBViewControllerFactory.h */,
1067-
8A69DBB91C7F0FC400F5EFC6 /* HUBViewController.h */,
10681068
8A0E4B761CB561DE0019DE71 /* HUBViewURIPredicate.h */,
10691069
8AED9F8F1D77090D00BEFD66 /* HUBViewControllerScrollHandler.h */,
10701070
);
@@ -1074,6 +1074,8 @@
10741074
8AF9FA041C5254E8003F3D6C /* View */ = {
10751075
isa = PBXGroup;
10761076
children = (
1077+
8A9CA05E1DDDC3D70070258F /* HUBViewController+Initializer.h */,
1078+
8AD064681C68DEA10086C081 /* HUBViewController.m */,
10771079
8AF9FA051C5254F5003F3D6C /* HUBViewModelImplementation.h */,
10781080
8AF9FA061C5254F5003F3D6C /* HUBViewModelImplementation.m */,
10791081
F64C5C2B1DB82CA30077E619 /* HUBViewModelRenderer.h */,
@@ -1086,8 +1088,6 @@
10861088
8A786B931C57D62100B2AB9E /* HUBViewModelBuilderImplementation.m */,
10871089
8AFDCAC31C8DD5920068DECC /* HUBInitialViewModelRegistry.h */,
10881090
8AFDCAC41C8DD5920068DECC /* HUBInitialViewModelRegistry.m */,
1089-
8AD064671C68DEA10086C081 /* HUBViewControllerImplementation.h */,
1090-
8AD064681C68DEA10086C081 /* HUBViewControllerImplementation.m */,
10911091
8AD0646E1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.h */,
10921092
8AD0646F1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.m */,
10931093
8A69DBA81C7DF8C000F5EFC6 /* HUBCollectionViewFactory.h */,
@@ -1242,7 +1242,7 @@
12421242
8A2A72EB1D4B726800141619 /* HUBComponentTargetJSONSchemaImplementation.m in Sources */,
12431243
8AD064561C64B6DB0086C081 /* HUBComponentModelJSONSchemaImplementation.m in Sources */,
12441244
8A15729B1D9E735C00E9DD4D /* HUBLiveServiceImplementation.m in Sources */,
1245-
8AD064691C68DEA10086C081 /* HUBViewControllerImplementation.m in Sources */,
1245+
8AD064691C68DEA10086C081 /* HUBViewController.m in Sources */,
12461246
8A786BA81C5A2E8F00B2AB9E /* HUBJSONSchemaRegistryImplementation.m in Sources */,
12471247
8A2A72E61D4B6F1700141619 /* HUBComponentTargetBuilderImplementation.m in Sources */,
12481248
8ADA48571D784C1400C27F21 /* HUBAutoEquatable.m in Sources */,

demo/sources/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import HubFramework
6666

6767
// MARK: - HUBLiveServiceDelegate
6868

69-
func liveService(_ liveService: HUBLiveService, didCreateViewController viewController: UIViewController) {
69+
func liveService(_ liveService: HUBLiveService, didCreateViewController viewController: HUBViewController) {
7070
prepareAndPush(viewController: viewController, animated: true)
7171
}
7272

documentation/Live editing guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Once the live service has created a view controller, push that view controller o
3636
3737
```objective-c
3838
- (void)liveService:(id<HUBLiveService>)liveService
39-
didCreateViewController:(UIViewController<HUBViewController> *)viewController
39+
didCreateViewController:(HUBViewController *)viewController
4040
{
4141
[self.navigationController pushViewController:viewController animated:YES];
4242
}

include/HubFramework/HUBLiveService.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
NS_ASSUME_NONNULL_BEGIN
2525

2626
@protocol HUBLiveService;
27-
@protocol HUBViewController;
27+
@class HUBViewController;
2828

2929
/**
3030
* Delegate protocol for `HUBLiveService`
@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
4646
* navigation stack.
4747
*/
4848
- (void)liveService:(id<HUBLiveService>)liveService
49-
didCreateViewController:(UIViewController<HUBViewController> *)viewController;
49+
didCreateViewController:(HUBViewController *)viewController;
5050

5151
@end
5252

include/HubFramework/HUBViewController.h

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@
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

3341
NS_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

256282
NS_ASSUME_NONNULL_END

include/HubFramework/HUBViewControllerFactory.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#import <UIKIt/UIKit.h>
2323

24-
@protocol HUBViewController;
24+
@class HUBViewController;
2525
@protocol HUBContentOperation;
2626

2727
NS_ASSUME_NONNULL_BEGIN
@@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
6060
* To be able to create a view controller without creating a feature, you can use the other view controller
6161
* creation method available on this protocol.
6262
*/
63-
- (nullable UIViewController<HUBViewController> *)createViewControllerForViewURI:(NSURL *)viewURI;
63+
- (nullable HUBViewController *)createViewControllerForViewURI:(NSURL *)viewURI;
6464

6565
/**
6666
* Create a view controller without a feature registration
@@ -73,10 +73,10 @@ NS_ASSUME_NONNULL_BEGIN
7373
* @param featureTitle The title of the feature that the view controller will belong to. Used for its
7474
* default title, and also made available to contnet operations as part of `HUBFeatureInfo`.
7575
*/
76-
- (UIViewController<HUBViewController> *)createViewControllerForViewURI:(NSURL *)viewURI
77-
contentOperations:(NSArray<id<HUBContentOperation>> *)contentOperations
78-
featureIdentifier:(NSString *)featureIdentifier
79-
featureTitle:(NSString *)featureTitle;
76+
- (HUBViewController *)createViewControllerForViewURI:(NSURL *)viewURI
77+
contentOperations:(NSArray<id<HUBContentOperation>> *)contentOperations
78+
featureIdentifier:(NSString *)featureIdentifier
79+
featureTitle:(NSString *)featureTitle;
8080

8181
@end
8282

0 commit comments

Comments
 (0)