Browse Source

change back findContainerForId to return UIViewController

Daniel Zlotin 7 years ago
parent
commit
ec046551ba

+ 6
- 3
lib/ios/RNNCommandsHandler.m View File

@@ -37,9 +37,12 @@
37 37
 
38 38
 -(void) setOptions:(NSString*)containerId options:(NSDictionary*)options {
39 39
 	[self assertReady];
40
-	RNNRootViewController* vc = [_store findContainerForId:containerId];
41
-	[vc.navigationOptions mergeWith:options];
42
-	[vc.navigationOptions applyOn:vc];
40
+	UIViewController* vc = [_store findContainerForId:containerId];
41
+	if([vc isKindOfClass:[RNNRootViewController class]]) {
42
+		RNNRootViewController* rootVc = (RNNRootViewController*)vc;
43
+		[rootVc.navigationOptions mergeWith:options];
44
+		[rootVc.navigationOptions applyOn:vc];
45
+	}
43 46
 }
44 47
 
45 48
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {

+ 1
- 1
lib/ios/RNNModalManager.m View File

@@ -34,7 +34,7 @@
34 34
 -(void)removePendingNextModalIfOnTop {
35 35
 	NSString *containerId = [[_store pendingModalIdsToDismiss] lastObject];
36 36
 	
37
-	RNNRootViewController *modalToDismiss = [_store findContainerForId:containerId];
37
+	UIViewController *modalToDismiss = [_store findContainerForId:containerId];
38 38
 	
39 39
 	if(!modalToDismiss) {
40 40
 		return;

+ 4
- 4
lib/ios/RNNNavigationStackManager.m View File

@@ -12,12 +12,12 @@
12 12
 }
13 13
 
14 14
 -(void)push:(UIViewController *)newTop onTop:(NSString *)containerId {
15
-	RNNRootViewController *vc = [_store findContainerForId:containerId];
15
+	UIViewController *vc = [_store findContainerForId:containerId];
16 16
 	[[vc navigationController] pushViewController:newTop animated:YES];
17 17
 }
18 18
 
19 19
 -(void)pop:(NSString *)containerId {
20
-	RNNRootViewController* vc = [_store findContainerForId:containerId];
20
+	UIViewController* vc = [_store findContainerForId:containerId];
21 21
 	UINavigationController* nvc = [vc navigationController];
22 22
 	if ([nvc topViewController] == vc) {
23 23
 		[nvc popViewControllerAnimated:YES];
@@ -30,7 +30,7 @@
30 30
 }
31 31
 
32 32
 -(void)popTo:(NSString*)containerId {
33
-	RNNRootViewController *vc = [_store findContainerForId:containerId];
33
+	UIViewController *vc = [_store findContainerForId:containerId];
34 34
 	
35 35
 	if (vc) {
36 36
 		UINavigationController *nvc = [vc navigationController];
@@ -42,7 +42,7 @@
42 42
 }
43 43
 
44 44
 -(void) popToRoot:(NSString*)containerId {
45
-	RNNRootViewController* vc = [_store findContainerForId:containerId];
45
+	UIViewController* vc = [_store findContainerForId:containerId];
46 46
 	UINavigationController* nvc = [vc navigationController];
47 47
 	NSArray* poppedVCs = [nvc popToRootViewControllerAnimated:YES];
48 48
 	[self removePopedViewControllers:poppedVCs];

+ 1
- 1
lib/ios/RNNStore.h View File

@@ -5,7 +5,7 @@
5 5
 
6 6
 @interface RNNStore : NSObject
7 7
 
8
--(RNNRootViewController*) findContainerForId:(NSString*)containerId;
8
+-(UIViewController*) findContainerForId:(NSString*)containerId;
9 9
 -(void) setContainer:(UIViewController*)viewController containerId:(NSString*)containerId;
10 10
 -(void) removeContainer:(NSString*)containerId;
11 11
 -(void) removeContainerByViewControllerInstance:(UIViewController*)containerInstance;

+ 2
- 2
lib/ios/RNNStore.m View File

@@ -19,12 +19,12 @@
19 19
 	return self;
20 20
 }
21 21
 
22
--(RNNRootViewController *)findContainerForId:(NSString *)containerId {
22
+-(UIViewController *)findContainerForId:(NSString *)containerId {
23 23
 	return [_containerStore objectForKey:containerId];
24 24
 }
25 25
 
26 26
 - (void)setContainer:(UIViewController*)viewController containerId:(NSString*)containerId {
27
-	RNNRootViewController *existingVewController = [self findContainerForId:containerId];
27
+	UIViewController *existingVewController = [self findContainerForId:containerId];
28 28
 	if (existingVewController) {
29 29
 		@throw [NSException exceptionWithName:@"MultipleContainerId" reason:[@"Container id already exists " stringByAppendingString:containerId] userInfo:nil];
30 30
 	}

+ 1
- 2
lib/ios/ReactNativeNavigationTests/RNNNavigationOptionsTest.m View File

@@ -28,8 +28,7 @@
28 28
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:@{@"topBarBackgroundColor" : @(0xff0000ff)}];
29 29
 	NSDictionary* dynamicOptions = @{@"topBarTextColor" : @(0xffff00ff), @"title" : @"hello"};
30 30
     [options mergeWith:dynamicOptions];
31
-	XCTAssertTrue([options.title isEqual:@"hello"]);
32
-	
31
+	XCTAssertTrue([options.title isEqual:@"hello"]);	
33 32
 }
34 33
 
35 34
 -(void)testChangeRNNNavigationOptionsWithInvalidProperties{