yogevbd 6 anos atrás
pai
commit
db013e8e67

+ 2
- 0
lib/ios/RNNModalManager.m Ver arquivo

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

+ 17
- 5
lib/ios/RNNNavigationController.m Ver arquivo

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

+ 16
- 15
lib/ios/RNNNavigationOptions.m Ver arquivo

@@ -31,11 +31,11 @@ RCT_ENUM_CONVERTER(UIModalPresentationStyle,
31 31
 @implementation RCTConvert (UIModalTransitionStyle)
32 32
 
33 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 40
 @end
41 41
 
@@ -67,7 +67,7 @@ RCT_ENUM_CONVERTER(UIModalTransitionStyle,
67 67
 			backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
68 68
 			[viewController.view insertSubview:backgroundImageView atIndex:0];
69 69
 		}
70
-
70
+		
71 71
 		backgroundImageView.layer.masksToBounds = YES;
72 72
 		backgroundImageView.image = [self.backgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.backgroundImage : [RCTConvert UIImage:self.backgroundImage];
73 73
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
@@ -79,22 +79,23 @@ RCT_ENUM_CONVERTER(UIModalTransitionStyle,
79 79
 			backgroundImageView = [[UIImageView alloc] initWithFrame:viewController.view.bounds];
80 80
 			[viewController.navigationController.view insertSubview:backgroundImageView atIndex:0];
81 81
 		}
82
-
82
+		
83 83
 		backgroundImageView.layer.masksToBounds = YES;
84 84
 		backgroundImageView.image = [self.rootBackgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.rootBackgroundImage : [RCTConvert UIImage:self.rootBackgroundImage];
85 85
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
86 86
 	}
87
-    
88
-    [self applyModalOptions:viewController];
87
+	
88
+	[self applyModalOptions:viewController];
89 89
 }
90 90
 
91 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 Ver arquivo

@@ -37,7 +37,7 @@
37 37
 	if (!self.isExternalComponent) {
38 38
 		self.view = [creator createRootView:self.componentName rootViewId:self.componentId];
39 39
 	}
40
-
40
+	
41 41
 	[[NSNotificationCenter defaultCenter] addObserver:self
42 42
 											 selector:@selector(onJsReload)
43 43
 												 name:RCTJavaScriptWillStartLoadingNotification
@@ -81,7 +81,8 @@
81 81
 }
82 82
 
83 83
 - (void)applyModalOptions {
84
-    [self.options applyModalOptions:self];
84
+	[self.options applyOn:self];
85
+	[self.options applyModalOptions:self];
85 86
 }
86 87
 
87 88
 - (void)mergeOptions:(NSDictionary *)options {
@@ -100,12 +101,12 @@
100 101
 		} if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
101 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 112
 - (void)setCustomNavigationBarView {
@@ -120,12 +121,12 @@
120 121
 		} else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
121 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 132
 - (void)setCustomNavigationComponentBackground {
@@ -140,13 +141,13 @@
140 141
 			[[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
141 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 153
 -(BOOL)isCustomTransitioned {
@@ -163,7 +164,7 @@
163 164
 	} else if ([self.options.statusBar.hideWithTopBar boolValue]) {
164 165
 		return self.navigationController.isNavigationBarHidden;
165 166
 	}
166
-
167
+	
167 168
 	return NO;
168 169
 }
169 170
 
@@ -198,17 +199,17 @@
198 199
 								  animationControllerForOperation:(UINavigationControllerOperation)operation
199 200
 											   fromViewController:(UIViewController*)fromVC
200 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 213
 	return nil;
213 214
 }
214 215
 
@@ -242,9 +243,9 @@
242 243
 	if (self.previewController) {
243 244
 		RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
244 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 250
 	return self.previewController;
250 251
 }
@@ -253,9 +254,9 @@
253 254
 - (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
254 255
 	RNNRootViewController * vc = (RNNRootViewController*) self.previewController;
255 256
 	NSDictionary * params = @{
256
-						  @"previewComponentId": vc.componentId,
257
-						  @"componentId": self.componentId
258
-						  };
257
+							  @"previewComponentId": vc.componentId,
258
+							  @"componentId": self.componentId
259
+							  };
259 260
 	if (vc.options.preview.commit) {
260 261
 		[_eventEmitter sendOnNavigationEvent:@"previewCommit" params:params];
261 262
 		[self.navigationController pushViewController:vc animated:false];
@@ -273,7 +274,7 @@
273 274
 	NSString *actionTitle = action[@"title"];
274 275
 	UIPreviewActionStyle actionStyle = UIPreviewActionStyleDefault;
275 276
 	if ([action[@"style"] isEqualToString:@"selected"]) {
276
-	   	actionStyle = UIPreviewActionStyleSelected;
277
+		actionStyle = UIPreviewActionStyleSelected;
277 278
 	} else if ([action[@"style"] isEqualToString:@"destructive"]) {
278 279
 		actionStyle = UIPreviewActionStyleDestructive;
279 280
 	}
@@ -288,16 +289,16 @@
288 289
 	for (NSDictionary *previewAction in self.options.preview.actions) {
289 290
 		UIPreviewAction *action = [self convertAction:previewAction];
290 291
 		NSDictionary *actionActions = previewAction[@"actions"];
291
-	    if (actionActions.count > 0) {
292
+		if (actionActions.count > 0) {
292 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 299
 		} else {
299
-	    	[actions addObject:action];
300
-	    }
300
+			[actions addObject:action];
301
+		}
301 302
 	}
302 303
 	return actions;
303 304
 }