浏览代码

Always add screens behind TopBar

This resolves a few edge cases where screens overlapped the TopBar
Guy Carmeli 6 年前
父节点
当前提交
f49f43d28e

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java 查看文件

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

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.java 查看文件

@@ -100,7 +100,7 @@ public class StackControllerTest extends BaseTest {
100 100
         StackController uut = createStack(Arrays.asList(child1, child2, child3, child4));
101 101
         assertThat(uut.getChildControllers().size()).isEqualTo(4);
102 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 106
     @Test
@@ -707,7 +707,7 @@ public class StackControllerTest extends BaseTest {
707 707
         parent.ensureViewIsCreated();
708 708
         parent.push(uut, new CommandListenerAdapter());
709 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 713
     @Test