yogevbd 6 years ago
parent
commit
db013e8e67

+ 2
- 0
lib/ios/RNNModalManager.m View File

22
 -(void)showModalAfterLoad:(NSDictionary*)notif {
22
 -(void)showModalAfterLoad:(NSDictionary*)notif {
23
 	[[NSNotificationCenter defaultCenter] removeObserver:self name:@"RCTContentDidAppearNotification" object:nil];
23
 	[[NSNotificationCenter defaultCenter] removeObserver:self name:@"RCTContentDidAppearNotification" object:nil];
24
 	RNNRootViewController *topVC = (RNNRootViewController*)[self topPresentedVC];
24
 	RNNRootViewController *topVC = (RNNRootViewController*)[self topPresentedVC];
25
+	topVC.definesPresentationContext = YES;
26
+	
25
 	if (topVC.options.animations.showModal.hasCustomAnimation) {
27
 	if (topVC.options.animations.showModal.hasCustomAnimation) {
26
 		self.toVC.transitioningDelegate = topVC;
28
 		self.toVC.transitioningDelegate = topVC;
27
 	}
29
 	}

+ 17
- 5
lib/ios/RNNNavigationController.m View File

8
 	return self.viewControllers.lastObject.supportedInterfaceOrientations;
8
 	return self.viewControllers.lastObject.supportedInterfaceOrientations;
9
 }
9
 }
10
 
10
 
11
+- (UIViewController<RNNRootViewProtocol>*)getTopViewController {
12
+	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController);
13
+}
14
+
11
 - (BOOL)isCustomTransitioned {
15
 - (BOOL)isCustomTransitioned {
12
 	return NO;
16
 	return NO;
13
 }
17
 }
14
 
18
 
15
 - (BOOL)isCustomViewController {
19
 - (BOOL)isCustomViewController {
16
-	return [((UIViewController<RNNRootViewProtocol>*)self.topViewController) isCustomViewController];
20
+	return [self.getTopViewController isCustomViewController];
17
 }
21
 }
18
 
22
 
19
 - (void)mergeOptions:(NSDictionary *)options {
23
 - (void)mergeOptions:(NSDictionary *)options {
20
-	[((UIViewController<RNNRootViewProtocol>*)self.topViewController) mergeOptions:options];
24
+	[self.getTopViewController mergeOptions:options];
21
 }
25
 }
22
 
26
 
23
 - (UIStatusBarStyle)preferredStatusBarStyle {
27
 - (UIStatusBarStyle)preferredStatusBarStyle {
24
-	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController).preferredStatusBarStyle;
28
+	return self.getTopViewController.preferredStatusBarStyle;
29
+}
30
+
31
+- (UIModalPresentationStyle)modalPresentationStyle {
32
+	return self.getTopViewController.modalPresentationStyle;
33
+}
34
+
35
+- (void)applyModalOptions {
36
+	[self.getTopViewController applyModalOptions];
25
 }
37
 }
26
 
38
 
27
 - (NSString *)componentId {
39
 - (NSString *)componentId {
28
-	return _componentId ? _componentId : ((UIViewController<RNNRootViewProtocol>*)self.topViewController).componentId;
40
+	return _componentId ? _componentId : self.getTopViewController.componentId;
29
 }
41
 }
30
 
42
 
31
 - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
43
 - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
37
 }
49
 }
38
 
50
 
39
 - (RNNNavigationOptions *)options {
51
 - (RNNNavigationOptions *)options {
40
-	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController).options;
52
+	return self.getTopViewController.options;
41
 }
53
 }
42
 
54
 
43
 - (UIViewController *)childViewControllerForStatusBarStyle {
55
 - (UIViewController *)childViewControllerForStatusBarStyle {

+ 16
- 15
lib/ios/RNNNavigationOptions.m View File

31
 @implementation RCTConvert (UIModalTransitionStyle)
31
 @implementation RCTConvert (UIModalTransitionStyle)
32
 
32
 
33
 RCT_ENUM_CONVERTER(UIModalTransitionStyle,
33
 RCT_ENUM_CONVERTER(UIModalTransitionStyle,
34
-                   (@{@"coverVertical": @(UIModalTransitionStyleCoverVertical),
35
-                      @"flipHorizontal": @(UIModalTransitionStyleFlipHorizontal),
36
-                      @"crossDissolve": @(UIModalTransitionStyleCrossDissolve),
37
-                      @"partialCurl": @(UIModalTransitionStylePartialCurl)
38
-                      }), UIModalTransitionStyleCoverVertical, integerValue)
34
+				   (@{@"coverVertical": @(UIModalTransitionStyleCoverVertical),
35
+					  @"flipHorizontal": @(UIModalTransitionStyleFlipHorizontal),
36
+					  @"crossDissolve": @(UIModalTransitionStyleCrossDissolve),
37
+					  @"partialCurl": @(UIModalTransitionStylePartialCurl)
38
+					  }), UIModalTransitionStyleCoverVertical, integerValue)
39
 
39
 
40
 @end
40
 @end
41
 
41
 
67
 			backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
67
 			backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
68
 			[viewController.view insertSubview:backgroundImageView atIndex:0];
68
 			[viewController.view insertSubview:backgroundImageView atIndex:0];
69
 		}
69
 		}
70
-
70
+		
71
 		backgroundImageView.layer.masksToBounds = YES;
71
 		backgroundImageView.layer.masksToBounds = YES;
72
 		backgroundImageView.image = [self.backgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.backgroundImage : [RCTConvert UIImage:self.backgroundImage];
72
 		backgroundImageView.image = [self.backgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.backgroundImage : [RCTConvert UIImage:self.backgroundImage];
73
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
73
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
79
 			backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
79
 			backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
80
 			[viewController.navigationController.view insertSubview:backgroundImageView atIndex:0];
80
 			[viewController.navigationController.view insertSubview:backgroundImageView atIndex:0];
81
 		}
81
 		}
82
-
82
+		
83
 		backgroundImageView.layer.masksToBounds = YES;
83
 		backgroundImageView.layer.masksToBounds = YES;
84
 		backgroundImageView.image = [self.rootBackgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.rootBackgroundImage : [RCTConvert UIImage:self.rootBackgroundImage];
84
 		backgroundImageView.image = [self.rootBackgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.rootBackgroundImage : [RCTConvert UIImage:self.rootBackgroundImage];
85
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
85
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
86
 	}
86
 	}
87
-    
88
-    [self applyModalOptions:viewController];
87
+	
88
+	[self applyModalOptions:viewController];
89
 }
89
 }
90
 
90
 
91
 - (void)applyModalOptions:(UIViewController*)viewController {
91
 - (void)applyModalOptions:(UIViewController*)viewController {
92
-    if (self.modalPresentationStyle) {
93
-        viewController.modalPresentationStyle = [RCTConvert UIModalPresentationStyle:self.modalPresentationStyle];
94
-    }
95
-    if (self.modalTransitionStyle) {
96
-        viewController.modalTransitionStyle = [RCTConvert UIModalTransitionStyle:self.modalTransitionStyle];
97
-    }
92
+	if (self.modalPresentationStyle) {
93
+		viewController.modalPresentationStyle = [RCTConvert UIModalPresentationStyle:self.modalPresentationStyle];
94
+		[viewController.view setBackgroundColor:[UIColor clearColor]];
95
+	}
96
+	if (self.modalTransitionStyle) {
97
+		viewController.modalTransitionStyle = [RCTConvert UIModalTransitionStyle:self.modalTransitionStyle];
98
+	}
98
 }
99
 }
99
 
100
 
100
 
101
 

+ 48
- 47
lib/ios/RNNRootViewController.m View File

37
 	if (!self.isExternalComponent) {
37
 	if (!self.isExternalComponent) {
38
 		self.view = [creator createRootView:self.componentName rootViewId:self.componentId];
38
 		self.view = [creator createRootView:self.componentName rootViewId:self.componentId];
39
 	}
39
 	}
40
-
40
+	
41
 	[[NSNotificationCenter defaultCenter] addObserver:self
41
 	[[NSNotificationCenter defaultCenter] addObserver:self
42
 											 selector:@selector(onJsReload)
42
 											 selector:@selector(onJsReload)
43
 												 name:RCTJavaScriptWillStartLoadingNotification
43
 												 name:RCTJavaScriptWillStartLoadingNotification
81
 }
81
 }
82
 
82
 
83
 - (void)applyModalOptions {
83
 - (void)applyModalOptions {
84
-    [self.options applyModalOptions:self];
84
+	[self.options applyOn:self];
85
+	[self.options applyModalOptions:self];
85
 }
86
 }
86
 
87
 
87
 - (void)mergeOptions:(NSDictionary *)options {
88
 - (void)mergeOptions:(NSDictionary *)options {
100
 		} if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
101
 		} if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
101
 			self.navigationItem.title = nil;
102
 			self.navigationItem.title = nil;
102
 		}
103
 		}
103
-    } else if (_customTitleView && _customTitleView.superview == nil) {
104
-        if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
105
-            self.navigationItem.title = nil;
106
-        }
107
-        self.navigationItem.titleView = _customTitleView;
108
-    }
104
+	} else if (_customTitleView && _customTitleView.superview == nil) {
105
+		if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
106
+			self.navigationItem.title = nil;
107
+		}
108
+		self.navigationItem.titleView = _customTitleView;
109
+	}
109
 }
110
 }
110
 
111
 
111
 - (void)setCustomNavigationBarView {
112
 - (void)setCustomNavigationBarView {
120
 		} else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
121
 		} else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
121
 			[[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
122
 			[[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
122
 		}
123
 		}
123
-    } else if (_customTopBar && _customTopBar.superview == nil) {
124
-        if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
125
-            [[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
126
-        }
127
-        [self.navigationController.navigationBar addSubview:_customTopBar];
128
-    }
124
+	} else if (_customTopBar && _customTopBar.superview == nil) {
125
+		if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
126
+			[[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
127
+		}
128
+		[self.navigationController.navigationBar addSubview:_customTopBar];
129
+	}
129
 }
130
 }
130
 
131
 
131
 - (void)setCustomNavigationComponentBackground {
132
 - (void)setCustomNavigationComponentBackground {
140
 			[[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
141
 			[[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
141
 			self.navigationController.navigationBar.clipsToBounds = NO;
142
 			self.navigationController.navigationBar.clipsToBounds = NO;
142
 		}
143
 		}
143
-    } if (_customTopBarBackground && _customTopBarBackground.superview == nil) {
144
-        if ([[self.navigationController.navigationBar.subviews objectAtIndex:1] isKindOfClass:[RNNCustomTitleView class]]) {
145
-            [[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
146
-        }
147
-        [self.navigationController.navigationBar insertSubview:_customTopBarBackground atIndex:1];
148
-        self.navigationController.navigationBar.clipsToBounds = YES;
149
-    }
144
+	} if (_customTopBarBackground && _customTopBarBackground.superview == nil) {
145
+		if ([[self.navigationController.navigationBar.subviews objectAtIndex:1] isKindOfClass:[RNNCustomTitleView class]]) {
146
+			[[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
147
+		}
148
+		[self.navigationController.navigationBar insertSubview:_customTopBarBackground atIndex:1];
149
+		self.navigationController.navigationBar.clipsToBounds = YES;
150
+	}
150
 }
151
 }
151
 
152
 
152
 -(BOOL)isCustomTransitioned {
153
 -(BOOL)isCustomTransitioned {
163
 	} else if ([self.options.statusBar.hideWithTopBar boolValue]) {
164
 	} else if ([self.options.statusBar.hideWithTopBar boolValue]) {
164
 		return self.navigationController.isNavigationBarHidden;
165
 		return self.navigationController.isNavigationBarHidden;
165
 	}
166
 	}
166
-
167
+	
167
 	return NO;
168
 	return NO;
168
 }
169
 }
169
 
170
 
198
 								  animationControllerForOperation:(UINavigationControllerOperation)operation
199
 								  animationControllerForOperation:(UINavigationControllerOperation)operation
199
 											   fromViewController:(UIViewController*)fromVC
200
 											   fromViewController:(UIViewController*)fromVC
200
 												 toViewController:(UIViewController*)toVC {
201
 												 toViewController:(UIViewController*)toVC {
201
-{
202
-	if (self.animator) {
203
-		return self.animator;
204
-	} else if (operation == UINavigationControllerOperationPush && self.options.animations.push.hasCustomAnimation) {
205
-		return [[RNNPushAnimation alloc] initWithScreenTransition:self.options.animations.push];
206
-	} else if (operation == UINavigationControllerOperationPop && self.options.animations.pop.hasCustomAnimation) {
207
-		return [[RNNPushAnimation alloc] initWithScreenTransition:self.options.animations.pop];
208
-	} else {
209
-		return nil;
202
+	{
203
+		if (self.animator) {
204
+			return self.animator;
205
+		} else if (operation == UINavigationControllerOperationPush && self.options.animations.push.hasCustomAnimation) {
206
+			return [[RNNPushAnimation alloc] initWithScreenTransition:self.options.animations.push];
207
+		} else if (operation == UINavigationControllerOperationPop && self.options.animations.pop.hasCustomAnimation) {
208
+			return [[RNNPushAnimation alloc] initWithScreenTransition:self.options.animations.pop];
209
+		} else {
210
+			return nil;
211
+		}
210
 	}
212
 	}
211
-}
212
 	return nil;
213
 	return nil;
213
 }
214
 }
214
 
215
 
242
 	if (self.previewController) {
243
 	if (self.previewController) {
243
 		RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
244
 		RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
244
 		[_eventEmitter sendOnNavigationEvent:@"previewContext" params:@{
245
 		[_eventEmitter sendOnNavigationEvent:@"previewContext" params:@{
245
-																   @"previewComponentId": vc.componentId,
246
-																   @"componentId": self.componentId
247
-																   }];
246
+																		@"previewComponentId": vc.componentId,
247
+																		@"componentId": self.componentId
248
+																		}];
248
 	}
249
 	}
249
 	return self.previewController;
250
 	return self.previewController;
250
 }
251
 }
253
 - (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
254
 - (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
254
 	RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
255
 	RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
255
 	NSDictionary * params = @{
256
 	NSDictionary * params = @{
256
-						  @"previewComponentId": vc.componentId,
257
-						  @"componentId": self.componentId
258
-						  };
257
+							  @"previewComponentId": vc.componentId,
258
+							  @"componentId": self.componentId
259
+							  };
259
 	if (vc.options.preview.commit) {
260
 	if (vc.options.preview.commit) {
260
 		[_eventEmitter sendOnNavigationEvent:@"previewCommit" params:params];
261
 		[_eventEmitter sendOnNavigationEvent:@"previewCommit" params:params];
261
 		[self.navigationController pushViewController:vc animated:false];
262
 		[self.navigationController pushViewController:vc animated:false];
273
 	NSString *actionTitle = action[@"title"];
274
 	NSString *actionTitle = action[@"title"];
274
 	UIPreviewActionStyle actionStyle = UIPreviewActionStyleDefault;
275
 	UIPreviewActionStyle actionStyle = UIPreviewActionStyleDefault;
275
 	if ([action[@"style"] isEqualToString:@"selected"]) {
276
 	if ([action[@"style"] isEqualToString:@"selected"]) {
276
-	   	actionStyle = UIPreviewActionStyleSelected;
277
+		actionStyle = UIPreviewActionStyleSelected;
277
 	} else if ([action[@"style"] isEqualToString:@"destructive"]) {
278
 	} else if ([action[@"style"] isEqualToString:@"destructive"]) {
278
 		actionStyle = UIPreviewActionStyleDestructive;
279
 		actionStyle = UIPreviewActionStyleDestructive;
279
 	}
280
 	}
288
 	for (NSDictionary *previewAction in self.options.preview.actions) {
289
 	for (NSDictionary *previewAction in self.options.preview.actions) {
289
 		UIPreviewAction *action = [self convertAction:previewAction];
290
 		UIPreviewAction *action = [self convertAction:previewAction];
290
 		NSDictionary *actionActions = previewAction[@"actions"];
291
 		NSDictionary *actionActions = previewAction[@"actions"];
291
-	    if (actionActions.count > 0) {
292
+		if (actionActions.count > 0) {
292
 			NSMutableArray *group = [[NSMutableArray alloc] init];
293
 			NSMutableArray *group = [[NSMutableArray alloc] init];
293
-	     	for (NSDictionary *previewGroupAction in actionActions) {
294
-	        	[group addObject:[self convertAction:previewGroupAction]];
295
-	      	}
296
-	      	UIPreviewActionGroup *actionGroup = [UIPreviewActionGroup actionGroupWithTitle:action.title style:UIPreviewActionStyleDefault actions:group];
297
-	      	[actions addObject:actionGroup];
294
+			for (NSDictionary *previewGroupAction in actionActions) {
295
+				[group addObject:[self convertAction:previewGroupAction]];
296
+			}
297
+			UIPreviewActionGroup *actionGroup = [UIPreviewActionGroup actionGroupWithTitle:action.title style:UIPreviewActionStyleDefault actions:group];
298
+			[actions addObject:actionGroup];
298
 		} else {
299
 		} else {
299
-	    	[actions addObject:action];
300
-	    }
300
+			[actions addObject:action];
301
+		}
301
 	}
302
 	}
302
 	return actions;
303
 	return actions;
303
 }
304
 }