Skip to content

Commit

Permalink
Bottom bar visibility Android Fix (#7389)
Browse files Browse the repository at this point in the history
* demo

* add test to check onViewWillAppear called

* show bottomNavigation when restore without animation

* add onViewWillAppear when tab selected to apply options

* Update app.ts

* Update Options.ts

* Update OptionsScreen.tsx
  • Loading branch information
swabbass authored Dec 6, 2021
1 parent 3aecf39 commit c52ccb8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ private void selectTab(int newIndex, boolean enableSelectionHistory) {
getCurrentView().setVisibility(View.INVISIBLE);
bottomTabs.setCurrentItem(newIndex, false);
getCurrentView().setVisibility(View.VISIBLE);
getCurrentChild().onViewWillAppear();
getCurrentChild().onViewDidAppear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public void setBackgroundColor(int color) {
if (getDefaultBackgroundColor() != color) setDefaultBackgroundColor(color);
}

@Override
public void restoreBottomNavigation(boolean withAnimation) {
super.restoreBottomNavigation(withAnimation);
if (!withAnimation) setVisibility(View.VISIBLE);
}

@Override
public void hideBottomNavigation(boolean withAnimation) {
super.hideBottomNavigation(withAnimation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,24 @@ class BottomTabsControllerTest : BaseTest() {
), ArgumentMatchers.any(Int::class.java)
)
}
@Test
fun `mergeOptions - select tab calls onViewWillAppear to apply options on the selected child`(){
uut.ensureViewIsCreated()
Java6Assertions.assertThat(uut.selectedIndex).isZero

val options = Options()
options.bottomTabsOptions.currentTabIndex = Number(1)
uut.mergeOptions(options)
Java6Assertions.assertThat(uut.selectedIndex).isOne
Mockito.verify(child2).onViewWillAppear()
Mockito.verify(child2).onViewDidAppear()

options.bottomTabsOptions.currentTabIndex = Number(0)
uut.mergeOptions(options)
Java6Assertions.assertThat(uut.selectedIndex).isZero
Mockito.verify(child1).onViewWillAppear()
Mockito.verify(child1).onViewDidAppear()
}
@Test
fun mergeOptions_drawBehind() {
Java6Assertions.assertThat(uut.getBottomInset(child1)).isEqualTo(uut.bottomTabs.height)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@
}
}
}
}
}
3 changes: 3 additions & 0 deletions playground/src/screens/LayoutsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export default class LayoutsScreen extends NavigationComponent<NavigationCompone

static options(): Options {
return {
bottomTabs: {
visible: true,
},
topBar: {
testID: WELCOME_SCREEN_HEADER,
title: {
Expand Down

0 comments on commit c52ccb8

Please sign in to comment.