yogevbd 6 years ago
parent
commit
ff2f9cd7a3
No account linked to committer's email address

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

@@ -4,7 +4,7 @@
4 4
 
5 5
 @interface RNNModalManager : NSObject
6 6
 
7
-@property (nonatomic, strong) UIViewController* toVC;
7
+@property (nonatomic, strong) UIViewController<RNNRootViewProtocol>* toVC;
8 8
 
9 9
 -(instancetype)initWithStore:(RNNStore*)store;
10 10
 -(void)showModal:(UIViewController*)viewController completion:(RNNTransitionCompletionBlock)completion;

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

@@ -22,7 +22,7 @@
22 22
 -(void)showModalAfterLoad:(NSDictionary*)notif {
23 23
 	[[NSNotificationCenter defaultCenter] removeObserver:self name:@"RCTContentDidAppearNotification" object:nil];
24 24
 	UIViewController *topVC = [self topPresentedVC];
25
-	[topVC presentViewController:self.toVC animated:YES completion:^{
25
+	[topVC presentViewController:self.toVC animated:self.toVC.isAnimated completion:^{
26 26
 		if (_completionBlock) {
27 27
 			_completionBlock();
28 28
 			_completionBlock = nil;
@@ -31,7 +31,7 @@
31 31
 }
32 32
 
33 33
 -(void)showModal:(UIViewController *)viewController completion:(RNNTransitionCompletionBlock)completion {
34
-	self.toVC = viewController;
34
+	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
35 35
 	_completionBlock = completion;
36 36
 	[self waitForContentToAppearAndThen:@selector(showModalAfterLoad:)];
37 37
 }
@@ -53,7 +53,7 @@
53 53
 -(void)removePendingNextModalIfOnTop {
54 54
 	NSString *componentId = [[_store pendingModalIdsToDismiss] lastObject];
55 55
 	
56
-	UIViewController *modalToDismiss = [_store findComponentForId:componentId];
56
+	UIViewController<RNNRootViewProtocol> *modalToDismiss = (UIViewController<RNNRootViewProtocol>*)[_store findComponentForId:componentId];
57 57
 	
58 58
 	if(!modalToDismiss) {
59 59
 		return;
@@ -62,7 +62,7 @@
62 62
 	UIViewController* topPresentedVC = [self topPresentedVC];
63 63
 	
64 64
 	if (modalToDismiss == topPresentedVC || [[topPresentedVC childViewControllers] containsObject:modalToDismiss]) {
65
-		[modalToDismiss dismissViewControllerAnimated:YES completion:^{
65
+		[modalToDismiss dismissViewControllerAnimated:modalToDismiss.isAnimated completion:^{
66 66
 			[[_store pendingModalIdsToDismiss] removeObject:componentId];
67 67
 			[self removePendingNextModalIfOnTop];
68 68
 		}];

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

@@ -11,6 +11,11 @@
11 11
 	return NO;
12 12
 }
13 13
 
14
+- (BOOL)isAnimated {
15
+	UIViewController<RNNRootViewProtocol>* rootVC = (UIViewController<RNNRootViewProtocol>*) self.topViewController;
16
+	return rootVC.isAnimated;
17
+}
18
+
14 19
 - (NSString *)componentId {
15 20
 	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController).componentId;
16 21
 }

+ 1
- 0
lib/ios/RNNNavigationOptions.h View File

@@ -23,6 +23,7 @@ extern const NSInteger TOP_BAR_TRANSPARENT_TAG;
23 23
 
24 24
 @property (nonatomic, strong) RNNNavigationOptions* defaultOptions;
25 25
 
26
+@property (nonatomic, strong) NSNumber* animated;
26 27
 @property (nonatomic, strong) NSNumber* statusBarHidden;
27 28
 @property (nonatomic, strong) NSNumber* screenBackgroundColor;
28 29
 @property (nonatomic, strong) NSMutableDictionary* originalTopBarImages;

+ 1
- 0
lib/ios/RNNNavigationOptions.m View File

@@ -31,6 +31,7 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
31 31
 	self.rootBackgroundImage = [RCTConvert UIImage:[options objectForKey:@"rootBackgroundImage"]];
32 32
 	self.bottomTab = [[RNNBottomTabOptions alloc] initWithDict:[options objectForKey:@"bottomTab"]];
33 33
 	self.overlay = [[RNNOverlayOptions alloc] initWithDict:[options objectForKey:@"overlay"]];
34
+	self.animated = [options objectForKey:@"animated"];
34 35
 	
35 36
 	return self;
36 37
 }

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

@@ -52,7 +52,7 @@ dispatch_queue_t RCTGetUIManagerQueue(void);
52 52
 		}
53 53
 	}];
54 54
 	
55
-	[[self.fromVC navigationController] pushViewController:self.toVC animated:YES];
55
+	[[self.fromVC navigationController] pushViewController:self.toVC animated:self.toVC.isAnimated];
56 56
 	[CATransaction commit];
57 57
 	
58 58
 	self.toVC = nil;
@@ -61,17 +61,17 @@ dispatch_queue_t RCTGetUIManagerQueue(void);
61 61
 }
62 62
 
63 63
 -(void)pop:(NSString *)componentId withAnimationData:(NSDictionary *)animationData {
64
-	UIViewController* vc = [_store findComponentForId:componentId];
64
+	UIViewController<RNNRootViewProtocol>* vc = (UIViewController<RNNRootViewProtocol>*)[_store findComponentForId:componentId];
65 65
 	UINavigationController* nvc = [vc navigationController];
66 66
 	if ([nvc topViewController] == vc) {
67 67
 		if (animationData) {
68 68
 			RNNRootViewController* RNNVC = (RNNRootViewController*)vc;
69 69
 			nvc.delegate = RNNVC;
70 70
 			[RNNVC.animator setupTransition:animationData];
71
-			[nvc popViewControllerAnimated:YES];
71
+			[nvc popViewControllerAnimated:vc.isAnimated];
72 72
 		} else {
73 73
 			nvc.delegate = nil;
74
-			[nvc popViewControllerAnimated:YES];
74
+			[nvc popViewControllerAnimated:vc.isAnimated];
75 75
 		}
76 76
 	} else {
77 77
 		NSMutableArray * vcs = nvc.viewControllers.mutableCopy;

+ 4
- 0
lib/ios/RNNRootViewController.m View File

@@ -70,6 +70,10 @@
70 70
 	return self.animator != nil;
71 71
 }
72 72
 
73
+- (BOOL)isAnimated {
74
+	return self.options.animated ? [self.options.animated boolValue] : YES;
75
+}
76
+
73 77
 - (BOOL)prefersStatusBarHidden {
74 78
 	if ([self.options.statusBarHidden boolValue]) {
75 79
 		return YES;

+ 2
- 0
lib/ios/RNNRootViewProtocol.h View File

@@ -5,6 +5,8 @@
5 5
 @required
6 6
 
7 7
 - (BOOL)isCustomTransitioned;
8
+- (BOOL)isAnimated;
9
+
8 10
 - (NSString *)componentId;
9 11
 
10 12
 @end

+ 4
- 0
lib/ios/RNNSideMenuChildVC.m View File

@@ -37,6 +37,10 @@
37 37
 	return NO;
38 38
 }
39 39
 
40
+- (BOOL)isAnimated {
41
+	return YES;
42
+}
43
+
40 44
 - (NSString *)componentId {
41 45
 	return _child.componentId;
42 46
 }

+ 4
- 0
lib/ios/RNNSideMenuController.m View File

@@ -76,6 +76,10 @@
76 76
 	return NO;
77 77
 }
78 78
 
79
+- (BOOL)isAnimated {
80
+	return YES;
81
+}
82
+
79 83
 - (NSString *)componentId {
80 84
 	return _center.componentId;
81 85
 }

+ 4
- 0
lib/ios/RNNTabBarController.m View File

@@ -37,6 +37,10 @@
37 37
 	return NO;
38 38
 }
39 39
 
40
+- (BOOL)isAnimated {
41
+	return YES;
42
+}
43
+
40 44
 - (NSString *)componentId {
41 45
 	return ((UIViewController<RNNRootViewProtocol>*)self.selectedViewController).componentId;
42 46
 }

+ 4
- 0
lib/ios/RNNTopTabsViewController.m View File

@@ -76,6 +76,10 @@
76 76
 	return NO;
77 77
 }
78 78
 
79
+- (BOOL)isAnimated {
80
+	return YES;
81
+}
82
+
79 83
 - (NSString *)componentId {
80 84
 	return _currentViewController.componentId;
81 85
 }

+ 3
- 3
lib/ios/ReactNativeNavigationTests/RNNNavigationStackManagerTest.m View File

@@ -38,9 +38,9 @@
38 38
 	self.uut = [[RNNNavigationStackManager alloc] initWithStore:self.store];
39 39
 	
40 40
 	self.nvc = [[MockUINavigationController alloc] init];
41
-	self.vc1 = [UIViewController new];
42
-	self.vc2 = [UIViewController new];
43
-	self.vc3 = [UIViewController new];
41
+	self.vc1 = [RNNRootViewController new];
42
+	self.vc2 = [RNNRootViewController new];
43
+	self.vc3 = [RNNRootViewController new];
44 44
 	NSArray *vcArray = @[self.vc1, self.vc2, self.vc3];
45 45
 	[self.nvc setViewControllers:vcArray];
46 46
 	

+ 3
- 0
playground/src/screens/ModalScreen.js View File

@@ -54,6 +54,9 @@ class ModalScreen extends Component {
54 54
         passProps: {
55 55
           modalPosition: this.getModalPosition() + 1,
56 56
           previousModalIds: _.concat([], this.props.previousModalIds || [], this.props.componentId)
57
+        },
58
+        options: {
59
+          animated: false
57 60
         }
58 61
       }
59 62
     });

+ 4
- 1
playground/src/screens/WelcomeScreen.js View File

@@ -213,7 +213,10 @@ class WelcomeScreen extends Component {
213 213
   onClickPushOptionsScreen() {
214 214
     Navigation.push(this.props.componentId, {
215 215
       component: {
216
-        name: 'navigation.playground.OptionsScreen'
216
+        name: 'navigation.playground.OptionsScreen',
217
+        options: {
218
+          animated: false
219
+        }
217 220
       }
218 221
     });
219 222
   }