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

Commit ed81a31

Browse files
authored
Merge branch 'master' into separate-rendering-logic
2 parents 3a160bb + 9b01f01 commit ed81a31

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

sources/HUBViewControllerImplementation.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ - (void)componentWrapper:(HUBComponentWrapper *)componentWrapper
468468
- (HUBComponentWrapper *)componentWrapper:(HUBComponentWrapper *)componentWrapper
469469
childComponentForModel:(id<HUBComponentModel>)model
470470
{
471-
CGSize const containerViewSize = HUBComponentLoadViewIfNeeded(componentWrapper).frame.size;
471+
CGSize const containerViewSize = [self childComponentContainerViewSizeForParentWrapper:componentWrapper];
472472

473473
HUBComponentWrapper * const childComponentWrapper = [self.childComponentReusePool componentWrapperForModel:model
474474
delegate:self
@@ -822,6 +822,16 @@ - (void)configureComponentWrapper:(HUBComponentWrapper *)wrapper withModel:(id<H
822822
self.componentWrappersByModelIdentifier[model.identifier] = wrapper;
823823
}
824824

825+
- (CGSize)childComponentContainerViewSizeForParentWrapper:(HUBComponentWrapper *)parentWrapper
826+
{
827+
if (parentWrapper.isRootComponent && parentWrapper.model.type == HUBComponentTypeBody) {
828+
NSIndexPath * const indexPath = [NSIndexPath indexPathForItem:(NSInteger)parentWrapper.model.index inSection:0];
829+
return [self.collectionView.collectionViewLayout layoutAttributesForItemAtIndexPath:indexPath].frame.size;
830+
}
831+
832+
return HUBComponentLoadViewIfNeeded(parentWrapper).frame.size;
833+
}
834+
825835
- (nullable HUBComponentWrapper *)componentWrapperFromCell:(HUBComponentCollectionViewCell *)cell
826836
{
827837
return self.componentWrappersByCellIdentifier[cell.identifier];

tests/HUBViewControllerTests.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,12 +1385,13 @@ - (void)testContainerViewSizeForReusedRootComponentsAreSameAsCollectionViewSize
13851385
XCTAssertTrue(CGSizeEqualToSize(self.component.currentContainerViewSize, self.collectionView.bounds.size));
13861386
}
13871387

1388-
- (void)testContainerViewSizeForChildComponentsAreParerentComponentsViewSize
1388+
- (void)testContainerViewSizeForChildComponentsAreParentComponentsViewSize
13891389
{
13901390
NSString * const componentNamespace = @"childComponentSelection";
13911391
NSString * const componentName = @"component";
13921392
NSString * const childComponentName = @"componentB";
13931393
HUBComponentMock * const component = [HUBComponentMock new];
1394+
component.preferredViewSize = CGSizeMake(200, 200);
13941395
HUBComponentMock * const childComponent = [HUBComponentMock new];
13951396

13961397
HUBComponentFactoryMock * const componentFactory = [[HUBComponentFactoryMock alloc] initWithComponents:@{
@@ -1417,17 +1418,16 @@ - (void)testContainerViewSizeForChildComponentsAreParerentComponentsViewSize
14171418
NSIndexPath * const indexPath = [NSIndexPath indexPathForItem:0 inSection:0];
14181419
[self.collectionView.dataSource collectionView:self.collectionView cellForItemAtIndexPath:indexPath];
14191420

1420-
const CGRect expectedParentFrame = CGRectMake(0, 0, 88, 88);
1421-
component.view.frame = expectedParentFrame;
1422-
14231421
id<HUBComponentChildDelegate> const childDelegate = component.childDelegate;
14241422

14251423
id<HUBComponentModel> const childComponentModelA = [component.model childAtIndex:0];
14261424
XCTAssertNotNil(childComponentModelA);
14271425

14281426
[childDelegate component:component childComponentForModel:childComponentModelA];
14291427

1430-
XCTAssertTrue(CGSizeEqualToSize(childComponent.currentContainerViewSize, expectedParentFrame.size));
1428+
CGSize const expectedContainerViewSize = [self.collectionView.collectionViewLayout layoutAttributesForItemAtIndexPath:indexPath].frame.size;
1429+
XCTAssertTrue(CGSizeEqualToSize(expectedContainerViewSize, CGSizeMake(200, 200)));
1430+
XCTAssertTrue(CGSizeEqualToSize(childComponent.currentContainerViewSize, expectedContainerViewSize));
14311431
}
14321432

14331433
- (void)testCollectionViewNotAddedOnTopOfInitialOverlayComponent

0 commit comments

Comments
 (0)