Przeglądaj źródła

Consolidate push and animatePush

Screen presentation logic in stack should be moved to a dedicated presenter
Guy Carmeli 7 lat temu
rodzic
commit
99b019008f

+ 20
- 12
lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java Wyświetl plik

3
 import android.support.annotation.CheckResult;
3
 import android.support.annotation.CheckResult;
4
 import android.support.annotation.NonNull;
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
 import com.reactnativenavigation.utils.TypefaceLoader;
9
 import com.reactnativenavigation.utils.TypefaceLoader;
7
 
10
 
8
 import org.json.JSONObject;
11
 import org.json.JSONObject;
27
         result.bottomTabsOptions = BottomTabsOptions.parse(json.optJSONObject("bottomTabs"));
30
         result.bottomTabsOptions = BottomTabsOptions.parse(json.optJSONObject("bottomTabs"));
28
         result.overlayOptions = OverlayOptions.parse(json.optJSONObject("overlay"));
31
         result.overlayOptions = OverlayOptions.parse(json.optJSONObject("overlay"));
29
         result.fabOptions = FabOptions.parse(json.optJSONObject("fab"));
32
         result.fabOptions = FabOptions.parse(json.optJSONObject("fab"));
30
-        result.animationsOptions = AnimationsOptions.parse(json.optJSONObject("animations"));
31
         result.sideMenuRootOptions = SideMenuRootOptions.parse(json.optJSONObject("sideMenu"));
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
         return result.withDefaultOptions(defaultOptions);
37
         return result.withDefaultOptions(defaultOptions);
34
     }
38
     }
43
     @NonNull public FabOptions fabOptions = new FabOptions();
47
     @NonNull public FabOptions fabOptions = new FabOptions();
44
     @NonNull public AnimationsOptions animationsOptions = new AnimationsOptions();
48
     @NonNull public AnimationsOptions animationsOptions = new AnimationsOptions();
45
     @NonNull public SideMenuRootOptions sideMenuRootOptions = new SideMenuRootOptions();
49
     @NonNull public SideMenuRootOptions sideMenuRootOptions = new SideMenuRootOptions();
50
+    @NonNull public Bool animated = new NullBool();
46
 
51
 
47
     void setTopTabIndex(int i) {
52
     void setTopTabIndex(int i) {
48
         topTabOptions.tabIndex = i;
53
         topTabOptions.tabIndex = i;
59
         result.bottomTabsOptions.mergeWith(bottomTabsOptions);
64
         result.bottomTabsOptions.mergeWith(bottomTabsOptions);
60
         result.overlayOptions = overlayOptions;
65
         result.overlayOptions = overlayOptions;
61
         result.fabOptions.mergeWith(fabOptions);
66
         result.fabOptions.mergeWith(fabOptions);
62
-        result.animationsOptions.mergeWith(animationsOptions);
63
         result.sideMenuRootOptions.mergeWith(sideMenuRootOptions);
67
         result.sideMenuRootOptions.mergeWith(sideMenuRootOptions);
68
+        result.animationsOptions.mergeWith(animationsOptions);
69
+        result.animated = animated;
64
         return result;
70
         return result;
65
     }
71
     }
66
 
72
 
76
         result.fabOptions.mergeWith(other.fabOptions);
82
         result.fabOptions.mergeWith(other.fabOptions);
77
         result.animationsOptions.mergeWith(other.animationsOptions);
83
         result.animationsOptions.mergeWith(other.animationsOptions);
78
         result.sideMenuRootOptions.mergeWith(other.sideMenuRootOptions);
84
         result.sideMenuRootOptions.mergeWith(other.sideMenuRootOptions);
85
+        if (other.animated.hasValue()) result.animated = other.animated;
79
         return result;
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
         return this;
100
         return this;
93
     }
101
     }
94
 
102
 

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java Wyświetl plik

107
     public void push(final String fromId, final ViewController viewController, CommandListener listener) {
107
     public void push(final String fromId, final ViewController viewController, CommandListener listener) {
108
         ViewController from = findControllerById(fromId);
108
         ViewController from = findControllerById(fromId);
109
         if (from != null) {
109
         if (from != null) {
110
-            from.performOnParentStack(stack -> ((StackController) stack).animatePush(viewController, listener));
110
+            from.performOnParentStack(stack -> ((StackController) stack).push(viewController, listener));
111
         } else {
111
         } else {
112
             listener.onError("Could not push component: " + viewController.getId() + ". Stack with id " + fromId + " was not found.");
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 Wyświetl plik

99
 
99
 
100
     public void push(ViewController child, CommandListener listener) {
100
     public void push(ViewController child, CommandListener listener) {
101
         final ViewController toRemove = stack.peek();
101
         final ViewController toRemove = stack.peek();
102
-
103
         child.setParentController(this);
102
         child.setParentController(this);
104
         stack.push(child.getId(), child);
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
         if (toRemove != null) {
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
                 getView().removeView(toRemove.getView());
113
                 getView().removeView(toRemove.getView());
125
                 listener.onSuccess(child.getId());
114
                 listener.onSuccess(child.getId());
126
-            });
127
-        } else {
128
-            listener.onSuccess(child.getId());
115
+            }
129
         }
116
         }
130
     }
117
     }
131
 
118
 
132
     public void setRoot(ViewController child, CommandListener listener) {
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
             @Override
121
             @Override
141
             public void onSuccess(String childId) {
122
             public void onSuccess(String childId) {
142
                 removeChildrenBellowTop();
123
                 removeChildrenBellowTop();

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java Wyświetl plik

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

+ 5
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/FloatingActionButtonTest.java Wyświetl plik

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

+ 35
- 28
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigatorTest.java Wyświetl plik

12
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
12
 import com.reactnativenavigation.mocks.TopBarBackgroundViewCreatorMock;
13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
13
 import com.reactnativenavigation.mocks.TopBarButtonCreatorMock;
14
 import com.reactnativenavigation.parse.Options;
14
 import com.reactnativenavigation.parse.Options;
15
+import com.reactnativenavigation.parse.params.Bool;
15
 import com.reactnativenavigation.parse.params.Text;
16
 import com.reactnativenavigation.parse.params.Text;
16
 import com.reactnativenavigation.utils.CommandListenerAdapter;
17
 import com.reactnativenavigation.utils.CommandListenerAdapter;
17
 import com.reactnativenavigation.utils.CompatUtils;
18
 import com.reactnativenavigation.utils.CompatUtils;
83
     @Test
84
     @Test
84
     public void push() {
85
     public void push() {
85
         StackController stackController = newStack();
86
         StackController stackController = newStack();
86
-        stackController.animatePush(child1, new CommandListenerAdapter());
87
+        stackController.push(child1, new CommandListenerAdapter());
87
         uut.setRoot(stackController, new MockPromise());
88
         uut.setRoot(stackController, new MockPromise());
88
 
89
 
89
         assertIsChildById(uut.getView(), stackController.getView());
90
         assertIsChildById(uut.getView(), stackController.getView());
107
         BottomTabsController bottomTabsController = newTabs();
108
         BottomTabsController bottomTabsController = newTabs();
108
         StackController stack1 = newStack();
109
         StackController stack1 = newStack();
109
         StackController stack2 = newStack();
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
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
113
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
113
         uut.setRoot(bottomTabsController, new MockPromise());
114
         uut.setRoot(bottomTabsController, new MockPromise());
114
 
115
 
134
         StackController stack2 = newStack();
135
         StackController stack2 = newStack();
135
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
136
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
136
         uut.setRoot(bottomTabsController, new MockPromise());
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
             @Override
141
             @Override
141
             public void onSuccess(String childId) {
142
             public void onSuccess(String childId) {
142
-                stack2.animatePush(child4, new CommandListenerAdapter() {
143
+                stack2.push(child4, new CommandListenerAdapter() {
143
                             @Override
144
                             @Override
144
                             public void onSuccess(String childId) {
145
                             public void onSuccess(String childId) {
145
                                 uut.pop("child4", new MockPromise());
146
                                 uut.pop("child4", new MockPromise());
156
         BottomTabsController bottomTabsController = newTabs();
157
         BottomTabsController bottomTabsController = newTabs();
157
         StackController stack1 = newStack();
158
         StackController stack1 = newStack();
158
         StackController stack2 = newStack();
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
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
164
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
164
         uut.setRoot(bottomTabsController, new MockPromise());
165
         uut.setRoot(bottomTabsController, new MockPromise());
165
 
166
 
176
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
177
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
177
         uut.setRoot(bottomTabsController, new MockPromise());
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
             @Override
185
             @Override
185
             public void onSuccess(String childId) {
186
             public void onSuccess(String childId) {
186
                 uut.popTo(child2.getId(), new MockPromise());
187
                 uut.popTo(child2.getId(), new MockPromise());
197
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
198
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
198
         uut.setRoot(bottomTabsController, new MockPromise());
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
             @Override
206
             @Override
206
             public void onSuccess(String childId) {
207
             public void onSuccess(String childId) {
207
                 uut.popToRoot(child3.getId(), new MockPromise());
208
                 uut.popToRoot(child3.getId(), new MockPromise());
212
 
213
 
213
     @Test
214
     @Test
214
     public void setStackRoot() {
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
         StackController stack = newStack();
220
         StackController stack = newStack();
216
         uut.setRoot(stack, new MockPromise());
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
         stack.setRoot(child3, new CommandListenerAdapter());
225
         stack.setRoot(child3, new CommandListenerAdapter());
221
 
226
 
222
         assertThat(stack.getChildControllers()).containsOnly(child3);
227
         assertThat(stack.getChildControllers()).containsOnly(child3);
272
     @Test
277
     @Test
273
     public void push_Promise() {
278
     public void push_Promise() {
274
         final StackController stackController = newStack();
279
         final StackController stackController = newStack();
275
-        stackController.animatePush(child1, new CommandListenerAdapter());
280
+        stackController.push(child1, new CommandListenerAdapter());
276
         uut.setRoot(stackController, new MockPromise());
281
         uut.setRoot(stackController, new MockPromise());
277
 
282
 
278
         assertIsChildById(uut.getView(), stackController.getView());
283
         assertIsChildById(uut.getView(), stackController.getView());
319
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
324
         bottomTabsController.setTabs(Arrays.asList(stack1, stack2));
320
         uut.setRoot(bottomTabsController, new MockPromise());
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
             @Override
331
             @Override
327
             public void onSuccess(String childId) {
332
             public void onSuccess(String childId) {
328
                 uut.pop("child4", new MockPromise());
333
                 uut.pop("child4", new MockPromise());
343
 
348
 
344
     @Test
349
     @Test
345
     public void pushedStackCanBePopped() {
350
     public void pushedStackCanBePopped() {
351
+        child1.options.animated = new Bool(false);
352
+        child2.options.animated = new Bool(false);
346
         StackController parent = newStack();
353
         StackController parent = newStack();
347
         parent.ensureViewIsCreated();
354
         parent.ensureViewIsCreated();
348
         uut.setRoot(parent, new MockPromise());
355
         uut.setRoot(parent, new MockPromise());

+ 3
- 3
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java Wyświetl plik

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

+ 3
- 3
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ParentControllerTest.java Wyświetl plik

95
         StackController stackController = createStack();
95
         StackController stackController = createStack();
96
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
96
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
97
         SimpleViewController child2 = new SimpleViewController(activity, "child2", new Options());
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
         children.add(stackController);
100
         children.add(stackController);
101
 
101
 
102
         assertThat(uut.findControllerById("child2")).isEqualTo(child2);
102
         assertThat(uut.findControllerById("child2")).isEqualTo(child2);
116
     public void optionsAreClearedWhenChildIsAppeared() {
116
     public void optionsAreClearedWhenChildIsAppeared() {
117
         StackController stackController = spy(createStack());
117
         StackController stackController = spy(createStack());
118
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
118
         SimpleViewController child1 = new SimpleViewController(activity, "child1", new Options());
119
-        stackController.animatePush(child1, new CommandListenerAdapter());
119
+        stackController.push(child1, new CommandListenerAdapter());
120
 
120
 
121
         child1.onViewAppeared();
121
         child1.onViewAppeared();
122
         verify(stackController, times(1)).clearOptions();
122
         verify(stackController, times(1)).clearOptions();

+ 52
- 47
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/StackControllerTest.java Wyświetl plik

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

+ 3
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/TopTabsViewControllerTest.java Wyświetl plik

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

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/ViewControllerTest.java Wyświetl plik

71
     public void holdsAReferenceToStackControllerOrNull() {
71
     public void holdsAReferenceToStackControllerOrNull() {
72
         assertThat(uut.getParentController()).isNull();
72
         assertThat(uut.getParentController()).isNull();
73
         StackController nav = new StackController(activity, new TopBarButtonCreatorMock(), new TitleBarReactViewCreatorMock(), new TopBarBackgroundViewController(activity, new TopBarBackgroundViewCreatorMock()), new TopBarController(), "stack", new Options());
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
         assertThat(uut.getParentController()).isEqualTo(nav);
75
         assertThat(uut.getParentController()).isEqualTo(nav);
76
     }
76
     }
77
 
77