|
@@ -2,108 +2,136 @@
|
2
|
2
|
#import "Constants.h"
|
3
|
3
|
|
4
|
4
|
@implementation RNNBridgeModule {
|
5
|
|
- RNNCommandsHandler* _commandsHandler;
|
|
5
|
+ RNNCommandsHandler* _commandsHandler;
|
6
|
6
|
}
|
7
|
7
|
@synthesize bridge = _bridge;
|
8
|
8
|
RCT_EXPORT_MODULE();
|
9
|
9
|
|
10
|
10
|
- (dispatch_queue_t)methodQueue {
|
11
|
|
- return dispatch_get_main_queue();
|
|
11
|
+ return dispatch_get_main_queue();
|
12
|
12
|
}
|
13
|
13
|
|
14
|
14
|
-(instancetype)initWithCommandsHandler:(RNNCommandsHandler *)commandsHandler {
|
15
|
|
- self = [super init];
|
16
|
|
- _commandsHandler = commandsHandler;
|
17
|
|
- return self;
|
|
15
|
+ self = [super init];
|
|
16
|
+ _commandsHandler = commandsHandler;
|
|
17
|
+ return self;
|
18
|
18
|
}
|
19
|
19
|
|
20
|
20
|
#pragma mark - JS interface
|
21
|
21
|
|
22
|
22
|
RCT_EXPORT_METHOD(setRoot:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
23
|
|
- [_commandsHandler setRoot:layout commandId:commandId completion:^{
|
24
|
|
- resolve(layout);
|
25
|
|
- }];
|
|
23
|
+ RCTExecuteOnMainQueue(^{
|
|
24
|
+ [_commandsHandler setRoot:layout commandId:commandId completion:^{
|
|
25
|
+ resolve(layout);
|
|
26
|
+ }];
|
|
27
|
+ });
|
26
|
28
|
}
|
27
|
29
|
|
28
|
30
|
RCT_EXPORT_METHOD(mergeOptions:(NSString*)componentId options:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
29
|
|
- [_commandsHandler mergeOptions:componentId options:options completion:^{
|
30
|
|
- resolve(componentId);
|
31
|
|
- }];
|
|
31
|
+ RCTExecuteOnMainQueue(^{
|
|
32
|
+ [_commandsHandler mergeOptions:componentId options:options completion:^{
|
|
33
|
+ resolve(componentId);
|
|
34
|
+ }];
|
|
35
|
+ });
|
32
|
36
|
}
|
33
|
37
|
|
34
|
38
|
RCT_EXPORT_METHOD(setDefaultOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
35
|
|
- [_commandsHandler setDefaultOptions:options completion:^{
|
36
|
|
- resolve(nil);
|
37
|
|
- }];
|
|
39
|
+ RCTExecuteOnMainQueue(^{
|
|
40
|
+ [_commandsHandler setDefaultOptions:options completion:^{
|
|
41
|
+ resolve(nil);
|
|
42
|
+ }];
|
|
43
|
+ });
|
38
|
44
|
}
|
39
|
45
|
|
40
|
46
|
RCT_EXPORT_METHOD(push:(NSString*)commandId componentId:(NSString*)componentId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
41
|
|
- [_commandsHandler push:componentId commandId:commandId layout:layout completion:^{
|
42
|
|
- resolve(componentId);
|
43
|
|
- } rejection:reject];
|
|
47
|
+ RCTExecuteOnMainQueue(^{
|
|
48
|
+ [_commandsHandler push:componentId commandId:commandId layout:layout completion:^{
|
|
49
|
+ resolve(componentId);
|
|
50
|
+ } rejection:reject];
|
|
51
|
+ });
|
44
|
52
|
}
|
45
|
53
|
|
46
|
54
|
RCT_EXPORT_METHOD(pop:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
47
|
|
- [_commandsHandler pop:componentId commandId:commandId mergeOptions:(NSDictionary*)options completion:^{
|
48
|
|
- resolve(componentId);
|
49
|
|
- } rejection:reject];
|
|
55
|
+ RCTExecuteOnMainQueue(^{
|
|
56
|
+ [_commandsHandler pop:componentId commandId:commandId mergeOptions:(NSDictionary*)options completion:^{
|
|
57
|
+ resolve(componentId);
|
|
58
|
+ } rejection:reject];
|
|
59
|
+ });
|
50
|
60
|
}
|
51
|
61
|
|
52
|
62
|
RCT_EXPORT_METHOD(setStackRoot:(NSString*)commandId componentId:(NSString*)componentId children:(NSArray*)children resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
53
|
|
- [_commandsHandler setStackRoot:componentId commandId:commandId children:children completion:^{
|
54
|
|
- resolve(componentId);
|
55
|
|
- } rejection:reject];
|
|
63
|
+ RCTExecuteOnMainQueue(^{
|
|
64
|
+ [_commandsHandler setStackRoot:componentId commandId:commandId children:children completion:^{
|
|
65
|
+ resolve(componentId);
|
|
66
|
+ } rejection:reject];
|
|
67
|
+ });
|
56
|
68
|
}
|
57
|
69
|
|
58
|
70
|
RCT_EXPORT_METHOD(popTo:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
59
|
|
- [_commandsHandler popTo:componentId commandId:commandId mergeOptions:options completion:^{
|
60
|
|
- resolve(componentId);
|
61
|
|
- } rejection:reject];
|
|
71
|
+ RCTExecuteOnMainQueue(^{
|
|
72
|
+ [_commandsHandler popTo:componentId commandId:commandId mergeOptions:options completion:^{
|
|
73
|
+ resolve(componentId);
|
|
74
|
+ } rejection:reject];
|
|
75
|
+ });
|
62
|
76
|
}
|
63
|
77
|
|
64
|
78
|
RCT_EXPORT_METHOD(popToRoot:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
65
|
|
- [_commandsHandler popToRoot:componentId commandId:commandId mergeOptions:options completion:^{
|
66
|
|
- resolve(componentId);
|
67
|
|
- } rejection:reject];
|
|
79
|
+ RCTExecuteOnMainQueue(^{
|
|
80
|
+ [_commandsHandler popToRoot:componentId commandId:commandId mergeOptions:options completion:^{
|
|
81
|
+ resolve(componentId);
|
|
82
|
+ } rejection:reject];
|
|
83
|
+ });
|
68
|
84
|
}
|
69
|
85
|
|
70
|
86
|
RCT_EXPORT_METHOD(showModal:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
71
|
|
- [_commandsHandler showModal:layout commandId:commandId completion:^(NSString *componentId) {
|
72
|
|
- resolve(componentId);
|
73
|
|
- }];
|
|
87
|
+ RCTExecuteOnMainQueue(^{
|
|
88
|
+ [_commandsHandler showModal:layout commandId:commandId completion:^(NSString *componentId) {
|
|
89
|
+ resolve(componentId);
|
|
90
|
+ }];
|
|
91
|
+ });
|
74
|
92
|
}
|
75
|
93
|
|
76
|
94
|
RCT_EXPORT_METHOD(dismissModal:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
77
|
|
- [_commandsHandler dismissModal:componentId commandId:commandId mergeOptions:options completion:^{
|
78
|
|
- resolve(componentId);
|
79
|
|
- } rejection:reject];
|
|
95
|
+ RCTExecuteOnMainQueue(^{
|
|
96
|
+ [_commandsHandler dismissModal:componentId commandId:commandId mergeOptions:options completion:^{
|
|
97
|
+ resolve(componentId);
|
|
98
|
+ } rejection:reject];
|
|
99
|
+ });
|
80
|
100
|
}
|
81
|
101
|
|
82
|
102
|
RCT_EXPORT_METHOD(dismissAllModals:(NSString*)commandId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
83
|
|
- [_commandsHandler dismissAllModals:options commandId:commandId completion:^{
|
84
|
|
- resolve(nil);
|
85
|
|
- }];
|
|
103
|
+ RCTExecuteOnMainQueue(^{
|
|
104
|
+ [_commandsHandler dismissAllModals:options commandId:commandId completion:^{
|
|
105
|
+ resolve(nil);
|
|
106
|
+ }];
|
|
107
|
+ });
|
86
|
108
|
}
|
87
|
109
|
|
88
|
110
|
RCT_EXPORT_METHOD(showOverlay:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
89
|
|
- [_commandsHandler showOverlay:layout commandId:commandId completion:^{
|
90
|
|
- resolve(layout[@"id"]);
|
91
|
|
- }];
|
|
111
|
+ RCTExecuteOnMainQueue(^{
|
|
112
|
+ [_commandsHandler showOverlay:layout commandId:commandId completion:^{
|
|
113
|
+ resolve(layout[@"id"]);
|
|
114
|
+ }];
|
|
115
|
+ });
|
92
|
116
|
}
|
93
|
117
|
|
94
|
118
|
RCT_EXPORT_METHOD(dismissOverlay:(NSString*)commandId componentId:(NSString*)componentId resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
95
|
|
- [_commandsHandler dismissOverlay:componentId commandId:commandId completion:^{
|
96
|
|
- resolve(@(1));
|
97
|
|
- } rejection:reject];
|
|
119
|
+ RCTExecuteOnMainQueue(^{
|
|
120
|
+ [_commandsHandler dismissOverlay:componentId commandId:commandId completion:^{
|
|
121
|
+ resolve(@(1));
|
|
122
|
+ } rejection:reject];
|
|
123
|
+ });
|
98
|
124
|
}
|
99
|
125
|
|
100
|
126
|
RCT_EXPORT_METHOD(getLaunchArgs:(NSString*)commandId :(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
101
|
|
- NSArray* args = [[NSProcessInfo processInfo] arguments];
|
102
|
|
- resolve(args);
|
|
127
|
+ NSArray* args = [[NSProcessInfo processInfo] arguments];
|
|
128
|
+ resolve(args);
|
103
|
129
|
}
|
104
|
130
|
|
105
|
131
|
RCT_EXPORT_METHOD(getNavigationConstants:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
106
|
|
- resolve([Constants getConstants]);
|
|
132
|
+ RCTExecuteOnMainQueue(^{
|
|
133
|
+ resolve([Constants getConstants]);
|
|
134
|
+ });
|
107
|
135
|
}
|
108
|
136
|
|
109
|
137
|
@end
|