Skip to content

Commit

Permalink
Fix incorrect bottom inset when hiding BottomTabs in default options (#…
Browse files Browse the repository at this point in the history
…5781)

Default options were not taken into account when determining bottom inset.
Closes #5738
  • Loading branch information
guyca authored Dec 17, 2019
1 parent 3b495cd commit d0c21e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,8 @@ public void applyBottomInset(int bottomInset) {
lp.bottomMargin = bottomInset;
bottomTabs.requestLayout();
}

public int getBottomInset(Options resolvedOptions) {
return resolvedOptions.withDefaultOptions(defaultOptions).bottomTabsOptions.isHiddenOrDrawBehind() ? 0 : bottomTabs.getHeight();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public boolean onMeasureChild(CoordinatorLayout parent, ViewGroup child, int par

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,16 @@ public void getTopInset() {
assertThat(stackChild.getTopInset()).isEqualTo(StatusBarUtils.getStatusBarHeight(activity));
}

@Test
public void getBottomInset_defaultOptionsAreTakenIntoAccount() {
Options defaultOptions = new Options();
defaultOptions.bottomTabsOptions.visible = new Bool(false);

assertThat(uut.getBottomInset(child1)).isEqualTo(bottomTabs.getHeight());
uut.setDefaultOptions(defaultOptions);
assertThat(uut.getBottomInset(child1)).isZero();
}

@Test
public void destroy() {
uut.destroy();
Expand Down

0 comments on commit d0c21e4

Please sign in to comment.