Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions HubFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
8AD0645E1C64F45A0086C081 /* HUBConnectivityStateResolverMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0645C1C64F4510086C081 /* HUBConnectivityStateResolverMock.m */; };
8AD064601C64F5460086C081 /* HUBViewModelLoaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0645F1C64F5460086C081 /* HUBViewModelLoaderTests.m */; };
8AD064661C64F7C30086C081 /* HUBContentOperationMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064651C64F7C30086C081 /* HUBContentOperationMock.m */; };
8AD064691C68DEA10086C081 /* HUBViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064681C68DEA10086C081 /* HUBViewController.m */; };
8AD0646C1C68E7B00086C081 /* HUBComponentCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0646B1C68E7B00086C081 /* HUBComponentCollectionViewCell.m */; };
8AD064701C68EDA20086C081 /* HUBViewControllerFactoryImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD0646F1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.m */; };
8AD064741C68F0820086C081 /* HUBViewModelLoaderFactoryImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064731C68F0820086C081 /* HUBViewModelLoaderFactoryImplementation.m */; };
Expand Down Expand Up @@ -335,7 +334,6 @@
8AE6C0841DF6E4020063B2B1 /* HUBContentOperationExecutionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AA9894A1DD1E3C1006CA6AA /* HUBContentOperationExecutionInfo.m */; };
8AE6C0851DF6E4020063B2B1 /* HUBContentOperationContextImplementation.h in Headers */ = {isa = PBXBuildFile; fileRef = 521891E81DEE3E4500FA3BF7 /* HUBContentOperationContextImplementation.h */; };
8AE6C0861DF6E4020063B2B1 /* HUBContentOperationContextImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = 521891E91DEE3E4500FA3BF7 /* HUBContentOperationContextImplementation.m */; };
8AE6C0881DF6E4020063B2B1 /* HUBViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD064681C68DEA10086C081 /* HUBViewController.m */; };
8AE6C0891DF6E4020063B2B1 /* HUBViewModelImplementation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AF9FA051C5254F5003F3D6C /* HUBViewModelImplementation.h */; };
8AE6C08A1DF6E4020063B2B1 /* HUBViewModelImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AF9FA061C5254F5003F3D6C /* HUBViewModelImplementation.m */; };
8AE6C08B1DF6E4020063B2B1 /* HUBViewModelRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = F64C5C2B1DB82CA30077E619 /* HUBViewModelRenderer.h */; };
Expand Down Expand Up @@ -745,7 +743,6 @@
8AD0645F1C64F5460086C081 /* HUBViewModelLoaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBViewModelLoaderTests.m; sourceTree = "<group>"; };
8AD064641C64F7C30086C081 /* HUBContentOperationMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBContentOperationMock.h; sourceTree = "<group>"; };
8AD064651C64F7C30086C081 /* HUBContentOperationMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBContentOperationMock.m; sourceTree = "<group>"; };
8AD064681C68DEA10086C081 /* HUBViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBViewController.m; sourceTree = "<group>"; };
8AD0646B1C68E7B00086C081 /* HUBComponentCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBComponentCollectionViewCell.m; sourceTree = "<group>"; };
8AD0646E1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUBViewControllerFactoryImplementation.h; sourceTree = "<group>"; };
8AD0646F1C68EDA20086C081 /* HUBViewControllerFactoryImplementation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUBViewControllerFactoryImplementation.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1590,7 +1587,6 @@
8AF9FA041C5254E8003F3D6C /* View */ = {
isa = PBXGroup;
children = (
8AD064681C68DEA10086C081 /* HUBViewController.m */,
6584D5881E82BBA10042666A /* HUBViewControllerImplementation.h */,
6584D5891E82BBA10042666A /* HUBViewControllerImplementation.m */,
6584D6281E82C6A30042666A /* HUBViewControllerExperimentalImplementation.h */,
Expand Down Expand Up @@ -2001,7 +1997,6 @@
8A2A72EB1D4B726800141619 /* HUBComponentTargetJSONSchemaImplementation.m in Sources */,
8AD064561C64B6DB0086C081 /* HUBComponentModelJSONSchemaImplementation.m in Sources */,
8A15729B1D9E735C00E9DD4D /* HUBLiveServiceImplementation.m in Sources */,
8AD064691C68DEA10086C081 /* HUBViewController.m in Sources */,
8A786BA81C5A2E8F00B2AB9E /* HUBJSONSchemaRegistryImplementation.m in Sources */,
8A2A72E61D4B6F1700141619 /* HUBComponentTargetBuilderImplementation.m in Sources */,
8ADA48571D784C1400C27F21 /* HUBAutoEquatable.m in Sources */,
Expand Down Expand Up @@ -2237,7 +2232,6 @@
8AE6C0DC1DF6E41B0063B2B1 /* HUBAutoEquatable.m in Sources */,
8AE6C0C81DF6E4100063B2B1 /* HUBDefaultImageLoader.m in Sources */,
8AE6C0A91DF6E40D0063B2B1 /* HUBDefaultComponentFallbackHandler.m in Sources */,
8AE6C0881DF6E4020063B2B1 /* HUBViewController.m in Sources */,
8AE6C0801DF6E4020063B2B1 /* HUBBlockContentOperation.m in Sources */,
8AE6C08C1DF6E4020063B2B1 /* HUBViewModelRenderer.m in Sources */,
8AE6C0BE1DF6E40D0063B2B1 /* HUBComponentUIStateManager.m in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion demo/sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,11 @@ import HubFramework
// MARK: - View controller handling

private func prepareAndPush(viewController: HUBViewController, animated: Bool) {
guard let vc = viewController as? UIViewController else { return }
viewController.delegate = navigationController
viewController.view.backgroundColor = .white
viewController.view.contentView?.alwaysBounceVertical = (viewController.viewURI == URL.gitHubSearchViewURI)
navigationController?.pushViewController(viewController, animated: animated)
navigationController?.pushViewController(vc, animated: animated)
}
}

5 changes: 3 additions & 2 deletions include/HubFramework/HUBConfigViewControllerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class HUBConfig;
@class HUBViewController;
@protocol HUBViewController;
@protocol HUBActionHandler;
@protocol HUBContentOperation;
@protocol HUBViewModel;
Expand All @@ -48,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param featureTitle Used to set the `featureInfo` on the created view controller.
* @param actionHandler Optional custom action handler. See `HUBActionHandler` for more info.
*/
- (HUBViewController *)createViewControllerWithConfig:(HUBConfig *)config
- (id<HUBViewController>)createViewControllerWithConfig:(HUBConfig *)config
contentOperations:(NSArray<id<HUBContentOperation>> *)contentOperations
viewURI:(NSURL *)viewURI
featureIdentifier:(NSString *)featureIdentifier
Expand Down
26 changes: 13 additions & 13 deletions include/HubFramework/HUBViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@protocol HUBViewModel;
@protocol HUBComponentModel;
@protocol HUBImageLoader;
@class HUBViewController;
@protocol HUBViewController;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
* You can use this method to perform any custom UI operations on the whole view controller right before
* a new model will be rendered.
*/
- (void)viewController:(HUBViewController *)viewController willUpdateWithViewModel:(id<HUBViewModel>)viewModel;
- (void)viewController:(id <HUBViewController>)viewController willUpdateWithViewModel:(id<HUBViewModel>)viewModel;

/**
* Sent to a Hub Framework view controller's delegate when it was updated with a new view model
Expand All @@ -59,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
* You can use this method to perform any custom UI operations on the whole view controller when a new
* view model has been rendered.
*/
- (void)viewControllerDidUpdate:(HUBViewController *)viewController;
- (void)viewControllerDidUpdate:(id <HUBViewController>)viewController;

/**
* Sent to a Hub Framework view controller's delegate when it failed to be updated because of an error
Expand All @@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* Note that you can also use content operations (`HUBContentOperation`) to react to errors, and adjust the UI.
*/
- (void)viewController:(HUBViewController *)viewController didFailToUpdateWithError:(NSError *)error;
- (void)viewController:(id <HUBViewController>)viewController didFailToUpdateWithError:(NSError *)error;

/**
* Sent to a Hub Framework view controller's delegate when the view finished rendering, due to a view model update.
Expand All @@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN
* You can use this method to perform any custom UI operations on the whole view controller right after
* a new view model was rendered.
*/
- (void)viewControllerDidFinishRendering:(HUBViewController *)viewController;
- (void)viewControllerDidFinishRendering:(id <HUBViewController>)viewController;

/**
* Sent to a Hub Framework view controller's delegate to ask it whenever the view controller should start scrolling
Expand All @@ -92,7 +92,7 @@ NS_ASSUME_NONNULL_BEGIN
* This method can be used to veto a scroll event from being started. It will be called every time the user starts
* scrolling the view that is rendering body components.
*/
- (BOOL)viewControllerShouldStartScrolling:(HUBViewController *)viewController;
- (BOOL)viewControllerShouldStartScrolling:(id <HUBViewController>)viewController;

/**
* Sent to a Hub Framework view controller's delegate when a component is about to appear on the screen
Expand All @@ -102,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param layoutTraits The layout traits of the component that is about to appear
* @param componentView The view that the component is about to appear in
*/
- (void)viewController:(HUBViewController *)viewController
- (void)viewController:(id<HUBViewController>)viewController
componentWithModel:(id<HUBComponentModel>)componentModel
layoutTraits:(NSSet<HUBComponentLayoutTrait> *)layoutTraits
willAppearInView:(UIView *)componentView;
Expand All @@ -115,7 +115,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param layoutTraits The layout traits of the component that disappeared
* @param componentView The view that the component disappeared from
*/
- (void)viewController:(HUBViewController *)viewController
- (void)viewController:(id<HUBViewController>)viewController
componentWithModel:(id<HUBComponentModel>)componentModel
layoutTraits:(NSSet<HUBComponentLayoutTrait> *)layoutTraits
didDisappearFromView:(UIView *)componentView;
Expand All @@ -126,7 +126,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param viewController The view controller in which a component view will be reused
* @param componentView The component view that will be reused
*/
- (void)viewController:(HUBViewController *)viewController
- (void)viewController:(id<HUBViewController>)viewController
willReuseComponentWithView:(UIView *)componentView;

/**
Expand All @@ -135,7 +135,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param viewController The view controller in which the component was selected
* @param componentModel The model of the component that was selected
*/
- (void)viewController:(HUBViewController *)viewController componentSelectedWithModel:(id<HUBComponentModel>)componentModel;
- (void)viewController:(id<HUBViewController>)viewController componentSelectedWithModel:(id<HUBComponentModel>)componentModel;

/**
* Sent to a Hub Framework view controller's delegate to ask if view controller should automatically
Expand All @@ -146,7 +146,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion When view controller automatically manages content inset it puts body components
* below header component and below navigation bar.
*/
- (BOOL)viewControllerShouldAutomaticallyManageTopContentInset:(HUBViewController *)viewController;
- (BOOL)viewControllerShouldAutomaticallyManageTopContentInset:(id<HUBViewController>)viewController;

/**
* Return the center point of overlay coponents used in a view controller.
Expand All @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN
* The Hub Framework will call this method every time a view controller is being laid out, which is usually in
* response to that its view model has been changed. The returned value will be set as a center point of the overlay.
*/
- (CGPoint)centerPointForOverlayComponentInViewController:(HUBViewController *)viewController
- (CGPoint)centerPointForOverlayComponentInViewController:(id<HUBViewController>)viewController
proposedCenterPoint:(CGPoint)proposedCenterPoint;

@end
Expand All @@ -170,7 +170,7 @@ NS_ASSUME_NONNULL_BEGIN
* This view controller renders `HUBComponent` instances using a collection view. What components that are rendered
* are determined by `HUBContentOperation`s that build a `HUBViewModel`.
*/
@interface HUBViewController : UIViewController <HUBActionPerformer>
@protocol HUBViewController

/// The view controller's delegate. See `HUBViewControllerDelegate` for more information.
@property (nonatomic, weak, nullable) id<HUBViewControllerDelegate> delegate;
Expand Down
8 changes: 4 additions & 4 deletions include/HubFramework/HUBViewControllerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#import <UIKIt/UIKit.h>

@class HUBViewController;
@protocol HUBViewController;
@protocol HUBContentOperation;

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
* To be able to create a view controller without creating a feature, you can use the other view controller
* creation methods available on this protocol.
*/
- (nullable HUBViewController *)createViewControllerForViewURI:(NSURL *)viewURI;
- (nullable id<HUBViewController>)createViewControllerForViewURI:(NSURL *)viewURI;

/**
* Create a view controller without a feature registration, with implicit identifiers
Expand All @@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
* The view controller's feature identifier and view URI will be set by transforming the given feature
* title into lowercase characters.
*/
- (HUBViewController *)createViewControllerWithContentOperations:(NSArray<id<HUBContentOperation>> *)contentOperations
- (id<HUBViewController>)createViewControllerWithContentOperations:(NSArray<id<HUBContentOperation>> *)contentOperations
featureTitle:(NSString *)featureTitle NS_SWIFT_NAME(createViewController(withContentOperations:featureTitle:));

/**
Expand All @@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param featureTitle The title of the feature that the view controller will belong to. Used for its
* default title, and also made available to contnet operations as part of `HUBFeatureInfo`.
*/
- (HUBViewController *)createViewControllerForViewURI:(NSURL *)viewURI
- (id<HUBViewController>)createViewControllerForViewURI:(NSURL *)viewURI
contentOperations:(NSArray<id<HUBContentOperation>> *)contentOperations
featureIdentifier:(NSString *)featureIdentifier
featureTitle:(NSString *)featureTitle;
Expand Down
22 changes: 11 additions & 11 deletions include/HubFramework/HUBViewControllerScrollHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#import <UIKit/UIKit.h>
#import "HUBScrollPosition.h"

@class HUBViewController;
@protocol HUBViewController;

/**
* Protocol used to define custom scroll handlers for Hub Framework view controllers
Expand All @@ -41,7 +41,7 @@
* The Hub Framework will call this method when a view controller is being set up. The returned
* value will be used for both horizontal & vertical scroll indicators.
*/
- (BOOL)shouldShowScrollIndicatorsInViewController:(HUBViewController *)viewController;
- (BOOL)shouldShowScrollIndicatorsInViewController:(id<HUBViewController>)viewController;

/**
* Return whether the system's automatic adjustment of content insets should be used for a view controller
Expand All @@ -52,7 +52,7 @@
* assigned to its `automaticallyAdjustsScrollViewInsets` property, so see the documentation for that property
* on `UIViewController` for more information.
*/
- (BOOL)shouldAutomaticallyAdjustContentInsetsInViewController:(HUBViewController *)viewController;
- (BOOL)shouldAutomaticallyAdjustContentInsetsInViewController:(id<HUBViewController>)viewController;

/**
* Return the manner in which the keyboard is dismissed when the content in the view controller is dragged
Expand All @@ -63,7 +63,7 @@
* assigned to the `keyboardDismissMode` property of the used scroll view, so see the documentation for that property
* on `UIScrollView` for more information.
*/
- (UIScrollViewKeyboardDismissMode)keyboardDismissModeForViewController:(HUBViewController *)viewController;
- (UIScrollViewKeyboardDismissMode)keyboardDismissModeForViewController:(id<HUBViewController>)viewController;

/**
* Return the deceleration rate to use for scrolling in a view controller
Expand All @@ -73,7 +73,7 @@
* The Hub Framework will call this method when a view controller is being set up. The returned value will be
* assied to the `decelerationRate` property of its internal scroll view.
*/
- (CGFloat)scrollDecelerationRateForViewController:(HUBViewController *)viewController;
- (CGFloat)scrollDecelerationRateForViewController:(id<HUBViewController>)viewController;

/**
* Return the content insets to use for a view controller
Expand All @@ -86,7 +86,7 @@
* response to that its view model has been changed. The returned value will be assigned to the `contentInset`
* property of its internal scroll view.
*/
- (UIEdgeInsets)contentInsetsForViewController:(HUBViewController *)viewController
- (UIEdgeInsets)contentInsetsForViewController:(id<HUBViewController>)viewController
proposedContentInsets:(UIEdgeInsets)proposedContentInsets;

/**
Expand All @@ -95,7 +95,7 @@
* @param viewController The view controller in question
* @param currentContentRect The rectangle of the currently visible content in the view controller's scroll view
*/
- (void)scrollingWillStartInViewController:(HUBViewController *)viewController
- (void)scrollingWillStartInViewController:(id<HUBViewController>)viewController
currentContentRect:(CGRect)currentContentRect;

/**
Expand All @@ -104,7 +104,7 @@
* @param viewController The view controller in question
* @param contentOffest The scroll view's content offset
*/
- (void)scrollViewDidScrollInViewController:(HUBViewController *)viewController
- (void)scrollViewDidScrollInViewController:(id<HUBViewController>)viewController
withContentOffset:(CGPoint)contentOffest;

/**
Expand All @@ -113,7 +113,7 @@
* @param viewController The view controller in question
* @param currentContentRect The rectangle of the currently visible content in the view controller's scroll view
*/
- (void)scrollingDidEndInViewController:(HUBViewController *)viewController
- (void)scrollingDidEndInViewController:(id<HUBViewController>)viewController
currentContentRect:(CGRect)currentContentRect;

/**
Expand All @@ -125,7 +125,7 @@
* @param currentContentOffset The current scrolling content offset
* @param proposedContentOffset The target content offset that the Hub Framework is proposing will be used
*/
- (CGPoint)targetContentOffsetForEndedScrollInViewController:(HUBViewController *)viewController
- (CGPoint)targetContentOffsetForEndedScrollInViewController:(id<HUBViewController>)viewController
velocity:(CGVector)velocity
contentInset:(UIEdgeInsets)contentInset
currentContentOffset:(CGPoint)currentContentOffset
Expand All @@ -144,6 +144,6 @@
scrollPosition:(HUBScrollPosition)scrollPosition
contentInset:(UIEdgeInsets)contentInset
contentSize:(CGSize)contentSize
viewController:(HUBViewController *)viewController;
viewController:(id<HUBViewController>)viewController;

@end
Loading