Browse Source

Support passing mergeOptions to pop and dismissModal commands

Guy Carmeli 5 years ago
parent
commit
aabd9e4248

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java View File

@@ -10,6 +10,7 @@ import com.reactnativenavigation.utils.TypefaceLoader;
10 10
 import org.json.JSONObject;
11 11
 
12 12
 public class Options {
13
+    public static final Options EMPTY = new Options();
13 14
 
14 15
     @NonNull
15 16
     public static Options parse(TypefaceLoader typefaceManager, JSONObject json) {

+ 20
- 15
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java View File

@@ -69,14 +69,12 @@ public class NavigationModule extends ReactContextBaseJavaModule {
69 69
 
70 70
 	@ReactMethod
71 71
 	public void setDefaultOptions(ReadableMap options) {
72
-        final Options defaultOptions = Options.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
73
-        handle(() -> navigator().setDefaultOptions(defaultOptions));
72
+        handle(() -> navigator().setDefaultOptions(parse(options)));
74 73
     }
75 74
 
76 75
 	@ReactMethod
77 76
 	public void mergeOptions(String onComponentId, ReadableMap options) {
78
-		final Options navOptions = Options.parse(new TypefaceLoader(activity()), JSONParser.parse(options));
79
-		handle(() -> navigator().mergeOptions(onComponentId, navOptions));
77
+		handle(() -> navigator().mergeOptions(onComponentId, parse(options)));
80 78
 	}
81 79
 
82 80
 	@ReactMethod
@@ -98,18 +96,18 @@ public class NavigationModule extends ReactContextBaseJavaModule {
98 96
     }
99 97
 
100 98
 	@ReactMethod
101
-	public void pop(String commandId, String componentId, ReadableMap options, Promise promise) {
102
-		handle(() -> navigator().pop(componentId, new NativeCommandListener(commandId, promise, eventEmitter, now)));
99
+	public void pop(String commandId, String componentId, ReadableMap mergeOptions, Promise promise) {
100
+		handle(() -> navigator().pop(componentId, parse(mergeOptions), new NativeCommandListener(commandId, promise, eventEmitter, now)));
103 101
 	}
104 102
 
105 103
 	@ReactMethod
106
-	public void popTo(String commandId, String componentId, Promise promise) {
107
-		handle(() -> navigator().popTo(componentId, new NativeCommandListener(commandId, promise, eventEmitter, now)));
104
+	public void popTo(String commandId, String componentId, ReadableMap mergeOptions, Promise promise) {
105
+		handle(() -> navigator().popTo(componentId, parse(mergeOptions), new NativeCommandListener(commandId, promise, eventEmitter, now)));
108 106
 	}
109 107
 
110 108
 	@ReactMethod
111
-	public void popToRoot(String commandId, String componentId, Promise promise) {
112
-		handle(() -> navigator().popToRoot(componentId, new NativeCommandListener(commandId, promise, eventEmitter, now)));
109
+	public void popToRoot(String commandId, String componentId, ReadableMap mergeOptions, Promise promise) {
110
+		handle(() -> navigator().popToRoot(componentId, parse(mergeOptions), new NativeCommandListener(commandId, promise, eventEmitter, now)));
113 111
 	}
114 112
 
115 113
 	@ReactMethod
@@ -122,13 +120,16 @@ public class NavigationModule extends ReactContextBaseJavaModule {
122 120
 	}
123 121
 
124 122
 	@ReactMethod
125
-	public void dismissModal(String commandId, String componentId, Promise promise) {
126
-		handle(() -> navigator().dismissModal(componentId, new NativeCommandListener(commandId, promise, eventEmitter, now)));
123
+	public void dismissModal(String commandId, String componentId, ReadableMap mergeOptions, Promise promise) {
124
+		handle(() -> {
125
+            navigator().mergeOptions(componentId, parse(mergeOptions));
126
+            navigator().dismissModal(componentId, new NativeCommandListener(commandId, promise, eventEmitter, now));
127
+        });
127 128
 	}
128 129
 
129
-	@ReactMethod
130
-	public void dismissAllModals(String commandId, Promise promise) {
131
-		handle(() -> navigator().dismissAllModals(new NativeCommandListener(commandId, promise, eventEmitter, now)));
130
+    @ReactMethod
131
+	public void dismissAllModals(String commandId, ReadableMap mergeOptions, Promise promise) {
132
+		handle(() -> navigator().dismissAllModals(parse(mergeOptions), new NativeCommandListener(commandId, promise, eventEmitter, now)));
132 133
 	}
133 134
 
134 135
 	@ReactMethod
@@ -160,6 +161,10 @@ public class NavigationModule extends ReactContextBaseJavaModule {
160 161
         );
161 162
 	}
162 163
 
164
+    private Options parse(ReadableMap mergeOptions) {
165
+        return Options.parse(new TypefaceLoader(activity()), JSONParser.parse(mergeOptions));
166
+    }
167
+
163 168
 	private Map<String, ExternalComponentCreator> externalComponentCreator() {
164 169
         return ((NavigationApplication) activity().getApplication()).getExternalComponents();
165 170
     }

+ 13
- 8
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java View File

@@ -156,18 +156,23 @@ public class Navigator extends ParentController {
156 156
         applyOnStack(id, listener, stack -> stack.setRoot(viewController, listener));
157 157
     }
158 158
 
159
-    public void pop(String id, CommandListener listener) {
160
-        applyOnStack(id, listener, stack -> stack.pop(listener));
159
+    public void pop(String id, Options mergeOptions, CommandListener listener) {
160
+        applyOnStack(id, listener, stack -> {
161
+            stack.peek().mergeOptions(mergeOptions);
162
+            stack.pop(listener);
163
+        });
161 164
     }
162 165
 
163
-    public void popToRoot(final String id, CommandListener listener) {
164
-        applyOnStack(id, listener, stack -> stack.popToRoot(listener));
166
+    public void popToRoot(final String id, Options mergeOptions, CommandListener listener) {
167
+        applyOnStack(id, listener, stack -> stack.popToRoot(mergeOptions, listener));
165 168
     }
166 169
 
167
-    public void popTo(final String id, CommandListener listener) {
170
+    public void popTo(final String id, Options mergeOptions, CommandListener listener) {
168 171
         ViewController target = findControllerById(id);
169 172
         if (target != null) {
170
-            target.performOnParentStack(stack -> ((StackController) stack).popTo(target, listener));
173
+            target.performOnParentStack(stack -> {
174
+                ((StackController) stack).popTo(target, mergeOptions, listener);
175
+            });
171 176
         } else {
172 177
             listener.onError("Failed to execute stack command. Stack by " + id + " not found.");
173 178
         }
@@ -185,8 +190,8 @@ public class Navigator extends ParentController {
185 190
         modalStack.dismissModal(componentId, root, listener);
186 191
     }
187 192
 
188
-    public void dismissAllModals(CommandListener listener) {
189
-        modalStack.dismissAllModals(listener, root);
193
+    public void dismissAllModals(Options mergeOptions, CommandListener listener) {
194
+        modalStack.dismissAllModals(root, mergeOptions, listener);
190 195
     }
191 196
 
192 197
     public void showOverlay(ViewController overlay, CommandListener listener) {

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java View File

@@ -149,7 +149,7 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
149 149
         return false;
150 150
     }
151 151
 
152
-    void performOnParentStack(Task accept, Runnable reject) {
152
+    void performOnParentStack(Task<StackController> accept, Runnable reject) {
153 153
         if (!performOnParentStack(accept)) {
154 154
             reject.run();
155 155
         }

+ 3
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalStack.java View File

@@ -78,7 +78,7 @@ public class ModalStack {
78 78
         }
79 79
     }
80 80
 
81
-    public void dismissAllModals(CommandListener listener, ViewController root) {
81
+    public void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener) {
82 82
         if (modals.isEmpty()) {
83 83
             listener.onError("Nothing to dismiss");
84 84
             return;
@@ -87,6 +87,8 @@ public class ModalStack {
87 87
         String topModalId = peek().getId();
88 88
         int modalsDismissed = size();
89 89
 
90
+        peek().mergeOptions(mergeOptions);
91
+
90 92
         while (!modals.isEmpty()) {
91 93
             if (modals.size() == 1) {
92 94
                 dismissModal(modals.get(0).getId(), root, new CommandListenerAdapter(listener) {

+ 6
- 3
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java View File

@@ -221,12 +221,14 @@ public class StackController extends ParentController<StackLayout> {
221 221
         listener.onSuccess(disappearing.getId());
222 222
     }
223 223
 
224
-    public void popTo(final ViewController viewController, CommandListener listener) {
225
-        if (!stack.containsId(viewController.getId())) {
224
+    public void popTo(ViewController viewController, Options mergeOptions, CommandListener listener) {
225
+        if (!stack.containsId(viewController.getId()) || peek().equals(viewController)) {
226 226
             listener.onError("Nothing to pop");
227 227
             return;
228 228
         }
229 229
 
230
+        peek().mergeOptions(mergeOptions);
231
+
230 232
         Iterator<String> iterator = stack.iterator();
231 233
         String currentControlId = iterator.next();
232 234
         while (!viewController.getId().equals(currentControlId)) {
@@ -241,12 +243,13 @@ public class StackController extends ParentController<StackLayout> {
241 243
         pop(listener);
242 244
     }
243 245
 
244
-    public void popToRoot(CommandListener listener) {
246
+    public void popToRoot(Options mergeOptions, CommandListener listener) {
245 247
         if (!canPop()) {
246 248
             listener.onError("Nothing to pop");
247 249
             return;
248 250
         }
249 251
 
252
+        peek().mergeOptions(mergeOptions);
250 253
         Iterator<String> iterator = stack.iterator();
251 254
         while (stack.size() > 2) {
252 255
             ViewController controller = stack.get(iterator.next());

+ 12
- 12
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java View File

@@ -188,9 +188,9 @@ public class NavigatorTest extends BaseTest {
188 188
 
189 189
     @Test
190 190
     public void pop_InvalidDoesNothing() {
191
-        uut.pop("123", new CommandListenerAdapter());
191
+        uut.pop("123", Options.EMPTY, new CommandListenerAdapter());
192 192
         uut.setRoot(child1, new CommandListenerAdapter());
193
-        uut.pop(child1.getId(), new CommandListenerAdapter());
193
+        uut.pop(child1.getId(), Options.EMPTY, new CommandListenerAdapter());
194 194
         assertThat(uut.getChildControllers()).hasSize(1);
195 195
     }
196 196
 
@@ -208,7 +208,7 @@ public class NavigatorTest extends BaseTest {
208 208
                 stack2.push(child4, new CommandListenerAdapter() {
209 209
                             @Override
210 210
                             public void onSuccess(String childId) {
211
-                                uut.pop("child4", new CommandListenerAdapter());
211
+                                uut.pop("child4", Options.EMPTY, new CommandListenerAdapter());
212 212
                                 assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
213 213
                             }
214 214
                         }
@@ -226,7 +226,7 @@ public class NavigatorTest extends BaseTest {
226 226
         stack.push(child1, new CommandListenerAdapter());
227 227
         stack.push(child2, new CommandListenerAdapter());
228 228
 
229
-        uut.pop(stack.getId(), new CommandListenerAdapter());
229
+        uut.pop(stack.getId(), Options.EMPTY, new CommandListenerAdapter());
230 230
         assertThat(stack.getChildControllers()).containsOnly(child1);
231 231
     }
232 232
 
@@ -244,7 +244,7 @@ public class NavigatorTest extends BaseTest {
244 244
         stack2.push(child5, new CommandListenerAdapter() {
245 245
             @Override
246 246
             public void onSuccess(String childId) {
247
-                uut.popTo(child2.getId(), new CommandListenerAdapter());
247
+                uut.popTo(child2.getId(), Options.EMPTY, new CommandListenerAdapter());
248 248
                 assertThat(stack2.getChildControllers()).containsOnly(child2);
249 249
             }
250 250
         });
@@ -264,7 +264,7 @@ public class NavigatorTest extends BaseTest {
264 264
         stack2.push(child5, new CommandListenerAdapter() {
265 265
             @Override
266 266
             public void onSuccess(String childId) {
267
-                uut.popToRoot(child3.getId(), new CommandListenerAdapter());
267
+                uut.popToRoot(child3.getId(), Options.EMPTY, new CommandListenerAdapter());
268 268
                 assertThat(stack2.getChildControllers()).containsOnly(child2);
269 269
             }
270 270
         });
@@ -370,9 +370,9 @@ public class NavigatorTest extends BaseTest {
370 370
 
371 371
     @Test
372 372
     public void pop_InvalidDoesNothing_Promise() {
373
-        uut.pop("123", new CommandListenerAdapter());
373
+        uut.pop("123", Options.EMPTY, new CommandListenerAdapter());
374 374
         uut.setRoot(child1, new CommandListenerAdapter());
375
-        uut.pop(child1.getId(), new CommandListenerAdapter() {
375
+        uut.pop(child1.getId(), Options.EMPTY, new CommandListenerAdapter() {
376 376
             @Override
377 377
             public void onError(String reason) {
378 378
                 assertThat(uut.getChildControllers()).hasSize(1);
@@ -393,7 +393,7 @@ public class NavigatorTest extends BaseTest {
393 393
         stack2.push(child4, new CommandListenerAdapter() {
394 394
             @Override
395 395
             public void onSuccess(String childId) {
396
-                uut.pop("child4", new CommandListenerAdapter());
396
+                uut.pop("child4", Options.EMPTY, new CommandListenerAdapter());
397 397
                 assertThat(stack2.getChildControllers()).containsOnly(child2, child3);
398 398
             }
399 399
         });
@@ -431,7 +431,7 @@ public class NavigatorTest extends BaseTest {
431 431
                 assertThat(spy.getChildControllers().size()).isEqualTo(1);
432 432
             }
433 433
         };
434
-        uut.pop("child2", listener);
434
+        uut.pop("child2", Options.EMPTY, listener);
435 435
         verify(spy, times(1)).pop(listener);
436 436
     }
437 437
 
@@ -505,7 +505,7 @@ public class NavigatorTest extends BaseTest {
505 505
         disablePushAnimation(child2);
506 506
         disableShowModalAnimation(child1);
507 507
 
508
-        uut.dismissAllModals(new CommandListenerAdapter());
508
+        uut.dismissAllModals(Options.EMPTY, new CommandListenerAdapter());
509 509
         verify(parentVisibilityListener, times(0)).onViewAppeared(parentController.getView());
510 510
 
511 511
         uut.setRoot(parentController, new CommandListenerAdapter());
@@ -513,7 +513,7 @@ public class NavigatorTest extends BaseTest {
513 513
 
514 514
         verify(parentVisibilityListener, times(1)).onViewAppeared(parentController.getView());
515 515
         uut.showModal(child1, new CommandListenerAdapter());
516
-        uut.dismissAllModals(new CommandListenerAdapter());
516
+        uut.dismissAllModals(Options.EMPTY, new CommandListenerAdapter());
517 517
 
518 518
         verify(parentVisibilityListener, times(2)).onViewAppeared(parentController.getView());
519 519
     }

+ 18
- 5
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java View File

@@ -141,7 +141,7 @@ public class ModalStackTest extends BaseTest {
141 141
                 assertThat(uut.isEmpty()).isTrue();
142 142
             }
143 143
         });
144
-        uut.dismissAllModals(listener, rootController);
144
+        uut.dismissAllModals(rootController, Options.EMPTY, listener);
145 145
         verify(listener, times(1)).onSuccess(anyString());
146 146
         verifyZeroInteractions(listener);
147 147
     }
@@ -149,10 +149,23 @@ public class ModalStackTest extends BaseTest {
149 149
     @Test
150 150
     public void dismissAllModals_rejectIfEmpty() {
151 151
         CommandListener spy = spy(new CommandListenerAdapter());
152
-        uut.dismissAllModals(spy, rootController);
152
+        uut.dismissAllModals(rootController, Options.EMPTY, spy);
153 153
         verify(spy, times(1)).onError(any());
154 154
     }
155 155
 
156
+    @Test
157
+    public void dismissAllModals_optionsAreMergedOnTopModal() {
158
+        uut.showModal(modal1, rootController, new CommandListenerAdapter());
159
+        uut.showModal(modal2, rootController, new CommandListenerAdapter());
160
+        uut.showModal(modal3, rootController, new CommandListenerAdapter());
161
+
162
+        Options mergeOptions = new Options();
163
+        uut.dismissAllModals(rootController, mergeOptions, new CommandListenerAdapter());
164
+        verify(modal3).mergeOptions(mergeOptions);
165
+        verify(modal1, times(0)).mergeOptions(mergeOptions);
166
+        verify(modal2, times(0)).mergeOptions(mergeOptions);
167
+    }
168
+
156 169
     @SuppressWarnings("Convert2Lambda")
157 170
     @Test
158 171
     public void dismissAllModals_onlyTopModalIsAnimated() {
@@ -162,7 +175,7 @@ public class ModalStackTest extends BaseTest {
162 175
         ViewGroup view1 = modal1.getView();
163 176
         ViewGroup view2 = modal2.getView();
164 177
         CommandListener listener = spy(new CommandListenerAdapter());
165
-        uut.dismissAllModals(listener, rootController);
178
+        uut.dismissAllModals(rootController, Options.EMPTY, listener);
166 179
         verify(presenter, times(1)).dismissTopModal(eq(modal2), eq(rootController), any());
167 180
         verify(listener).onSuccess(modal2.getId());
168 181
         verify(animator, times(0)).dismiss(eq(view1), eq(modal1.options.animations.dismissModal), any());
@@ -175,7 +188,7 @@ public class ModalStackTest extends BaseTest {
175 188
         uut.showModal(modal1, rootController, new CommandListenerAdapter());
176 189
         uut.showModal(modal2, rootController, new CommandListenerAdapter());
177 190
 
178
-        uut.dismissAllModals(new CommandListenerAdapter(), rootController);
191
+        uut.dismissAllModals(rootController, Options.EMPTY, new CommandListenerAdapter());
179 192
 
180 193
         verify(modal1, times(1)).destroy();
181 194
         verify(modal1, times(1)).onViewDisappear();
@@ -187,7 +200,7 @@ public class ModalStackTest extends BaseTest {
187 200
         assertThat(uut.isEmpty()).isTrue();
188 201
         uut.showModal(modal1, rootController, new CommandListenerAdapter());
189 202
         assertThat(uut.isEmpty()).isFalse();
190
-        uut.dismissAllModals(new CommandListenerAdapter(), rootController);
203
+        uut.dismissAllModals(rootController, Options.EMPTY, new CommandListenerAdapter());
191 204
         assertThat(uut.isEmpty()).isTrue();
192 205
     }
193 206
 

+ 35
- 8
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.java View File

@@ -453,7 +453,7 @@ public class StackControllerTest extends BaseTest {
453 453
                 assertThat(uut.size()).isEqualTo(3);
454 454
                 assertThat(uut.peek()).isEqualTo(child3);
455 455
 
456
-                uut.popTo(child1, new CommandListenerAdapter());
456
+                uut.popTo(child1, Options.EMPTY, new CommandListenerAdapter());
457 457
 
458 458
                 assertThat(uut.size()).isEqualTo(1);
459 459
                 assertThat(uut.peek()).isEqualTo(child1);
@@ -461,12 +461,27 @@ public class StackControllerTest extends BaseTest {
461 461
         });
462 462
     }
463 463
 
464
+    @Test
465
+    public void popTo_optionsAreMergedOnTopChild() {
466
+        disablePushAnimation(child1, child2);
467
+        uut.push(child1, new CommandListenerAdapter());
468
+
469
+        Options mergeOptions = new Options();
470
+        uut.popTo(child2, mergeOptions, new CommandListenerAdapter());
471
+        uut.popTo(child1, mergeOptions, new CommandListenerAdapter());
472
+        verify(child1, times(0)).mergeOptions(mergeOptions);
473
+
474
+        uut.push(child2, new CommandListenerAdapter());
475
+        uut.popTo(child1, mergeOptions, new CommandListenerAdapter());
476
+        verify(child2).mergeOptions(mergeOptions);
477
+    }
478
+
464 479
     @Test
465 480
     public void popTo_NotAChildOfThisStack_DoesNothing() {
466 481
         uut.push(child1, new CommandListenerAdapter());
467 482
         uut.push(child3, new CommandListenerAdapter());
468 483
         assertThat(uut.size()).isEqualTo(2);
469
-        uut.popTo(child2, new CommandListenerAdapter());
484
+        uut.popTo(child2, Options.EMPTY, new CommandListenerAdapter());
470 485
         assertThat(uut.size()).isEqualTo(2);
471 486
     }
472 487
 
@@ -478,7 +493,7 @@ public class StackControllerTest extends BaseTest {
478 493
         uut.push(child4, new CommandListenerAdapter() {
479 494
             @Override
480 495
             public void onSuccess(String childId) {
481
-                uut.popTo(child2, new CommandListenerAdapter() {
496
+                uut.popTo(child2, Options.EMPTY, new CommandListenerAdapter() {
482 497
                     @Override
483 498
                     public void onSuccess(String childId) {
484 499
                         verify(animator, times(0)).pop(eq(child1.getView()), any(), any());
@@ -503,7 +518,7 @@ public class StackControllerTest extends BaseTest {
503 518
                 assertThat(uut.size()).isEqualTo(3);
504 519
                 assertThat(uut.peek()).isEqualTo(child3);
505 520
 
506
-                uut.popToRoot(new CommandListenerAdapter() {
521
+                uut.popToRoot(Options.EMPTY, new CommandListenerAdapter() {
507 522
                     @Override
508 523
                     public void onSuccess(String childId) {
509 524
                         assertThat(uut.size()).isEqualTo(1);
@@ -524,7 +539,7 @@ public class StackControllerTest extends BaseTest {
524 539
         uut.push(child3, new CommandListenerAdapter() {
525 540
             @Override
526 541
             public void onSuccess(String childId) {
527
-                uut.popToRoot(new CommandListenerAdapter() {
542
+                uut.popToRoot(Options.EMPTY, new CommandListenerAdapter() {
528 543
                     @Override
529 544
                     public void onSuccess(String childId) {
530 545
                         verify(animator, times(1)).pop(eq(child3.getView()), eq(child3.options.animations.pop), any());
@@ -544,7 +559,7 @@ public class StackControllerTest extends BaseTest {
544 559
         uut.push(child2, new CommandListenerAdapter());
545 560
         uut.push(child3, new CommandListenerAdapter());
546 561
 
547
-        uut.popToRoot(new CommandListenerAdapter() {
562
+        uut.popToRoot(Options.EMPTY, new CommandListenerAdapter() {
548 563
             @Override
549 564
             public void onSuccess(String childId) {
550 565
                 verify(child1, times(0)).destroy();
@@ -558,11 +573,23 @@ public class StackControllerTest extends BaseTest {
558 573
     public void popToRoot_EmptyStackDoesNothing() {
559 574
         assertThat(uut.isEmpty()).isTrue();
560 575
         CommandListenerAdapter listener = spy(new CommandListenerAdapter());
561
-        uut.popToRoot(listener);
576
+        uut.popToRoot(Options.EMPTY, listener);
562 577
         assertThat(uut.isEmpty()).isTrue();
563 578
         verify(listener, times(1)).onError(any());
564 579
     }
565 580
 
581
+    @Test
582
+    public void popToRoot_optionsAreMergedOnTopChild() {
583
+        disablePushAnimation(child1, child2);
584
+        uut.push(child1, new CommandListenerAdapter());
585
+        uut.push(child2, new CommandListenerAdapter());
586
+
587
+        Options mergeOptions = new Options();
588
+        uut.popToRoot(mergeOptions, new CommandListenerAdapter());
589
+        verify(child2).mergeOptions(mergeOptions);
590
+        verify(child1, times(0)).mergeOptions(mergeOptions);
591
+    }
592
+
566 593
     @Test
567 594
     public void findControllerById_ReturnsSelfOrChildrenById() {
568 595
         assertThat(uut.findControllerById("123")).isNull();
@@ -673,7 +700,7 @@ public class StackControllerTest extends BaseTest {
673 700
                 verify(child2, times(0)).destroy();
674 701
                 verify(child3, times(0)).destroy();
675 702
 
676
-                uut.popTo(child1, new CommandListenerAdapter() {
703
+                uut.popTo(child1, Options.EMPTY, new CommandListenerAdapter() {
677 704
                     @Override
678 705
                     public void onSuccess(String childId) {
679 706
                         verify(child2, times(1)).destroy();

+ 8
- 8
lib/src/adapters/NativeCommandsSender.ts View File

@@ -26,12 +26,12 @@ export class NativeCommandsSender {
26 26
     return this.nativeCommandsModule.pop(commandId, componentId, options);
27 27
   }
28 28
 
29
-  popTo(commandId: string, componentId: string) {
30
-    return this.nativeCommandsModule.popTo(commandId, componentId);
29
+  popTo(commandId: string, componentId: string, options: object) {
30
+    return this.nativeCommandsModule.popTo(commandId, componentId, options);
31 31
   }
32 32
 
33
-  popToRoot(commandId: string, componentId: string) {
34
-    return this.nativeCommandsModule.popToRoot(commandId, componentId);
33
+  popToRoot(commandId: string, componentId: string, options: object) {
34
+    return this.nativeCommandsModule.popToRoot(commandId, componentId, options);
35 35
   }
36 36
 
37 37
   setStackRoot(commandId: string, onComponentId: string, layout: object) {
@@ -42,12 +42,12 @@ export class NativeCommandsSender {
42 42
     return this.nativeCommandsModule.showModal(commandId, layout);
43 43
   }
44 44
 
45
-  dismissModal(commandId: string, componentId: string) {
46
-    return this.nativeCommandsModule.dismissModal(commandId, componentId);
45
+  dismissModal(commandId: string, componentId: string, options: object) {
46
+    return this.nativeCommandsModule.dismissModal(commandId, componentId, options);
47 47
   }
48 48
 
49
-  dismissAllModals(commandId: string) {
50
-    return this.nativeCommandsModule.dismissAllModals(commandId);
49
+  dismissAllModals(commandId: string, options: object) {
50
+    return this.nativeCommandsModule.dismissAllModals(commandId, options);
51 51
   }
52 52
 
53 53
   showOverlay(commandId: string, layout: object) {

+ 14
- 14
lib/src/commands/Commands.ts View File

@@ -62,16 +62,16 @@ export class Commands {
62 62
     return result;
63 63
   }
64 64
 
65
-  public dismissModal(componentId) {
65
+  public dismissModal(componentId, mergeOptions) {
66 66
     const commandId = this.uniqueIdProvider.generate('dismissModal');
67
-    const result = this.nativeCommandsSender.dismissModal(commandId, componentId);
68
-    this.commandsObserver.notify('dismissModal', { commandId, componentId });
67
+    const result = this.nativeCommandsSender.dismissModal(commandId, componentId, mergeOptions);
68
+    this.commandsObserver.notify('dismissModal', { commandId, componentId, mergeOptions});
69 69
     return result;
70 70
   }
71 71
 
72
-  public dismissAllModals() {
72
+  public dismissAllModals(mergeOptions) {
73 73
     const commandId = this.uniqueIdProvider.generate('dismissAllModals');
74
-    const result = this.nativeCommandsSender.dismissAllModals(commandId);
74
+    const result = this.nativeCommandsSender.dismissAllModals(commandId, mergeOptions);
75 75
     this.commandsObserver.notify('dismissAllModals', { commandId });
76 76
     return result;
77 77
   }
@@ -88,24 +88,24 @@ export class Commands {
88 88
     return result;
89 89
   }
90 90
 
91
-  public pop(componentId, options) {
91
+  public pop(componentId, mergeOptions) {
92 92
     const commandId = this.uniqueIdProvider.generate('pop');
93
-    const result = this.nativeCommandsSender.pop(commandId, componentId, options);
94
-    this.commandsObserver.notify('pop', { commandId, componentId, options });
93
+    const result = this.nativeCommandsSender.pop(commandId, componentId, mergeOptions);
94
+    this.commandsObserver.notify('pop', { commandId, componentId, mergeOptions });
95 95
     return result;
96 96
   }
97 97
 
98
-  public popTo(componentId) {
98
+  public popTo(componentId, mergeOptions) {
99 99
     const commandId = this.uniqueIdProvider.generate('popTo');
100
-    const result = this.nativeCommandsSender.popTo(commandId, componentId);
101
-    this.commandsObserver.notify('popTo', { commandId, componentId });
100
+    const result = this.nativeCommandsSender.popTo(commandId, componentId, mergeOptions);
101
+    this.commandsObserver.notify('popTo', { commandId, componentId, mergeOptions });
102 102
     return result;
103 103
   }
104 104
 
105
-  public popToRoot(componentId) {
105
+  public popToRoot(componentId, mergeOptions) {
106 106
     const commandId = this.uniqueIdProvider.generate('popToRoot');
107
-    const result = this.nativeCommandsSender.popToRoot(commandId, componentId);
108
-    this.commandsObserver.notify('popToRoot', { commandId, componentId });
107
+    const result = this.nativeCommandsSender.popToRoot(commandId, componentId, mergeOptions);
108
+    this.commandsObserver.notify('popToRoot', { commandId, componentId, mergeOptions });
109 109
     return result;
110 110
   }
111 111