Browse Source

Emit bottomTabSelected event

Guy Carmeli 6 years ago
parent
commit
e006406ceb

+ 24
- 20
lib/android/app/src/main/java/com/reactnativenavigation/react/EventEmitter.java View File

@@ -26,17 +26,17 @@ public class EventEmitter {
26 26
 	}
27 27
 
28 28
 	public void componentDidDisappear(String id, String componentName) {
29
-		WritableMap data = Arguments.createMap();
30
-		data.putString("componentId", id);
31
-		data.putString("componentName", componentName);
32
-		emit(componentDidDisappear, data);
29
+		WritableMap event = Arguments.createMap();
30
+		event.putString("componentId", id);
31
+		event.putString("componentName", componentName);
32
+		emit(componentDidDisappear, event);
33 33
 	}
34 34
 
35 35
 	public void componentDidAppear(String id, String componentName) {
36
-		WritableMap data = Arguments.createMap();
37
-		data.putString("componentId", id);
38
-		data.putString("componentName", componentName);
39
-		emit(componentDidAppear, data);
36
+		WritableMap event = Arguments.createMap();
37
+		event.putString("componentId", id);
38
+		event.putString("componentName", componentName);
39
+		emit(componentDidAppear, event);
40 40
 	}
41 41
 
42 42
     public void emitOnNavigationButtonPressed(String id, String buttonId) {
@@ -44,24 +44,28 @@ public class EventEmitter {
44 44
 		params.putString("componentId", id);
45 45
 		params.putString("buttonId", buttonId);
46 46
 
47
-        WritableMap data = Arguments.createMap();
48
-        data.putString("name", buttonPressedEvent);
49
-        data.putMap("params", params);
50
-		emit(nativeEvent, data);
47
+        WritableMap event = Arguments.createMap();
48
+        event.putString("name", buttonPressedEvent);
49
+        event.putMap("params", params);
50
+		emit(nativeEvent, event);
51 51
 	}
52 52
 
53 53
     public void emitBottomTabSelected(int unselectedTabIndex, int selectedTabIndex) {
54
-        WritableMap data = Arguments.createMap();
55
-        data.putInt("unselectedTabIndex", unselectedTabIndex);
56
-        data.putInt("selectedTabIndex", selectedTabIndex);
57
-        emit(nativeEvent, data);
54
+        WritableMap params = Arguments.createMap();
55
+        params.putInt("unselectedTabIndex", unselectedTabIndex);
56
+        params.putInt("selectedTabIndex", selectedTabIndex);
57
+
58
+        WritableMap event = Arguments.createMap();
59
+        event.putString("name", "bottomTabSelected");
60
+        event.putMap("params", params);
61
+        emitter.emit(nativeEvent, event);
58 62
     }
59 63
 
60 64
     public void emitCommandCompletedEvent(String commandId, long completionTime) {
61
-        WritableMap map = Arguments.createMap();
62
-        map.putString("commandId", commandId);
63
-        map.putDouble("completionTime", completionTime);
64
-        emit(commandCompleted, map);
65
+        WritableMap event = Arguments.createMap();
66
+        event.putString("commandId", commandId);
67
+        event.putDouble("completionTime", completionTime);
68
+        emitter.emit(commandCompleted, event);
65 69
     }
66 70
 
67 71
 	private void emit(String eventName) {