Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: events in bridgeless mode #3656

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.annotations.ReactProp
import com.facebook.react.viewmanagers.RNMBXRasterSourceManagerInterface
import com.rnmapbox.rnmbx.events.constants.EventKeys
import com.rnmapbox.rnmbx.events.constants.eventMapOf
import javax.annotation.Nonnull

class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext) :
Expand All @@ -26,7 +28,10 @@ class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext)
}

override fun customEvents(): Map<String, String>? {
return null
return eventMapOf(
EventKeys.RASTER_SOURCE_LAYER_CLICK to "onMapboxRasterSourcePress",
EventKeys.MAP_ANDROID_CALLBACK to "onAndroidCallback"
)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,37 @@ private fun ns(name: String): String {
val namespace = "rct.mapbox"
return String.format("%s.%s", namespace, name)
}

enum class EventKeys(val value: String) {
// map events
MAP_CLICK(ns("map.press")),
MAP_LONG_CLICK(ns("map.longpress")),
MAP_ONCHANGE(ns("map.change")),
MAP_ON_LOCATION_CHANGE(ns("map.location.change")),
MAP_ANDROID_CALLBACK(ns("map.androidcallback")),
MAP_USER_TRACKING_MODE_CHANGE(ns("map.usertrackingmodechange")),
MAP_CLICK("topPress"),
MAP_LONG_CLICK("topLongPress"),
MAP_ONCHANGE("topMapChange"),
MAP_ON_LOCATION_CHANGE("topLocationChange"),
MAP_ANDROID_CALLBACK("topAndroidCallback"),
MAP_USER_TRACKING_MODE_CHANGE("topUserTrackingModeChange"),

// point annotation events
POINT_ANNOTATION_SELECTED(ns("pointannotation.selected")),
POINT_ANNOTATION_DESELECTED(ns("pointannotation.deselected")),
POINT_ANNOTATION_DRAG_START(ns("pointannotation.dragstart")),
POINT_ANNOTATION_DRAG(ns("pointannotation.drag")),
POINT_ANNOTATION_DRAG_END(ns("pointannotation.dragend")),
POINT_ANNOTATION_SELECTED("topMapboxPointAnnotationSelected"),
POINT_ANNOTATION_DESELECTED("topMapboxPointAnnotationDeselected"),
POINT_ANNOTATION_DRAG_START("topMapboxPointAnnotationDragStart"),
POINT_ANNOTATION_DRAG("topMapboxPointAnnotationDrag"),
POINT_ANNOTATION_DRAG_END("topMapboxPointAnnotationDragEnd"),

// source events
SHAPE_SOURCE_LAYER_CLICK(ns("shapesource.layer.pressed")),
VECTOR_SOURCE_LAYER_CLICK(ns("vectorsource.layer.pressed")),
RASTER_SOURCE_LAYER_CLICK(ns("rastersource.layer.pressed")),
SHAPE_SOURCE_LAYER_CLICK("topMapboxShapeSourcePress"),
VECTOR_SOURCE_LAYER_CLICK("topMapboxVectorSourcePress"),
RASTER_SOURCE_LAYER_CLICK("topMapboxRasterSourcePress"),

// images event
IMAGES_MISSING(ns("images.missing")),
IMAGES_MISSING("topImageMissing"),

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

// viewport events
VIEWPORT_STATUS_CHANGE(ns("viewport.statuschange"))
VIEWPORT_STATUS_CHANGE("topStatusChanged")
}

fun eventMapOf(vararg values: Pair<EventKeys, String>): Map<String, String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MainApplication : Application(), ReactApplication {
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load(bridgelessEnabled=false)
load()
}
}
}
Loading