소스 검색

Fix incorrect bottom inset when hiding BottomTabs in default options (#5781)

Default options were not taken into account when determining bottom inset.
Closes #5738
Guy Carmeli 5 년 전
부모
커밋
d0c21e4f65
No account linked to committer's email address

+ 4
- 0
lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabsPresenter.java 파일 보기

151
         lp.bottomMargin = bottomInset;
151
         lp.bottomMargin = bottomInset;
152
         bottomTabs.requestLayout();
152
         bottomTabs.requestLayout();
153
     }
153
     }
154
+
155
+    public int getBottomInset(Options resolvedOptions) {
156
+        return resolvedOptions.withDefaultOptions(defaultOptions).bottomTabsOptions.isHiddenOrDrawBehind() ? 0 : bottomTabs.getHeight();
157
+    }
154
 }
158
 }

+ 1
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java 파일 보기

174
 
174
 
175
     @Override
175
     @Override
176
     public int getBottomInset(ViewController child) {
176
     public int getBottomInset(ViewController child) {
177
-        int bottomTabsInset = resolveChildOptions(child).bottomTabsOptions.isHiddenOrDrawBehind() ? 0 : bottomTabs.getHeight();
178
-        return bottomTabsInset + perform(getParentController(), 0, p -> p.getBottomInset(this));
177
+        return presenter.getBottomInset(resolveChildOptions(child)) + perform(getParentController(), 0, p -> p.getBottomInset(this));
179
     }
178
     }
180
 
179
 
181
     @Override
180
     @Override

+ 10
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.java 파일 보기

377
         assertThat(stackChild.getTopInset()).isEqualTo(StatusBarUtils.getStatusBarHeight(activity));
377
         assertThat(stackChild.getTopInset()).isEqualTo(StatusBarUtils.getStatusBarHeight(activity));
378
     }
378
     }
379
 
379
 
380
+    @Test
381
+    public void getBottomInset_defaultOptionsAreTakenIntoAccount() {
382
+        Options defaultOptions = new Options();
383
+        defaultOptions.bottomTabsOptions.visible = new Bool(false);
384
+
385
+        assertThat(uut.getBottomInset(child1)).isEqualTo(bottomTabs.getHeight());
386
+        uut.setDefaultOptions(defaultOptions);
387
+        assertThat(uut.getBottomInset(child1)).isZero();
388
+    }
389
+
380
     @Test
390
     @Test
381
     public void destroy() {
391
     public void destroy() {
382
         uut.destroy();
392
         uut.destroy();