Skip to content
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

External components fixes #5896

Merged
merged 3 commits into from
Feb 2, 2020
Merged
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
5 changes: 5 additions & 0 deletions e2e/ExternalComponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ describe('External Component', () => {
await elementById(TestIDs.EXTERNAL_DISMISS_MODAL_BTN).tap();
await expect(elementById(TestIDs.NAVIGATION_SCREEN)).toBeVisible();
});

test(':ios: External component should receive options', async () => {
await elementById(TestIDs.MODAL_BTN).tap();
await expect(elementByLabel('External Component')).toBeVisible();
});
});
2 changes: 1 addition & 1 deletion lib/ios/RNNControllerFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ - (UIViewController *)createComponent:(RNNLayoutNode*)node {
- (UIViewController *)createExternalComponent:(RNNLayoutNode*)node {
RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] initWithNode:node];
RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:node.data[@"options"]];
RNNComponentPresenter* presenter = [[RNNComponentPresenter alloc] initWithDefaultOptions:_defaultOptions];
RNNComponentPresenter* presenter = [[RNNComponentPresenter alloc] initWithComponentRegistry:_componentRegistry defaultOptions:_defaultOptions];

UIViewController* externalVC = [_store getExternalComponent:layoutInfo bridge:_bridge];

Expand Down
5 changes: 3 additions & 2 deletions lib/ios/RNNExternalViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ @implementation RNNExternalViewController {
}

- (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo eventEmitter:(RNNEventEmitter *)eventEmitter presenter:(RNNComponentPresenter *)presenter options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions viewController:(UIViewController *)viewController {
self = [super initWithLayoutInfo:layoutInfo rootViewCreator:nil eventEmitter:eventEmitter presenter:presenter options:options defaultOptions:defaultOptions];
_boundViewController = viewController;
self = [super initWithLayoutInfo:layoutInfo rootViewCreator:nil eventEmitter:eventEmitter presenter:presenter options:options defaultOptions:defaultOptions];
[self bindViewController:viewController];
return self;
}
Expand All @@ -22,7 +23,7 @@ - (UINavigationItem *)navigationItem {
}

- (void)loadView {
self.view = [UIView new];
self.view = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds];
}

- (void)render {
Expand Down
29 changes: 29 additions & 0 deletions playground/ios/NavigationTests/RNNExternalViewControllerTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import <ReactNativeNavigation/RNNExternalViewController.h>
#import <ReactNativeNavigation/RNNCustomViewController.h>

@interface RNNExternalViewControllerTest : XCTestCase

@property (nonatomic, strong) RNNExternalViewController* uut;
@property (nonatomic, strong) RNNCustomViewController* customViewController;

@end

@implementation RNNExternalViewControllerTest

- (void)setUp {
[super setUp];
self.customViewController = [[RNNCustomViewController alloc] init];
RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
layoutInfo.componentId = @"externalComponentId";
RNNComponentPresenter* presenter = [[RNNComponentPresenter alloc] initWithComponentRegistry:nil defaultOptions:nil];
self.uut = [[RNNExternalViewController alloc] initWithLayoutInfo:layoutInfo eventEmitter:nil presenter:presenter options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil viewController:self.customViewController];
}

- (void)testLoadView_withMainScreenBounds {
XCTAssertTrue(CGRectEqualToRect(self.uut.view.bounds, UIScreen.mainScreen.bounds));
}


@end
4 changes: 4 additions & 0 deletions playground/ios/playground.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
501C86B9239FE9C400E0B631 /* UIImage+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 501C86B8239FE9C400E0B631 /* UIImage+Utils.m */; };
50451D35204451A900695F00 /* RNNCustomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 50451D34204451A800695F00 /* RNNCustomViewController.m */; };
50647FE323E3196800B92025 /* RNNExternalViewControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 50647FE223E3196800B92025 /* RNNExternalViewControllerTests.m */; };
50996C6823AA477400008F89 /* RNNRootViewControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 50996C6723AA477400008F89 /* RNNRootViewControllerTest.m */; };
50996C6923AA487800008F89 /* RNNTestRootViewCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = E58D263D2385888C003F36BA /* RNNTestRootViewCreator.m */; };
67C681D42B662A53F29C19DA /* Pods_NavigationIOS12Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEE0B5D45FD34FBABC6586CF /* Pods_NavigationIOS12Tests.framework */; };
Expand Down Expand Up @@ -83,6 +84,7 @@
50364D6B238E7F0A000E62A2 /* ReactNativeNavigation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ReactNativeNavigation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50451D33204451A800695F00 /* RNNCustomViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNNCustomViewController.h; path = ../../../lib/ios/RNNCustomViewController.h; sourceTree = "<group>"; };
50451D34204451A800695F00 /* RNNCustomViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNNCustomViewController.m; path = ../../../lib/ios/RNNCustomViewController.m; sourceTree = "<group>"; };
50647FE223E3196800B92025 /* RNNExternalViewControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNExternalViewControllerTests.m; sourceTree = "<group>"; };
50996C5D23AA46DD00008F89 /* NavigationIOS12Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NavigationIOS12Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
50996C6123AA46DD00008F89 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50996C6723AA477400008F89 /* RNNRootViewControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNRootViewControllerTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -271,6 +273,7 @@
E58D263B2385888C003F36BA /* UITabBarController+RNNOptionsTest.m */,
E58D26252385888B003F36BA /* UIViewController+LayoutProtocolTest.m */,
E58D263E2385888C003F36BA /* UIViewController+RNNOptionsTest.m */,
50647FE223E3196800B92025 /* RNNExternalViewControllerTests.m */,
E58D262E2385888B003F36BA /* utils */,
E58D261F238587F4003F36BA /* Info.plist */,
);
Expand Down Expand Up @@ -735,6 +738,7 @@
files = (
E58D265B2385888C003F36BA /* UIViewController+RNNOptionsTest.m in Sources */,
E58D26532385888C003F36BA /* RNNSideMenuPresenterTest.m in Sources */,
50647FE323E3196800B92025 /* RNNExternalViewControllerTests.m in Sources */,
E58D264D2385888C003F36BA /* RNNOverlayManagerTest.m in Sources */,
501C86B9239FE9C400E0B631 /* UIImage+Utils.m in Sources */,
E58D265F2385888C003F36BA /* RNNBasePresenterTest.m in Sources */,
Expand Down
7 changes: 7 additions & 0 deletions playground/src/screens/ExternalComponentScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class ExternalComponentScreen extends React.Component {
name: Screens.NativeScreen,
passProps: {
text: 'External component in deep stack'
},
options: {
topBar: {
title: {
text: 'External Component'
}
}
}
}
}
Expand Down