Browse Source

Emit BottomTabSelected event also when tab is reselected

Guy Carmeli 6 years ago
parent
commit
53dcb3e850

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java View File

116
 
116
 
117
     @Override
117
     @Override
118
     public boolean onTabSelected(int index, boolean wasSelected) {
118
     public boolean onTabSelected(int index, boolean wasSelected) {
119
-        if (wasSelected) return false;
120
         eventEmitter.emitBottomTabSelected(bottomTabs.getCurrentItem(), index);
119
         eventEmitter.emitBottomTabSelected(bottomTabs.getCurrentItem(), index);
120
+        if (wasSelected) return false;
121
         selectTab(index);
121
         selectTab(index);
122
         return false;
122
         return false;
123
 	}
123
 	}

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java View File

140
         uut.ensureViewIsCreated();
140
         uut.ensureViewIsCreated();
141
         assertThat(uut.getSelectedIndex()).isZero();
141
         assertThat(uut.getSelectedIndex()).isZero();
142
 
142
 
143
-        uut.onTabSelected(0, false);
143
+        uut.onTabSelected(0, true);
144
 
144
 
145
         assertThat(uut.getSelectedIndex()).isEqualTo(0);
145
         assertThat(uut.getSelectedIndex()).isEqualTo(0);
146
         assertThat(((ViewController) ((List) uut.getChildControllers()).get(0)).getView().getParent()).isNotNull();
146
         assertThat(((ViewController) ((List) uut.getChildControllers()).get(0)).getView().getParent()).isNotNull();