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

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

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

+ 4
- 4
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
 	UIViewController *topVC = [self topPresentedVC];
24
 	UIViewController *topVC = [self topPresentedVC];
25
-	[topVC presentViewController:self.toVC animated:YES completion:^{
25
+	[topVC presentViewController:self.toVC animated:self.toVC.isAnimated completion:^{
26
 		if (_completionBlock) {
26
 		if (_completionBlock) {
27
 			_completionBlock();
27
 			_completionBlock();
28
 			_completionBlock = nil;
28
 			_completionBlock = nil;
31
 }
31
 }
32
 
32
 
33
 -(void)showModal:(UIViewController *)viewController completion:(RNNTransitionCompletionBlock)completion {
33
 -(void)showModal:(UIViewController *)viewController completion:(RNNTransitionCompletionBlock)completion {
34
-	self.toVC = viewController;
34
+	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
35
 	_completionBlock = completion;
35
 	_completionBlock = completion;
36
 	[self waitForContentToAppearAndThen:@selector(showModalAfterLoad:)];
36
 	[self waitForContentToAppearAndThen:@selector(showModalAfterLoad:)];
37
 }
37
 }
53
 -(void)removePendingNextModalIfOnTop {
53
 -(void)removePendingNextModalIfOnTop {
54
 	NSString *componentId = [[_store pendingModalIdsToDismiss] lastObject];
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
 	if(!modalToDismiss) {
58
 	if(!modalToDismiss) {
59
 		return;
59
 		return;
62
 	UIViewController* topPresentedVC = [self topPresentedVC];
62
 	UIViewController* topPresentedVC = [self topPresentedVC];
63
 	
63
 	
64
 	if (modalToDismiss == topPresentedVC || [[topPresentedVC childViewControllers] containsObject:modalToDismiss]) {
64
 	if (modalToDismiss == topPresentedVC || [[topPresentedVC childViewControllers] containsObject:modalToDismiss]) {
65
-		[modalToDismiss dismissViewControllerAnimated:YES completion:^{
65
+		[modalToDismiss dismissViewControllerAnimated:modalToDismiss.isAnimated completion:^{
66
 			[[_store pendingModalIdsToDismiss] removeObject:componentId];
66
 			[[_store pendingModalIdsToDismiss] removeObject:componentId];
67
 			[self removePendingNextModalIfOnTop];
67
 			[self removePendingNextModalIfOnTop];
68
 		}];
68
 		}];

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

11
 	return NO;
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
 - (NSString *)componentId {
19
 - (NSString *)componentId {
15
 	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController).componentId;
20
 	return ((UIViewController<RNNRootViewProtocol>*)self.topViewController).componentId;
16
 }
21
 }

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

23
 
23
 
24
 @property (nonatomic, strong) RNNNavigationOptions* defaultOptions;
24
 @property (nonatomic, strong) RNNNavigationOptions* defaultOptions;
25
 
25
 
26
+@property (nonatomic, strong) NSNumber* animated;
26
 @property (nonatomic, strong) NSNumber* statusBarHidden;
27
 @property (nonatomic, strong) NSNumber* statusBarHidden;
27
 @property (nonatomic, strong) NSNumber* screenBackgroundColor;
28
 @property (nonatomic, strong) NSNumber* screenBackgroundColor;
28
 @property (nonatomic, strong) NSMutableDictionary* originalTopBarImages;
29
 @property (nonatomic, strong) NSMutableDictionary* originalTopBarImages;

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

31
 	self.rootBackgroundImage = [RCTConvert UIImage:[options objectForKey:@"rootBackgroundImage"]];
31
 	self.rootBackgroundImage = [RCTConvert UIImage:[options objectForKey:@"rootBackgroundImage"]];
32
 	self.bottomTab = [[RNNBottomTabOptions alloc] initWithDict:[options objectForKey:@"bottomTab"]];
32
 	self.bottomTab = [[RNNBottomTabOptions alloc] initWithDict:[options objectForKey:@"bottomTab"]];
33
 	self.overlay = [[RNNOverlayOptions alloc] initWithDict:[options objectForKey:@"overlay"]];
33
 	self.overlay = [[RNNOverlayOptions alloc] initWithDict:[options objectForKey:@"overlay"]];
34
+	self.animated = [options objectForKey:@"animated"];
34
 	
35
 	
35
 	return self;
36
 	return self;
36
 }
37
 }

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

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

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

70
 	return self.animator != nil;
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
 - (BOOL)prefersStatusBarHidden {
77
 - (BOOL)prefersStatusBarHidden {
74
 	if ([self.options.statusBarHidden boolValue]) {
78
 	if ([self.options.statusBarHidden boolValue]) {
75
 		return YES;
79
 		return YES;

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

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

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

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

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

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

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

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

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

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

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

38
 	self.uut = [[RNNNavigationStackManager alloc] initWithStore:self.store];
38
 	self.uut = [[RNNNavigationStackManager alloc] initWithStore:self.store];
39
 	
39
 	
40
 	self.nvc = [[MockUINavigationController alloc] init];
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
 	NSArray *vcArray = @[self.vc1, self.vc2, self.vc3];
44
 	NSArray *vcArray = @[self.vc1, self.vc2, self.vc3];
45
 	[self.nvc setViewControllers:vcArray];
45
 	[self.nvc setViewControllers:vcArray];
46
 	
46
 	

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

54
         passProps: {
54
         passProps: {
55
           modalPosition: this.getModalPosition() + 1,
55
           modalPosition: this.getModalPosition() + 1,
56
           previousModalIds: _.concat([], this.props.previousModalIds || [], this.props.componentId)
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
   onClickPushOptionsScreen() {
213
   onClickPushOptionsScreen() {
214
     Navigation.push(this.props.componentId, {
214
     Navigation.push(this.props.componentId, {
215
       component: {
215
       component: {
216
-        name: 'navigation.playground.OptionsScreen'
216
+        name: 'navigation.playground.OptionsScreen',
217
+        options: {
218
+          animated: false
219
+        }
217
       }
220
       }
218
     });
221
     });
219
   }
222
   }