Pārlūkot izejas kodu

change back findContainerForId to return UIViewController

Daniel Zlotin 7 gadus atpakaļ
vecāks
revīzija
ec046551ba

+ 6
- 3
lib/ios/RNNCommandsHandler.m Parādīt failu

37
 
37
 
38
 -(void) setOptions:(NSString*)containerId options:(NSDictionary*)options {
38
 -(void) setOptions:(NSString*)containerId options:(NSDictionary*)options {
39
 	[self assertReady];
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
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {
48
 -(void) push:(NSString*)containerId layout:(NSDictionary*)layout {

+ 1
- 1
lib/ios/RNNModalManager.m Parādīt failu

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

+ 4
- 4
lib/ios/RNNNavigationStackManager.m Parādīt failu

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

+ 1
- 1
lib/ios/RNNStore.h Parādīt failu

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

+ 2
- 2
lib/ios/RNNStore.m Parādīt failu

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

+ 1
- 2
lib/ios/ReactNativeNavigationTests/RNNNavigationOptionsTest.m Parādīt failu

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