Browse Source

Remove push overload

Guy Carmeli 6 years ago
parent
commit
67755362e5

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

3
 import android.app.Activity;
3
 import android.app.Activity;
4
 
4
 
5
 import com.facebook.react.ReactInstanceManager;
5
 import com.facebook.react.ReactInstanceManager;
6
+import com.reactnativenavigation.utils.CommandListenerAdapter;
6
 import com.reactnativenavigation.utils.ImageLoader;
7
 import com.reactnativenavigation.utils.ImageLoader;
7
 import com.reactnativenavigation.utils.TypefaceLoader;
8
 import com.reactnativenavigation.utils.TypefaceLoader;
8
 import com.reactnativenavigation.viewcontrollers.ComponentViewController;
9
 import com.reactnativenavigation.viewcontrollers.ComponentViewController;
136
 
137
 
137
     private void addChildrenToStack(List<LayoutNode> children, StackController stackController) {
138
     private void addChildrenToStack(List<LayoutNode> children, StackController stackController) {
138
         for (LayoutNode child : children) {
139
         for (LayoutNode child : children) {
139
-            stackController.push(create(child));
140
+            stackController.push(create(child), new CommandListenerAdapter());
140
         }
141
         }
141
     }
142
     }
142
 
143
 

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

89
         topBarController.clear();
89
         topBarController.clear();
90
     }
90
     }
91
 
91
 
92
-    public void push(ViewController child) {
93
-        push(child, new CommandListenerAdapter());
94
-    }
95
-
96
     public void push(ViewController child, CommandListener listener) {
92
     public void push(ViewController child, CommandListener listener) {
97
         final ViewController toRemove = stack.peek();
93
         final ViewController toRemove = stack.peek();
98
         child.setParentController(this);
94
         child.setParentController(this);

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

137
 
137
 
138
         StackController stack = spy(createStack("stack"));
138
         StackController stack = spy(createStack("stack"));
139
         stack.ensureViewIsCreated();
139
         stack.ensureViewIsCreated();
140
-        stack.push(uut);
140
+        stack.push(uut, new CommandListenerAdapter());
141
 
141
 
142
         child1.onViewAppeared();
142
         child1.onViewAppeared();
143
         ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);
143
         ArgumentCaptor<Options> optionsCaptor = ArgumentCaptor.forClass(Options.class);

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

83
 
83
 
84
     @Test
84
     @Test
85
     public void showOnPush() {
85
     public void showOnPush() {
86
-        stackController.push(childFab);
86
+        stackController.push(childFab, new CommandListenerAdapter());
87
         childFab.onViewAppeared();
87
         childFab.onViewAppeared();
88
         assertThat(hasFab()).isTrue();
88
         assertThat(hasFab()).isTrue();
89
     }
89
     }
90
 
90
 
91
     @Test
91
     @Test
92
     public void hideOnPush() {
92
     public void hideOnPush() {
93
-        stackController.push(childFab);
93
+        stackController.push(childFab, new CommandListenerAdapter());
94
         childFab.onViewAppeared();
94
         childFab.onViewAppeared();
95
         assertThat(hasFab()).isTrue();
95
         assertThat(hasFab()).isTrue();
96
-        stackController.push(childNoFab);
96
+        stackController.push(childNoFab, new CommandListenerAdapter());
97
         childNoFab.onViewAppeared();
97
         childNoFab.onViewAppeared();
98
         assertThat(hasFab()).isFalse();
98
         assertThat(hasFab()).isFalse();
99
     }
99
     }
100
 
100
 
101
     @Test
101
     @Test
102
     public void hideOnPop() {
102
     public void hideOnPop() {
103
-        stackController.push(childNoFab);
104
-        stackController.push(childFab);
103
+        stackController.push(childNoFab, new CommandListenerAdapter());
104
+        stackController.push(childFab, new CommandListenerAdapter());
105
         childFab.onViewAppeared();
105
         childFab.onViewAppeared();
106
         assertThat(hasFab()).isTrue();
106
         assertThat(hasFab()).isTrue();
107
         stackController.pop(new CommandListenerAdapter());
107
         stackController.pop(new CommandListenerAdapter());
114
         childFab.options.animated = new Bool(false);
114
         childFab.options.animated = new Bool(false);
115
         childNoFab.options.animated = new Bool(false);
115
         childNoFab.options.animated = new Bool(false);
116
 
116
 
117
-        stackController.push(childFab);
118
-        stackController.push(childNoFab);
117
+        stackController.push(childFab, new CommandListenerAdapter());
118
+        stackController.push(childNoFab, new CommandListenerAdapter());
119
         childNoFab.onViewAppeared();
119
         childNoFab.onViewAppeared();
120
         assertThat(hasFab()).isFalse();
120
         assertThat(hasFab()).isFalse();
121
         stackController.pop(new CommandListenerAdapter());
121
         stackController.pop(new CommandListenerAdapter());
126
     @Test
126
     @Test
127
     public void hasChildren() {
127
     public void hasChildren() {
128
         childFab = new SimpleViewController(activity, "child1", getOptionsWithFabActions());
128
         childFab = new SimpleViewController(activity, "child1", getOptionsWithFabActions());
129
-        stackController.push(childFab);
129
+        stackController.push(childFab, new CommandListenerAdapter());
130
         childFab.onViewAppeared();
130
         childFab.onViewAppeared();
131
         assertThat(hasFab()).isTrue();
131
         assertThat(hasFab()).isTrue();
132
         assertThat(containsActions()).isTrue();
132
         assertThat(containsActions()).isTrue();

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

340
     public void pushIntoModal() {
340
     public void pushIntoModal() {
341
         uut.setRoot(parentController, new MockPromise());
341
         uut.setRoot(parentController, new MockPromise());
342
         StackController stackController = newStack();
342
         StackController stackController = newStack();
343
-        stackController.push(child1);
343
+        stackController.push(child1, new CommandListenerAdapter());
344
         uut.showModal(stackController, new MockPromise());
344
         uut.showModal(stackController, new MockPromise());
345
         uut.push(stackController.getId(), child2, new CommandListenerAdapter());
345
         uut.push(stackController.getId(), child2, new CommandListenerAdapter());
346
         assertIsChildById(stackController.getView(), child2.getView());
346
         assertIsChildById(stackController.getView(), child2.getView());
353
         StackController parent = newStack();
353
         StackController parent = newStack();
354
         parent.ensureViewIsCreated();
354
         parent.ensureViewIsCreated();
355
         uut.setRoot(parent, new MockPromise());
355
         uut.setRoot(parent, new MockPromise());
356
-        parent.push(parentController);
356
+        parent.push(parentController, new CommandListenerAdapter());
357
 
357
 
358
-        parentController.push(child1);
359
-        parentController.push(child2);
358
+        parentController.push(child1, new CommandListenerAdapter());
359
+        parentController.push(child2, new CommandListenerAdapter());
360
         assertThat(parentController.getChildControllers().size()).isEqualTo(2);
360
         assertThat(parentController.getChildControllers().size()).isEqualTo(2);
361
         child1.ensureViewIsCreated();
361
         child1.ensureViewIsCreated();
362
         child2.ensureViewIsCreated();
362
         child2.ensureViewIsCreated();

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

193
         json.put("component", new JSONObject().put("name","someComponent").put("componentId", "id"));
193
         json.put("component", new JSONObject().put("name","someComponent").put("componentId", "id"));
194
         uut.options.topBarOptions.background = TopBarBackgroundOptions.parse(json);
194
         uut.options.topBarOptions.background = TopBarBackgroundOptions.parse(json);
195
         uut.ensureViewIsCreated();
195
         uut.ensureViewIsCreated();
196
-        stackController.push(uut);
196
+        stackController.push(uut, new CommandListenerAdapter());
197
         uut.onViewAppeared();
197
         uut.onViewAppeared();
198
 
198
 
199
         assertThat(((ColorDrawable) stackController.getTopBar().getTitleBar().getBackground()).getColor()).isEqualTo(Color.TRANSPARENT);
199
         assertThat(((ColorDrawable) stackController.getTopBar().getTitleBar().getBackground()).getColor()).isEqualTo(Color.TRANSPARENT);
206
         json.put("text", "sub");
206
         json.put("text", "sub");
207
         uut.options.topBarOptions.subtitle = SubtitleOptions.parse(new TypefaceLoaderMock(), json);
207
         uut.options.topBarOptions.subtitle = SubtitleOptions.parse(new TypefaceLoaderMock(), json);
208
         uut.ensureViewIsCreated();
208
         uut.ensureViewIsCreated();
209
-        stackController.push(uut);
209
+        stackController.push(uut, new CommandListenerAdapter());
210
         uut.onViewAppeared();
210
         uut.onViewAppeared();
211
 
211
 
212
         assertThat(stackController.getTopBar().getTitleBar().getSubtitle()).isEqualTo("sub");
212
         assertThat(stackController.getTopBar().getTitleBar().getSubtitle()).isEqualTo("sub");

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

64
         tabControllers.forEach(viewController -> viewController.setParentController(uut));
64
         tabControllers.forEach(viewController -> viewController.setParentController(uut));
65
 
65
 
66
         parentController = spy(createStackController("stackId"));
66
         parentController = spy(createStackController("stackId"));
67
-        parentController.push(uut);
67
+        parentController.push(uut, new CommandListenerAdapter());
68
         uut.setParentController(parentController);
68
         uut.setParentController(parentController);
69
     }
69
     }
70
 
70
 
233
         );
233
         );
234
         first.options.animated = new Bool(false);
234
         first.options.animated = new Bool(false);
235
         uut.options.animated = new Bool(false);
235
         uut.options.animated = new Bool(false);
236
-        stackController.push(first);
237
-        stackController.push(uut);
236
+        stackController.push(first, new CommandListenerAdapter());
237
+        stackController.push(uut, new CommandListenerAdapter());
238
 
238
 
239
         first.ensureViewIsCreated();
239
         first.ensureViewIsCreated();
240
         uut.ensureViewIsCreated();
240
         uut.ensureViewIsCreated();