Browse Source

Always add screens behind TopBar

This resolves a few edge cases where screens overlapped the TopBar
Guy Carmeli 6 years ago
parent
commit
f49f43d28e

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

158
         view.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
158
         view.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
159
         child.setWaitForRender(resolvedOptions.animations.push.waitForRender);
159
         child.setWaitForRender(resolvedOptions.animations.push.waitForRender);
160
         presenter.applyLayoutParamsOptions(resolvedOptions, view);
160
         presenter.applyLayoutParamsOptions(resolvedOptions, view);
161
-        getView().addView(view);
161
+        getView().addView(view, getView().getChildCount() - 1);
162
     }
162
     }
163
 
163
 
164
     public void setRoot(ViewController child, CommandListener listener) {
164
     public void setRoot(ViewController child, CommandListener listener) {
312
         child.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
312
         child.setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
313
         Options options = resolveCurrentOptions();
313
         Options options = resolveCurrentOptions();
314
         presenter.applyLayoutParamsOptions(options, child);
314
         presenter.applyLayoutParamsOptions(options, child);
315
-        stackLayout.addView(child);
315
+        stackLayout.addView(child, 0);
316
     }
316
     }
317
 
317
 
318
     private void onNavigationButtonPressed(String buttonId) {
318
     private void onNavigationButtonPressed(String buttonId) {

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

100
         StackController uut = createStack(Arrays.asList(child1, child2, child3, child4));
100
         StackController uut = createStack(Arrays.asList(child1, child2, child3, child4));
101
         assertThat(uut.getChildControllers().size()).isEqualTo(4);
101
         assertThat(uut.getChildControllers().size()).isEqualTo(4);
102
         assertThat(uut.getView().getChildCount()).isEqualTo(2);
102
         assertThat(uut.getView().getChildCount()).isEqualTo(2);
103
-        assertThat(uut.getView().getChildAt(1)).isEqualTo(child4.getView());
103
+        assertThat(uut.getView().getChildAt(0)).isEqualTo(child4.getView());
104
     }
104
     }
105
 
105
 
106
     @Test
106
     @Test
707
         parent.ensureViewIsCreated();
707
         parent.ensureViewIsCreated();
708
         parent.push(uut, new CommandListenerAdapter());
708
         parent.push(uut, new CommandListenerAdapter());
709
         uut.onViewAppeared();
709
         uut.onViewAppeared();
710
-        assertThat(parent.getView().getChildAt(1)).isEqualTo(uut.getView());
710
+        assertThat(parent.getView().getChildAt(0)).isEqualTo(uut.getView());
711
     }
711
     }
712
 
712
 
713
     @Test
713
     @Test