Skip to content

Commit 2980630

Browse files
authored
fix: events in bridgeless mode (#3656)
1 parent c05ecad commit 2980630

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXRasterSourceManager.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import com.facebook.react.bridge.ReactApplicationContext
55
import com.facebook.react.uimanager.ThemedReactContext
66
import com.facebook.react.uimanager.annotations.ReactProp
77
import com.facebook.react.viewmanagers.RNMBXRasterSourceManagerInterface
8+
import com.rnmapbox.rnmbx.events.constants.EventKeys
9+
import com.rnmapbox.rnmbx.events.constants.eventMapOf
810
import javax.annotation.Nonnull
911

1012
class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext) :
@@ -26,7 +28,10 @@ class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext)
2628
}
2729

2830
override fun customEvents(): Map<String, String>? {
29-
return null
31+
return eventMapOf(
32+
EventKeys.RASTER_SOURCE_LAYER_CLICK to "onMapboxRasterSourcePress",
33+
EventKeys.MAP_ANDROID_CALLBACK to "onAndroidCallback"
34+
)
3035
}
3136

3237
companion object {

android/src/main/java/com/rnmapbox/rnmbx/events/constants/EventKeys.kt

+18-16
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,37 @@ private fun ns(name: String): String {
44
val namespace = "rct.mapbox"
55
return String.format("%s.%s", namespace, name)
66
}
7+
78
enum class EventKeys(val value: String) {
89
// map events
9-
MAP_CLICK(ns("map.press")),
10-
MAP_LONG_CLICK(ns("map.longpress")),
11-
MAP_ONCHANGE(ns("map.change")),
12-
MAP_ON_LOCATION_CHANGE(ns("map.location.change")),
13-
MAP_ANDROID_CALLBACK(ns("map.androidcallback")),
14-
MAP_USER_TRACKING_MODE_CHANGE(ns("map.usertrackingmodechange")),
10+
MAP_CLICK("topPress"),
11+
MAP_LONG_CLICK("topLongPress"),
12+
MAP_ONCHANGE("topMapChange"),
13+
MAP_ON_LOCATION_CHANGE("topLocationChange"),
14+
MAP_ANDROID_CALLBACK("topAndroidCallback"),
15+
MAP_USER_TRACKING_MODE_CHANGE("topUserTrackingModeChange"),
1516

1617
// point annotation events
17-
POINT_ANNOTATION_SELECTED(ns("pointannotation.selected")),
18-
POINT_ANNOTATION_DESELECTED(ns("pointannotation.deselected")),
19-
POINT_ANNOTATION_DRAG_START(ns("pointannotation.dragstart")),
20-
POINT_ANNOTATION_DRAG(ns("pointannotation.drag")),
21-
POINT_ANNOTATION_DRAG_END(ns("pointannotation.dragend")),
18+
POINT_ANNOTATION_SELECTED("topMapboxPointAnnotationSelected"),
19+
POINT_ANNOTATION_DESELECTED("topMapboxPointAnnotationDeselected"),
20+
POINT_ANNOTATION_DRAG_START("topMapboxPointAnnotationDragStart"),
21+
POINT_ANNOTATION_DRAG("topMapboxPointAnnotationDrag"),
22+
POINT_ANNOTATION_DRAG_END("topMapboxPointAnnotationDragEnd"),
2223

2324
// source events
24-
SHAPE_SOURCE_LAYER_CLICK(ns("shapesource.layer.pressed")),
25-
VECTOR_SOURCE_LAYER_CLICK(ns("vectorsource.layer.pressed")),
26-
RASTER_SOURCE_LAYER_CLICK(ns("rastersource.layer.pressed")),
25+
SHAPE_SOURCE_LAYER_CLICK("topMapboxShapeSourcePress"),
26+
VECTOR_SOURCE_LAYER_CLICK("topMapboxVectorSourcePress"),
27+
RASTER_SOURCE_LAYER_CLICK("topMapboxRasterSourcePress"),
2728

2829
// images event
29-
IMAGES_MISSING(ns("images.missing")),
30+
IMAGES_MISSING("topImageMissing"),
3031

3132
// location events
33+
// TODO: not sure about this one since it is not registered anywhere
3234
USER_LOCATION_UPDATE(ns("user.location.update")),
3335

3436
// viewport events
35-
VIEWPORT_STATUS_CHANGE(ns("viewport.statuschange"))
37+
VIEWPORT_STATUS_CHANGE("topStatusChanged")
3638
}
3739

3840
fun eventMapOf(vararg values: Pair<EventKeys, String>): Map<String, String> {

example/android/app/src/main/java/com/rnmapboxglexample/MainApplication.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MainApplication : Application(), ReactApplication {
2929
SoLoader.init(this, false)
3030
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
3131
// If you opted-in for the New Architecture, we load the native entry point for this app.
32-
load(bridgelessEnabled=false)
32+
load()
3333
}
3434
}
3535
}

0 commit comments

Comments
 (0)