From f15a332bbd1fe5808a6c48327f7af62744c07559 Mon Sep 17 00:00:00 2001 From: Youssef Henna Date: Mon, 11 Nov 2024 17:14:35 +0100 Subject: [PATCH] Add `onRoutesLoaded` callback to android --- .../expo/modules/mapboxnavigation/ExpoMapboxNavigationModule.kt | 2 +- .../expo/modules/mapboxnavigation/ExpoMapboxNavigationView.kt | 2 ++ src/ExpoMapboxNavigation.types.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationModule.kt b/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationModule.kt index c1b0007..997d928 100644 --- a/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationModule.kt +++ b/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationModule.kt @@ -40,7 +40,7 @@ class ExpoMapboxNavigationModule : Module() { } View(ExpoMapboxNavigationView::class) { - Events("onRouteProgressChanged", "onCancelNavigation", "onWaypointArrival", "onFinalDestinationArrival", "onRouteChanged", "onUserOffRoute") + Events("onRouteProgressChanged", "onCancelNavigation", "onWaypointArrival", "onFinalDestinationArrival", "onRouteChanged", "onUserOffRoute", "onRoutesLoaded") Prop("coordinates") { view: ExpoMapboxNavigationView, coordinates: List> -> val points = mutableListOf() diff --git a/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationView.kt b/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationView.kt index 8c4af88..233ecd8 100644 --- a/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationView.kt +++ b/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationView.kt @@ -111,6 +111,7 @@ class ExpoMapboxNavigationView(context: Context, appContext: AppContext) : ExpoV private val onFinalDestinationArrival by EventDispatcher() private val onRouteChanged by EventDispatcher() private val onUserOffRoute by EventDispatcher() + private val onRoutesLoaded by EventDispatcher() private val mapboxNavigation = MapboxNavigationApp.current() private var mapboxStyle: Style? = null @@ -590,6 +591,7 @@ class ExpoMapboxNavigationView(context: Context, appContext: AppContext) : ExpoV } private fun onRoutesReady(routes: List){ + onRoutesLoaded(mapOf()) mapboxNavigation?.setNavigationRoutes(routes) mapboxNavigation?.startTripSession(withForegroundService=false) navigationCamera.requestNavigationCameraToFollowing( diff --git a/src/ExpoMapboxNavigation.types.ts b/src/ExpoMapboxNavigation.types.ts index 896c576..1776a05 100644 --- a/src/ExpoMapboxNavigation.types.ts +++ b/src/ExpoMapboxNavigation.types.ts @@ -23,5 +23,6 @@ export type ExpoMapboxNavigationViewProps = { onFinalDestinationArrival?: () => void; onRouteChanged?: () => void; onUserOffRoute?: () => void; + onRoutesLoaded?: () => void; style?: StyleProp; };