Browse Source

Consolidate push and animatePush

Screen presentation logic in stack should be moved to a dedicated presenter
Guy Carmeli 6 years ago
parent
commit
99b019008f

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

@@ -3,6 +3,9 @@ package com.reactnativenavigation.parse;
3 3
 import android.support.annotation.CheckResult;
4 4
 import android.support.annotation.NonNull;
5 5
 
6
+import com.reactnativenavigation.parse.params.Bool;
7
+import com.reactnativenavigation.parse.params.NullBool;
8
+import com.reactnativenavigation.parse.parsers.BoolParser;
6 9
 import com.reactnativenavigation.utils.TypefaceLoader;
7 10
 
8 11
 import org.json.JSONObject;
@@ -27,8 +30,9 @@ public class Options {
27 30
         result.bottomTabsOptions = BottomTabsOptions.parse(json.optJSONObject("bottomTabs"));
28 31
         result.overlayOptions = OverlayOptions.parse(json.optJSONObject("overlay"));
29 32
         result.fabOptions = FabOptions.parse(json.optJSONObject("fab"));
30
-        result.animationsOptions = AnimationsOptions.parse(json.optJSONObject("animations"));
31 33
         result.sideMenuRootOptions = SideMenuRootOptions.parse(json.optJSONObject("sideMenu"));
34
+        result.animationsOptions = AnimationsOptions.parse(json.optJSONObject("animations"));
35
+        result.animated = BoolParser.parse(json, "animated");
32 36
 
33 37
         return result.withDefaultOptions(defaultOptions);
34 38
     }
@@ -43,6 +47,7 @@ public class Options {
43 47
     @NonNull public FabOptions fabOptions = new FabOptions();
44 48
     @NonNull public AnimationsOptions animationsOptions = new AnimationsOptions();
45 49
     @NonNull public SideMenuRootOptions sideMenuRootOptions = new SideMenuRootOptions();
50
+    @NonNull public Bool animated = new NullBool();
46 51
 
47 52
     void setTopTabIndex(int i) {
48 53
         topTabOptions.tabIndex = i;
@@ -59,8 +64,9 @@ public class Options {
59 64
         result.bottomTabsOptions.mergeWith(bottomTabsOptions);
60 65
         result.overlayOptions = overlayOptions;
61 66
         result.fabOptions.mergeWith(fabOptions);
62
-        result.animationsOptions.mergeWith(animationsOptions);
63 67
         result.sideMenuRootOptions.mergeWith(sideMenuRootOptions);
68
+        result.animationsOptions.mergeWith(animationsOptions);
69
+        result.animated = animated;
64 70
         return result;
65 71
     }
66 72
 
@@ -76,19 +82,21 @@ public class Options {
76 82
         result.fabOptions.mergeWith(other.fabOptions);
77 83
         result.animationsOptions.mergeWith(other.animationsOptions);
78 84
         result.sideMenuRootOptions.mergeWith(other.sideMenuRootOptions);
85
+        if (other.animated.hasValue()) result.animated = other.animated;
79 86
         return result;
80 87
     }
81 88
 
82
-    Options withDefaultOptions(final Options other) {
83
-        orientationOptions.mergeWithDefault(other.orientationOptions);
84
-        topBarOptions.mergeWithDefault(other.topBarOptions);
85
-        topTabOptions.mergeWithDefault(other.topTabOptions);
86
-        topTabsOptions.mergeWithDefault(other.topTabsOptions);
87
-        bottomTabOptions.mergeWithDefault(other.bottomTabOptions);
88
-        bottomTabsOptions.mergeWithDefault(other.bottomTabsOptions);
89
-        fabOptions.mergeWithDefault(other.fabOptions);
90
-        animationsOptions.mergeWithDefault(other.animationsOptions);
91
-        sideMenuRootOptions.mergeWithDefault(other.sideMenuRootOptions);
89
+    Options withDefaultOptions(final Options defaultOptions) {
90
+        orientationOptions.mergeWithDefault(defaultOptions.orientationOptions);
91
+        topBarOptions.mergeWithDefault(defaultOptions.topBarOptions);
92
+        topTabOptions.mergeWithDefault(defaultOptions.topTabOptions);
93
+        topTabsOptions.mergeWithDefault(defaultOptions.topTabsOptions);
94
+        bottomTabOptions.mergeWithDefault(defaultOptions.bottomTabOptions);
95
+        bottomTabsOptions.mergeWithDefault(defaultOptions.bottomTabsOptions);
96
+        fabOptions.mergeWithDefault(defaultOptions.fabOptions);
97
+        animationsOptions.mergeWithDefault(defaultOptions.animationsOptions);
98
+        sideMenuRootOptions.mergeWithDefault(defaultOptions.sideMenuRootOptions);
99
+        if (!animated.hasValue()) animated = defaultOptions.animated;
92 100
         return this;
93 101
     }
94 102
 

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

@@ -107,7 +107,7 @@ public class Navigator extends ParentController implements ModalListener {
107 107
     public void push(final String fromId, final ViewController viewController, CommandListener listener) {
108 108
         ViewController from = findControllerById(fromId);
109 109
         if (from != null) {
110
-            from.performOnParentStack(stack -> ((StackController) stack).animatePush(viewController, listener));
110
+            from.performOnParentStack(stack -> ((StackController) stack).push(viewController, listener));
111 111
         } else {
112 112
             listener.onError("Could not push component: " + viewController.getId() + ". Stack with id " + fromId + " was not found.");
113 113
         }

+ 9
- 28
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java View File

@@ -99,44 +99,25 @@ public class StackController extends ParentController<StackLayout> {
99 99
 
100 100
     public void push(ViewController child, CommandListener listener) {
101 101
         final ViewController toRemove = stack.peek();
102
-
103 102
         child.setParentController(this);
104 103
         stack.push(child.getId(), child);
105
-        View enteringView = child.getView();
106
-        getView().addView(enteringView, MATCH_PARENT, MATCH_PARENT);
104
+        getView().addView(child.getView(), MATCH_PARENT, MATCH_PARENT);
107 105
 
108 106
         if (toRemove != null) {
109
-            getView().removeView(toRemove.getView());
110
-        }
111
-        listener.onSuccess(child.getId());
112
-    }
113
-
114
-    public void animatePush(final ViewController child, CommandListener listener) {
115
-        final ViewController toRemove = stack.peek();
116
-
117
-        child.setParentController(this);
118
-        stack.push(child.getId(), child);
119
-        View enteringView = child.getView();
120
-        getView().addView(enteringView, MATCH_PARENT, MATCH_PARENT);
121
-
122
-        if (toRemove != null) {
123
-            animator.animatePush(enteringView, () -> {
107
+            if (child.options.animated.isTrueOrUndefined()) {
108
+                animator.animatePush(child.getView(), () -> {
109
+                    getView().removeView(toRemove.getView());
110
+                    listener.onSuccess(child.getId());
111
+                });
112
+            } else {
124 113
                 getView().removeView(toRemove.getView());
125 114
                 listener.onSuccess(child.getId());
126
-            });
127
-        } else {
128
-            listener.onSuccess(child.getId());
115
+            }
129 116
         }
130 117
     }
131 118
 
132 119
     public void setRoot(ViewController child, CommandListener listener) {
133
-        push(child);
134
-        removeChildrenBellowTop();
135
-        listener.onSuccess(child.getId());
136
-    }
137
-
138
-    public void animateSetRoot(ViewController child, CommandListener listener) {
139
-        animatePush(child, new CommandListenerAdapter() {
120
+        push(child, new CommandListenerAdapter() {
140 121
             @Override
141 122
             public void onSuccess(String childId) {
142 123
                 removeChildrenBellowTop();

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java View File

@@ -105,7 +105,7 @@ public class BottomTabsControllerTest extends BaseTest {
105 105
         assertThat(uut.findControllerById("123")).isNull();
106 106
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
107 107
         StackController inner = createStack("inner");
108
-        inner.animatePush(child1, new CommandListenerAdapter());
108
+        inner.push(child1, new CommandListenerAdapter());
109 109
         assertThat(uut.findControllerById(child1.getId())).isNull();
110 110
         uut.setTabs(Collections.singletonList(inner));
111 111
         assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);

+ 5
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/FloatingActionButtonTest.java View File

@@ -13,6 +13,7 @@ import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
13 13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14 14
 import com.reactnativenavigation.parse.FabOptions;
15 15
 import com.reactnativenavigation.parse.Options;
16
+import com.reactnativenavigation.parse.params.Bool;
16 17
 import com.reactnativenavigation.parse.params.Text;
17 18
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
18 19
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarController;
@@ -46,6 +47,7 @@ public class FloatingActionButtonTest extends BaseTest {
46 47
     @NonNull
47 48
     private Options getOptionsWithFab() {
48 49
         Options options = new Options();
50
+        options.animated = new Bool(false);
49 51
         FabOptions fabOptions = new FabOptions();
50 52
         fabOptions.id = new Text("FAB");
51 53
         options.fabOptions = fabOptions;
@@ -109,6 +111,9 @@ public class FloatingActionButtonTest extends BaseTest {
109 111
 
110 112
     @Test
111 113
     public void showOnPop() {
114
+        childFab.options.animated = new Bool(false);
115
+        childNoFab.options.animated = new Bool(false);
116
+
112 117
         stackController.push(childFab);
113 118
         stackController.push(childNoFab);
114 119
         childNoFab.onViewAppeared();

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

@@ -12,6 +12,7 @@ import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
12 12
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
13 13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14 14
 import com.reactnativenavigation.parse.Options;
15
+import com.reactnativenavigation.parse.params.Bool;
15 16
 import com.reactnativenavigation.parse.params.Text;
16 17
 import com.reactnativenavigation.utils.CommandListenerAdapter;
17 18
 import com.reactnativenavigation.utils.CompatUtils;
@@ -83,7 +84,7 @@ public class NavigatorTest extends BaseTest {
83 84
     @Test
84 85
     public void push() {
85 86
         StackController stackController = newStack();
86
-        stackController.animatePush(child1, new CommandListenerAdapter());
87
+        stackController.push(child1, new CommandListenerAdapter());
87 88
         uut.setRoot(stackController, new MockPromise());
88 89
 
89 90
         assertIsChildById(uut.getView(), stackController.getView());
@@ -107,8 +108,8 @@ public class NavigatorTest extends BaseTest {
107 108
         BottomTabsController bottomTabsController = newTabs();
108 109
         StackController stack1 = newStack();
109 110
         StackController stack2 = newStack();
110
-        stack1.animatePush(child1, new CommandListenerAdapter());
111
-        stack2.animatePush(child2, new CommandListenerAdapter());
111
+        stack1.push(child1, new CommandListenerAdapter());
112
+        stack2.push(child2, new CommandListenerAdapter());
112 113
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
113 114
         uut.setRoot(bottomTabsController, new MockPromise());
114 115
 
@@ -134,12 +135,12 @@ public class NavigatorTest extends BaseTest {
134 135
         StackController stack2 = newStack();
135 136
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
136 137
         uut.setRoot(bottomTabsController, new MockPromise());
137
-        stack1.animatePush(child1, new CommandListenerAdapter());
138
-        stack2.animatePush(child2, new CommandListenerAdapter());
139
-        stack2.animatePush(child3, new CommandListenerAdapter() {
138
+        stack1.push(child1, new CommandListenerAdapter());
139
+        stack2.push(child2, new CommandListenerAdapter());
140
+        stack2.push(child3, new CommandListenerAdapter() {
140 141
             @Override
141 142
             public void onSuccess(String childId) {
142
-                stack2.animatePush(child4, new CommandListenerAdapter() {
143
+                stack2.push(child4, new CommandListenerAdapter() {
143 144
                             @Override
144 145
                             public void onSuccess(String childId) {
145 146
                                 uut.pop("child4", new MockPromise());
@@ -156,10 +157,10 @@ public class NavigatorTest extends BaseTest {
156 157
         BottomTabsController bottomTabsController = newTabs();
157 158
         StackController stack1 = newStack();
158 159
         StackController stack2 = newStack();
159
-        stack1.animatePush(child1, new CommandListenerAdapter());
160
-        stack2.animatePush(child2, new CommandListenerAdapter());
161
-        stack2.animatePush(child3, new CommandListenerAdapter());
162
-        stack2.animatePush(child4, new CommandListenerAdapter());
160
+        stack1.push(child1, new CommandListenerAdapter());
161
+        stack2.push(child2, new CommandListenerAdapter());
162
+        stack2.push(child3, new CommandListenerAdapter());
163
+        stack2.push(child4, new CommandListenerAdapter());
163 164
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
164 165
         uut.setRoot(bottomTabsController, new MockPromise());
165 166
 
@@ -176,11 +177,11 @@ public class NavigatorTest extends BaseTest {
176 177
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
177 178
         uut.setRoot(bottomTabsController, new MockPromise());
178 179
 
179
-        stack1.animatePush(child1, new CommandListenerAdapter());
180
-        stack2.animatePush(child2, new CommandListenerAdapter());
181
-        stack2.animatePush(child3, new CommandListenerAdapter());
182
-        stack2.animatePush(child4, new CommandListenerAdapter());
183
-        stack2.animatePush(child5, new CommandListenerAdapter() {
180
+        stack1.push(child1, new CommandListenerAdapter());
181
+        stack2.push(child2, new CommandListenerAdapter());
182
+        stack2.push(child3, new CommandListenerAdapter());
183
+        stack2.push(child4, new CommandListenerAdapter());
184
+        stack2.push(child5, new CommandListenerAdapter() {
184 185
             @Override
185 186
             public void onSuccess(String childId) {
186 187
                 uut.popTo(child2.getId(), new MockPromise());
@@ -197,11 +198,11 @@ public class NavigatorTest extends BaseTest {
197 198
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
198 199
         uut.setRoot(bottomTabsController, new MockPromise());
199 200
 
200
-        stack1.animatePush(child1, new CommandListenerAdapter());
201
-        stack2.animatePush(child2, new CommandListenerAdapter());
202
-        stack2.animatePush(child3, new CommandListenerAdapter());
203
-        stack2.animatePush(child4, new CommandListenerAdapter());
204
-        stack2.animatePush(child5, new CommandListenerAdapter() {
201
+        stack1.push(child1, new CommandListenerAdapter());
202
+        stack2.push(child2, new CommandListenerAdapter());
203
+        stack2.push(child3, new CommandListenerAdapter());
204
+        stack2.push(child4, new CommandListenerAdapter());
205
+        stack2.push(child5, new CommandListenerAdapter() {
205 206
             @Override
206 207
             public void onSuccess(String childId) {
207 208
                 uut.popToRoot(child3.getId(), new MockPromise());
@@ -212,11 +213,15 @@ public class NavigatorTest extends BaseTest {
212 213
 
213 214
     @Test
214 215
     public void setStackRoot() {
216
+        child1.options.animated = new Bool(false);
217
+        child2.options.animated = new Bool(false);
218
+        child3.options.animated = new Bool(false);
219
+
215 220
         StackController stack = newStack();
216 221
         uut.setRoot(stack, new MockPromise());
217 222
 
218
-        stack.animatePush(child1, new CommandListenerAdapter());
219
-        stack.animatePush(child2, new CommandListenerAdapter());
223
+        stack.push(child1, new CommandListenerAdapter());
224
+        stack.push(child2, new CommandListenerAdapter());
220 225
         stack.setRoot(child3, new CommandListenerAdapter());
221 226
 
222 227
         assertThat(stack.getChildControllers()).containsOnly(child3);
@@ -272,7 +277,7 @@ public class NavigatorTest extends BaseTest {
272 277
     @Test
273 278
     public void push_Promise() {
274 279
         final StackController stackController = newStack();
275
-        stackController.animatePush(child1, new CommandListenerAdapter());
280
+        stackController.push(child1, new CommandListenerAdapter());
276 281
         uut.setRoot(stackController, new MockPromise());
277 282
 
278 283
         assertIsChildById(uut.getView(), stackController.getView());
@@ -319,10 +324,10 @@ public class NavigatorTest extends BaseTest {
319 324
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
320 325
         uut.setRoot(bottomTabsController, new MockPromise());
321 326
 
322
-        stack1.animatePush(child1, new CommandListenerAdapter());
323
-        stack2.animatePush(child2, new CommandListenerAdapter());
324
-        stack2.animatePush(child3, new CommandListenerAdapter());
325
-        stack2.animatePush(child4, new CommandListenerAdapter() {
327
+        stack1.push(child1, new CommandListenerAdapter());
328
+        stack2.push(child2, new CommandListenerAdapter());
329
+        stack2.push(child3, new CommandListenerAdapter());
330
+        stack2.push(child4, new CommandListenerAdapter() {
326 331
             @Override
327 332
             public void onSuccess(String childId) {
328 333
                 uut.pop("child4", new MockPromise());
@@ -343,6 +348,8 @@ public class NavigatorTest extends BaseTest {
343 348
 
344 349
     @Test
345 350
     public void pushedStackCanBePopped() {
351
+        child1.options.animated = new Bool(false);
352
+        child2.options.animated = new Bool(false);
346 353
         StackController parent = newStack();
347 354
         parent.ensureViewIsCreated();
348 355
         uut.setRoot(parent, new MockPromise());

+ 3
- 3
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java View File

@@ -73,7 +73,7 @@ public class OptionsApplyingTest extends BaseTest {
73 73
         uut.options.topBarOptions.title.text = new Text("the title");
74 74
         StackController stackController =
75 75
                 new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stackId", new Options());
76
-        stackController.animatePush(uut, new CommandListenerAdapter());
76
+        stackController.push(uut, new CommandListenerAdapter());
77 77
         assertThat(stackController.getTopBar().getTitle()).isEmpty();
78 78
 
79 79
         uut.onViewAppeared();
@@ -118,7 +118,7 @@ public class OptionsApplyingTest extends BaseTest {
118 118
     @Test
119 119
     public void appliesTopBarTextColor() {
120 120
         assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
121
-        stackController.animatePush(uut, new CommandListenerAdapter() {
121
+        stackController.push(uut, new CommandListenerAdapter() {
122 122
             @Override
123 123
             public void onSuccess(String childId) {
124 124
                 Options opts = new Options();
@@ -169,7 +169,7 @@ public class OptionsApplyingTest extends BaseTest {
169 169
         uut.options.topBarOptions.title.text = new Text("the title");
170 170
         uut.options.topBarOptions.drawBehind = new Bool(false);
171 171
         uut.ensureViewIsCreated();
172
-        stackController.animatePush(uut, new CommandListenerAdapter() {
172
+        stackController.push(uut, new CommandListenerAdapter() {
173 173
             @Override
174 174
             public void onSuccess(String childId) {
175 175
                 uut.onViewAppeared();

+ 3
- 3
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java View File

@@ -95,8 +95,8 @@ public class ParentControllerTest extends BaseTest {
95 95
         StackController stackController = createStack();
96 96
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
97 97
         SimpleViewController child2 = new SimpleViewController(activity, "child2", new Options());
98
-        stackController.animatePush(child1, new CommandListenerAdapter());
99
-        stackController.animatePush(child2, new CommandListenerAdapter());
98
+        stackController.push(child1, new CommandListenerAdapter());
99
+        stackController.push(child2, new CommandListenerAdapter());
100 100
         children.add(stackController);
101 101
 
102 102
         assertThat(uut.findControllerById("child2")).isEqualTo(child2);
@@ -116,7 +116,7 @@ public class ParentControllerTest extends BaseTest {
116 116
     public void optionsAreClearedWhenChildIsAppeared() {
117 117
         StackController stackController = spy(createStack());
118 118
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
119
-        stackController.animatePush(child1, new CommandListenerAdapter());
119
+        stackController.push(child1, new CommandListenerAdapter());
120 120
 
121 121
         child1.onViewAppeared();
122 122
         verify(stackController, times(1)).clearOptions();

+ 52
- 47
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java View File

@@ -66,9 +66,9 @@ public class StackControllerTest extends BaseTest {
66 66
     @Test
67 67
     public void holdsAStackOfViewControllers() {
68 68
         assertThat(uut.isEmpty()).isTrue();
69
-        uut.animatePush(child1, new CommandListenerAdapter());
70
-        uut.animatePush(child2, new CommandListenerAdapter());
71
-        uut.animatePush(child3, new CommandListenerAdapter());
69
+        uut.push(child1, new CommandListenerAdapter());
70
+        uut.push(child2, new CommandListenerAdapter());
71
+        uut.push(child3, new CommandListenerAdapter());
72 72
         assertThat(uut.peek()).isEqualTo(child3);
73 73
         assertContainsOnlyId(child1.getId(), child2.getId(), child3.getId());
74 74
     }
@@ -76,7 +76,7 @@ public class StackControllerTest extends BaseTest {
76 76
     @Test
77 77
     public void push() {
78 78
         assertThat(uut.isEmpty()).isTrue();
79
-        uut.animatePush(child1, new CommandListenerAdapter());
79
+        uut.push(child1, new CommandListenerAdapter());
80 80
         assertContainsOnlyId(child1.getId());
81 81
     }
82 82
 
@@ -85,7 +85,7 @@ public class StackControllerTest extends BaseTest {
85 85
         assertThat(uut.isEmpty()).isTrue();
86 86
         uut.push(child1, new CommandListenerAdapter());
87 87
         uut.push(child2, new CommandListenerAdapter());
88
-        uut.animateSetRoot(child3, new CommandListenerAdapter() {
88
+        uut.setRoot(child3, new CommandListenerAdapter() {
89 89
             @Override
90 90
             public void onSuccess(String childId) {
91 91
                 assertContainsOnlyId(child3.getId());
@@ -108,8 +108,8 @@ public class StackControllerTest extends BaseTest {
108 108
 
109 109
     @Test
110 110
     public void pop() {
111
-        uut.animatePush(child1, new CommandListenerAdapter());
112
-        uut.animatePush(child2, new CommandListenerAdapter() {
111
+        uut.push(child1, new CommandListenerAdapter());
112
+        uut.push(child2, new CommandListenerAdapter() {
113 113
             @Override
114 114
             public void onSuccess(String childId) {
115 115
                 assertContainsOnlyId(child2.getId(), child1.getId());
@@ -121,8 +121,8 @@ public class StackControllerTest extends BaseTest {
121 121
 
122 122
     @Test
123 123
     public void pop_appliesOptionsAfterPop() {
124
-        uut.animatePush(child1, new CommandListenerAdapter());
125
-        uut.animatePush(child2, new CommandListenerAdapter() {
124
+        uut.push(child1, new CommandListenerAdapter());
125
+        uut.push(child2, new CommandListenerAdapter() {
126 126
             @Override
127 127
             public void onSuccess(String childId) {
128 128
                 uut.pop(new MockPromise());
@@ -144,7 +144,7 @@ public class StackControllerTest extends BaseTest {
144 144
                     }
145 145
                 };
146 146
         uut.push(child1, new CommandListenerAdapter());
147
-        uut.animatePush(child2, new CommandListenerAdapter() {
147
+        uut.push(child2, new CommandListenerAdapter() {
148 148
             @Override
149 149
             public void onSuccess(String childId) {
150 150
                 uut.animatePop(new MockPromise() {
@@ -163,7 +163,7 @@ public class StackControllerTest extends BaseTest {
163 163
         assertThat(uut.peek()).isNull();
164 164
         assertThat(uut.size()).isZero();
165 165
         assertThat(uut.isEmpty()).isTrue();
166
-        uut.animatePush(child1, new CommandListenerAdapter());
166
+        uut.push(child1, new CommandListenerAdapter());
167 167
         assertThat(uut.peek()).isEqualTo(child1);
168 168
         assertThat(uut.size()).isEqualTo(1);
169 169
         assertThat(uut.isEmpty()).isFalse();
@@ -172,11 +172,11 @@ public class StackControllerTest extends BaseTest {
172 172
     @Test
173 173
     public void pushAssignsRefToSelfOnPushedController() {
174 174
         assertThat(child1.getParentController()).isNull();
175
-        uut.animatePush(child1, new CommandListenerAdapter());
175
+        uut.push(child1, new CommandListenerAdapter());
176 176
         assertThat(child1.getParentController()).isEqualTo(uut);
177 177
 
178 178
         StackController anotherNavController = createStackController("another");
179
-        anotherNavController.animatePush(child2, new CommandListenerAdapter());
179
+        anotherNavController.push(child2, new CommandListenerAdapter());
180 180
         assertThat(child2.getParentController()).isEqualTo(anotherNavController);
181 181
     }
182 182
 
@@ -185,11 +185,11 @@ public class StackControllerTest extends BaseTest {
185 185
         assertThat(uut.isEmpty()).isTrue();
186 186
         assertThat(uut.handleBack()).isFalse();
187 187
 
188
-        uut.animatePush(child1, new CommandListenerAdapter());
188
+        uut.push(child1, new CommandListenerAdapter());
189 189
         assertThat(uut.size()).isEqualTo(1);
190 190
         assertThat(uut.handleBack()).isFalse();
191 191
 
192
-        uut.animatePush(child2, new CommandListenerAdapter() {
192
+        uut.push(child2, new CommandListenerAdapter() {
193 193
             @Override
194 194
             public void onSuccess(String childId) {
195 195
                 assertThat(uut.size()).isEqualTo(2);
@@ -207,7 +207,7 @@ public class StackControllerTest extends BaseTest {
207 207
         uut.pop(new MockPromise());
208 208
         assertThat(uut.isEmpty()).isTrue();
209 209
 
210
-        uut.animatePush(child1, new CommandListenerAdapter());
210
+        uut.push(child1, new CommandListenerAdapter());
211 211
         uut.pop(new MockPromise());
212 212
         assertContainsOnlyId(child1.getId());
213 213
     }
@@ -216,10 +216,10 @@ public class StackControllerTest extends BaseTest {
216 216
     public void canPopWhenSizeIsMoreThanOne() {
217 217
         assertThat(uut.isEmpty()).isTrue();
218 218
         assertThat(uut.canPop()).isFalse();
219
-        uut.animatePush(child1, new CommandListenerAdapter());
219
+        uut.push(child1, new CommandListenerAdapter());
220 220
         assertContainsOnlyId(child1.getId());
221 221
         assertThat(uut.canPop()).isFalse();
222
-        uut.animatePush(child2, new CommandListenerAdapter());
222
+        uut.push(child2, new CommandListenerAdapter());
223 223
         assertContainsOnlyId(child1.getId(), child2.getId());
224 224
         assertThat(uut.canPop()).isTrue();
225 225
     }
@@ -227,16 +227,16 @@ public class StackControllerTest extends BaseTest {
227 227
     @Test
228 228
     public void pushAddsToViewTree() {
229 229
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
230
-        uut.animatePush(child1, new CommandListenerAdapter());
230
+        uut.push(child1, new CommandListenerAdapter());
231 231
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
232 232
     }
233 233
 
234 234
     @Test
235 235
     public void pushRemovesPreviousFromTree() {
236 236
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
237
-        uut.animatePush(child1, new CommandListenerAdapter());
237
+        uut.push(child1, new CommandListenerAdapter());
238 238
         assertThat(uut.getView().findViewById(child1.getView().getId())).isNotNull();
239
-        uut.animatePush(child2, new CommandListenerAdapter() {
239
+        uut.push(child2, new CommandListenerAdapter() {
240 240
             @Override
241 241
             public void onSuccess(String childId) {
242 242
                 assertThat(uut.getView().findViewById(child1.getView().getId())).isNull();
@@ -250,8 +250,8 @@ public class StackControllerTest extends BaseTest {
250 250
         final View child2View = child2.getView();
251 251
         final View child1View = child1.getView();
252 252
 
253
-        uut.animatePush(child1, new CommandListenerAdapter());
254
-        uut.animatePush(child2, new CommandListenerAdapter() {
253
+        uut.push(child1, new CommandListenerAdapter());
254
+        uut.push(child2, new CommandListenerAdapter() {
255 255
             @Override
256 256
             public void onSuccess(String childId) {
257 257
                 assertIsChildById(uut.getView(), child2View);
@@ -265,8 +265,8 @@ public class StackControllerTest extends BaseTest {
265 265
 
266 266
     @Test
267 267
     public void popSpecificWhenTopIsRegularPop() {
268
-        uut.animatePush(child1, new CommandListenerAdapter());
269
-        uut.animatePush(child2, new CommandListenerAdapter() {
268
+        uut.push(child1, new CommandListenerAdapter());
269
+        uut.push(child2, new CommandListenerAdapter() {
270 270
             @Override
271 271
             public void onSuccess(String childId) {
272 272
                 uut.popSpecific(child2, new MockPromise() {
@@ -282,8 +282,8 @@ public class StackControllerTest extends BaseTest {
282 282
 
283 283
     @Test
284 284
     public void popSpecificDeepInStack() {
285
-        uut.animatePush(child1, new CommandListenerAdapter());
286
-        uut.animatePush(child2, new CommandListenerAdapter());
285
+        uut.push(child1, new CommandListenerAdapter());
286
+        uut.push(child2, new CommandListenerAdapter());
287 287
         assertIsChildById(uut.getView(), child2.getView());
288 288
         uut.popSpecific(child1, new MockPromise());
289 289
         assertContainsOnlyId(child2.getId());
@@ -292,9 +292,9 @@ public class StackControllerTest extends BaseTest {
292 292
 
293 293
     @Test
294 294
     public void popTo_PopsTopUntilControllerIsNewTop() {
295
-        uut.animatePush(child1, new CommandListenerAdapter());
296
-        uut.animatePush(child2, new CommandListenerAdapter());
297
-        uut.animatePush(child3, new CommandListenerAdapter() {
295
+        uut.push(child1, new CommandListenerAdapter());
296
+        uut.push(child2, new CommandListenerAdapter());
297
+        uut.push(child3, new CommandListenerAdapter() {
298 298
             @Override
299 299
             public void onSuccess(String childId) {
300 300
                 assertThat(uut.size()).isEqualTo(3);
@@ -310,8 +310,8 @@ public class StackControllerTest extends BaseTest {
310 310
 
311 311
     @Test
312 312
     public void popTo_NotAChildOfThisStack_DoesNothing() {
313
-        uut.animatePush(child1, new CommandListenerAdapter());
314
-        uut.animatePush(child3, new CommandListenerAdapter());
313
+        uut.push(child1, new CommandListenerAdapter());
314
+        uut.push(child3, new CommandListenerAdapter());
315 315
         assertThat(uut.size()).isEqualTo(2);
316 316
         uut.popTo(child2, new MockPromise());
317 317
         assertThat(uut.size()).isEqualTo(2);
@@ -319,9 +319,12 @@ public class StackControllerTest extends BaseTest {
319 319
 
320 320
     @Test
321 321
     public void popToRoot_PopsEverythingAboveFirstController() {
322
-        uut.animatePush(child1, new CommandListenerAdapter());
323
-        uut.animatePush(child2, new CommandListenerAdapter());
324
-        uut.animatePush(child3, new CommandListenerAdapter() {
322
+        child1.options.animated = new Bool(false);
323
+        child2.options.animated = new Bool(false);
324
+
325
+        uut.push(child1, new CommandListenerAdapter());
326
+        uut.push(child2, new CommandListenerAdapter());
327
+        uut.push(child3, new CommandListenerAdapter() {
325 328
             @Override
326 329
             public void onSuccess(String childId) {
327 330
                 assertThat(uut.size()).isEqualTo(3);
@@ -349,15 +352,15 @@ public class StackControllerTest extends BaseTest {
349 352
     public void findControllerById_ReturnsSelfOrChildrenById() {
350 353
         assertThat(uut.findControllerById("123")).isNull();
351 354
         assertThat(uut.findControllerById(uut.getId())).isEqualTo(uut);
352
-        uut.animatePush(child1, new CommandListenerAdapter());
355
+        uut.push(child1, new CommandListenerAdapter());
353 356
         assertThat(uut.findControllerById(child1.getId())).isEqualTo(child1);
354 357
     }
355 358
 
356 359
     @Test
357 360
     public void findControllerById_Deeply() {
358 361
         StackController stack = createStackController("another");
359
-        stack.animatePush(child2, new CommandListenerAdapter());
360
-        uut.animatePush(stack, new CommandListenerAdapter());
362
+        stack.push(child2, new CommandListenerAdapter());
363
+        uut.push(stack, new CommandListenerAdapter());
361 364
         assertThat(uut.findControllerById(child2.getId())).isEqualTo(child2);
362 365
     }
363 366
 
@@ -366,9 +369,9 @@ public class StackControllerTest extends BaseTest {
366 369
         child1 = spy(child1);
367 370
         child2 = spy(child2);
368 371
         child3 = spy(child3);
369
-        uut.animatePush(child1, new CommandListenerAdapter());
370
-        uut.animatePush(child2, new CommandListenerAdapter());
371
-        uut.animatePush(child3, new CommandListenerAdapter() {
372
+        uut.push(child1, new CommandListenerAdapter());
373
+        uut.push(child2, new CommandListenerAdapter());
374
+        uut.push(child3, new CommandListenerAdapter() {
372 375
             @Override
373 376
             public void onSuccess(String childId) {
374 377
                 verify(child3, times(0)).destroy();
@@ -380,6 +383,8 @@ public class StackControllerTest extends BaseTest {
380 383
 
381 384
     @Test
382 385
     public void pop_callWillAppearWillDisappear() {
386
+        child1.options.animated = new Bool(false);
387
+        child2.options.animated = new Bool(false);
383 388
         child1 = spy(child1);
384 389
         child2 = spy(child2);
385 390
         uut.push(child1, new CommandListenerAdapter());
@@ -414,9 +419,9 @@ public class StackControllerTest extends BaseTest {
414 419
         child1 = spy(child1);
415 420
         child2 = spy(child2);
416 421
         child3 = spy(child3);
417
-        uut.animatePush(child1, new CommandListenerAdapter());
418
-        uut.animatePush(child2, new CommandListenerAdapter());
419
-        uut.animatePush(child3, new CommandListenerAdapter());
422
+        uut.push(child1, new CommandListenerAdapter());
423
+        uut.push(child2, new CommandListenerAdapter());
424
+        uut.push(child3, new CommandListenerAdapter());
420 425
 
421 426
         verify(child2, times(0)).destroy();
422 427
         uut.popSpecific(child2, new MockPromise());
@@ -428,9 +433,9 @@ public class StackControllerTest extends BaseTest {
428 433
         child1 = spy(child1);
429 434
         child2 = spy(child2);
430 435
         child3 = spy(child3);
431
-        uut.animatePush(child1, new CommandListenerAdapter());
432
-        uut.animatePush(child2, new CommandListenerAdapter());
433
-        uut.animatePush(child3, new CommandListenerAdapter() {
436
+        uut.push(child1, new CommandListenerAdapter());
437
+        uut.push(child2, new CommandListenerAdapter());
438
+        uut.push(child3, new CommandListenerAdapter() {
434 439
             @Override
435 440
             public void onSuccess(String childId) {
436 441
                 verify(child2, times(0)).destroy();

+ 3
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java View File

@@ -12,6 +12,7 @@ import com.reactnativenavigation.mocks.TitleBarReactViewCreatorMock;
12 12
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
13 13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14 14
 import com.reactnativenavigation.parse.Options;
15
+import com.reactnativenavigation.parse.params.Bool;
15 16
 import com.reactnativenavigation.parse.params.Text;
16 17
 import com.reactnativenavigation.utils.ViewHelper;
17 18
 import com.reactnativenavigation.viewcontrollers.topbar.TopBarBackgroundViewController;
@@ -232,6 +233,8 @@ public class TopTabsViewControllerTest extends BaseTest {
232 233
                 new TestComponentViewCreator(),
233 234
                 new Options()
234 235
         );
236
+        first.options.animated = new Bool(false);
237
+        uut.options.animated = new Bool(false);
235 238
         stackController.push(first);
236 239
         stackController.push(uut);
237 240
 

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java View File

@@ -71,7 +71,7 @@ public class ViewControllerTest extends BaseTest {
71 71
     public void holdsAReferenceToStackControllerOrNull() {
72 72
         assertThat(uut.getParentController()).isNull();
73 73
         StackController nav = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options());
74
-        nav.animatePush(uut, new CommandListenerAdapter());
74
+        nav.push(uut, new CommandListenerAdapter());
75 75
         assertThat(uut.getParentController()).isEqualTo(nav);
76 76
     }
77 77