Ver código fonte

Fix merge options on pop

yogevbd 6 anos atrás
pai
commit
452443d781
1 arquivos alterados com 18 adições e 16 exclusões
  1. 18
    16
      lib/ios/RNNCommandsHandler.m

+ 18
- 16
lib/ios/RNNCommandsHandler.m Ver arquivo

@@ -78,7 +78,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
78 78
 		
79 79
 		[CATransaction commit];
80 80
 	}
81
-
81
+	
82 82
 	if ([vc isKindOfClass:[RNNSplitViewController class]]) {
83 83
 		RNNSplitViewController* splitVc = (RNNSplitViewController*)vc;
84 84
 		[splitVc.options mergeWith:options];
@@ -99,34 +99,34 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
99 99
 
100 100
 - (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
101 101
 	[self assertReady];
102
-
102
+	
103 103
 	RNNRootViewController *newVc = (RNNRootViewController *)[_controllerFactory createLayoutAndSaveToStore:layout];
104 104
 	UIViewController *fromVC = [_store findComponentForId:componentId];
105 105
 	
106 106
 	if (newVc.options.preview.elementId) {
107 107
 		UIViewController* vc = [_store findComponentForId:componentId];
108
-
108
+		
109 109
 		if([vc isKindOfClass:[RNNRootViewController class]]) {
110 110
 			RNNRootViewController* rootVc = (RNNRootViewController*)vc;
111 111
 			rootVc.previewController = newVc;
112
-
112
+			
113 113
 			RNNElementFinder* elementFinder = [[RNNElementFinder alloc] initWithFromVC:vc];
114 114
 			RNNElementView* elementView = [elementFinder findElementForId:newVc.options.preview.elementId];
115
-
115
+			
116 116
 			CGSize size = CGSizeMake(rootVc.view.frame.size.width, rootVc.view.frame.size.height);
117 117
 			
118 118
 			if (newVc.options.preview.width) {
119 119
 				size.width = [newVc.options.preview.width floatValue];
120 120
 			}
121
-
121
+			
122 122
 			if (newVc.options.preview.height) {
123 123
 				size.height = [newVc.options.preview.height floatValue];
124 124
 			}
125
-
125
+			
126 126
 			if (newVc.options.preview.width || newVc.options.preview.height) {
127 127
 				newVc.preferredContentSize = size;
128 128
 			}
129
-
129
+			
130 130
 			[rootVc registerForPreviewingWithDelegate:(id)rootVc sourceView:elementView];
131 131
 		}
132 132
 	} else {
@@ -153,12 +153,14 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
153 153
 	} rejection:rejection];
154 154
 }
155 155
 
156
-- (void)pop:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
156
+- (void)pop:(NSString*)componentId options:(NSDictionary*)optionsDict completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
157 157
 	[self assertReady];
158
-
158
+	
159 159
 	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
160
+	[vc.options mergeWith:optionsDict];
161
+	
160 162
 	UINavigationController *nvc = vc.navigationController;
161
-
163
+	
162 164
 	if ([nvc topViewController] == vc) {
163 165
 		if (vc.options.animations.pop) {
164 166
 			nvc.delegate = vc;
@@ -194,7 +196,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
194 196
 -(void) popToRoot:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
195 197
 	[self assertReady];
196 198
 	RNNRootViewController *newVc = (RNNRootViewController*)[_store findComponentForId:componentId];
197
-
199
+	
198 200
 	[CATransaction begin];
199 201
 	[CATransaction setCompletionBlock:^{
200 202
 		[_eventEmitter sendOnNavigationCommandCompletion:popToRoot params:@{@"componentId": componentId}];
@@ -212,7 +214,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
212 214
 
213 215
 - (void)showModal:(NSDictionary*)layout completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
214 216
 	[self assertReady];
215
-
217
+	
216 218
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
217 219
 	[_modalManager showModal:newVc animated:newVc.getLeafViewController.options.animations.showModal.enable completion:^(NSString *componentId) {
218 220
 		[_eventEmitter sendOnNavigationCommandCompletion:showModal params:@{@"layout": layout}];
@@ -222,7 +224,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
222 224
 
223 225
 - (void)dismissModal:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion {
224 226
 	[self assertReady];
225
-
227
+	
226 228
 	[CATransaction begin];
227 229
 	[CATransaction setCompletionBlock:^{
228 230
 		[_eventEmitter sendOnNavigationCommandCompletion:dismissModal params:@{@"componentId": componentId}];
@@ -235,7 +237,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
235 237
 
236 238
 - (void)dismissAllModalsWithCompletion:(RNNTransitionCompletionBlock)completion {
237 239
 	[self assertReady];
238
-
240
+	
239 241
 	[CATransaction begin];
240 242
 	[CATransaction setCompletionBlock:^{
241 243
 		[_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals params:@{}];
@@ -249,7 +251,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
249 251
 
250 252
 - (void)showOverlay:(NSDictionary *)layout completion:(RNNTransitionCompletionBlock)completion {
251 253
 	[self assertReady];
252
-
254
+	
253 255
 	UIViewController<RNNRootViewProtocol>* overlayVC = [_controllerFactory createOverlay:layout];
254 256
 	[_overlayManager showOverlay:overlayVC];
255 257
 	[_eventEmitter sendOnNavigationCommandCompletion:showOverlay params:@{@"layout": layout}];