Browse Source

Resolves componentId on showModal

yogevbd 6 years ago
parent
commit
2d879ccd0c

+ 2
- 2
lib/ios/RNNBridgeModule.m View File

68
 }
68
 }
69
 
69
 
70
 RCT_EXPORT_METHOD(showModal:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
70
 RCT_EXPORT_METHOD(showModal:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
71
-	[_commandsHandler showModal:layout completion:^{
72
-		resolve(nil);
71
+	[_commandsHandler showModal:layout completion:^(NSString *componentId) {
72
+		resolve(componentId);
73
 	}];
73
 	}];
74
 }
74
 }
75
 
75
 

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

24
 
24
 
25
 -(void)setStackRoot:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
25
 -(void)setStackRoot:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
26
 
26
 
27
--(void)showModal:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion;
27
+-(void)showModal:(NSDictionary*)layout completion:(RNNTransitionWithComponentIdCompletionBlock)completion;
28
 
28
 
29
 -(void)dismissModal:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion;
29
 -(void)dismissModal:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion;
30
 
30
 

+ 3
- 3
lib/ios/RNNCommandsHandler.m View File

205
 	[CATransaction commit];
205
 	[CATransaction commit];
206
 }
206
 }
207
 
207
 
208
-- (void)showModal:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion {
208
+- (void)showModal:(NSDictionary*)layout completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
209
 	[self assertReady];
209
 	[self assertReady];
210
 
210
 
211
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
211
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
212
-	[_modalManager showModal:newVc animated:newVc.getLeafViewController.options.animations.showModal.enable completion:^{
212
+	[_modalManager showModal:newVc animated:newVc.getLeafViewController.options.animations.showModal.enable completion:^(NSString *componentId) {
213
 		[_eventEmitter sendOnNavigationCommandCompletion:showModal params:@{@"layout": layout}];
213
 		[_eventEmitter sendOnNavigationCommandCompletion:showModal params:@{@"layout": layout}];
214
-		completion();
214
+		completion(componentId);
215
 	}];
215
 	}];
216
 }
216
 }
217
 
217
 

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

7
 @property (nonatomic, strong) UIViewController<RNNRootViewProtocol>* 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 animated:(BOOL)animated completion:(RNNTransitionCompletionBlock)completion;
10
+- (void)showModal:(UIViewController*)viewController animated:(BOOL)animated completion:(RNNTransitionWithComponentIdCompletionBlock)completion;
11
 - (void)dismissModal:(NSString *)componentId completion:(RNNTransitionCompletionBlock)completion;
11
 - (void)dismissModal:(NSString *)componentId completion:(RNNTransitionCompletionBlock)completion;
12
 - (void)dismissAllModals;
12
 - (void)dismissAllModals;
13
 
13
 

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

3
 
3
 
4
 @implementation RNNModalManager {
4
 @implementation RNNModalManager {
5
 	RNNStore *_store;
5
 	RNNStore *_store;
6
-	RNNTransitionCompletionBlock _completionBlock;
6
+	RNNTransitionWithComponentIdCompletionBlock _completionBlock;
7
 }
7
 }
8
 
8
 
9
 
9
 
27
 	
27
 	
28
 	[topVC presentViewController:self.toVC animated:animated completion:^{
28
 	[topVC presentViewController:self.toVC animated:animated completion:^{
29
 		if (_completionBlock) {
29
 		if (_completionBlock) {
30
-			_completionBlock();
30
+			_completionBlock(self.toVC.getLeafViewController.componentId);
31
 			_completionBlock = nil;
31
 			_completionBlock = nil;
32
 		}
32
 		}
33
 		self.toVC = nil;
33
 		self.toVC = nil;
34
 	}];
34
 	}];
35
 }
35
 }
36
 
36
 
37
--(void)showModal:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNTransitionCompletionBlock)completion {
37
+-(void)showModal:(UIViewController *)viewController animated:(BOOL)animated completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
38
 	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
38
 	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
39
 	RNNNavigationOptions* options = self.toVC.getLeafViewController.options;
39
 	RNNNavigationOptions* options = self.toVC.getLeafViewController.options;
40
 
40
 

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

5
 #import "ReactNativeNavigation.h"
5
 #import "ReactNativeNavigation.h"
6
 
6
 
7
 typedef void (^RNNTransitionCompletionBlock)(void);
7
 typedef void (^RNNTransitionCompletionBlock)(void);
8
+typedef void (^RNNTransitionWithComponentIdCompletionBlock)(NSString *componentId);
8
 typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, NSError *error);
9
 typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, NSError *error);
9
 
10
 
10
 @interface RNNStore : NSObject
11
 @interface RNNStore : NSObject