Selaa lähdekoodia

Send bottomTabSelected event (#600)

The event is sent to the top most screen displayed in the current screenStack.
Guy Carmeli 7 vuotta sitten
vanhempi
commit
e1d67727a4

+ 9
- 0
android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java Näytä tiedosto

@@ -7,7 +7,9 @@ import android.view.View;
7 7
 import android.widget.RelativeLayout;
8 8
 
9 9
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
10
+import com.facebook.react.bridge.Arguments;
10 11
 import com.facebook.react.bridge.Callback;
12
+import com.facebook.react.bridge.WritableMap;
11 13
 import com.reactnativenavigation.NavigationApplication;
12 14
 import com.reactnativenavigation.events.EventBus;
13 15
 import com.reactnativenavigation.events.ScreenChangedEvent;
@@ -298,9 +300,16 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
298 300
         hideCurrentStack();
299 301
         showNewStack(position);
300 302
         EventBus.instance.post(new ScreenChangedEvent(getCurrentScreenStack().peek().getScreenParams()));
303
+        sendTabSelectedEventToJs();
301 304
         return true;
302 305
     }
303 306
 
307
+    private void sendTabSelectedEventToJs() {
308
+        WritableMap data = Arguments.createMap();
309
+        String navigatorEventId = getCurrentScreenStack().peek().getNavigatorEventId();
310
+        NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("bottomTabSelected", navigatorEventId, data);
311
+    }
312
+
304 313
     private void showNewStack(int position) {
305 314
         showStackAndUpdateStyle(screenStacks[position]);
306 315
         currentStackIndex = position;