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

Uniffi React Native Integration #401

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

bjtrounson
Copy link
Contributor

@bjtrounson bjtrounson commented Dec 23, 2024

Background

After testing an expo modules approach in this PR #394 . We have found that the work to maintain the record types between the Rust layer and expo modules would be too tendinous. So this PR has an initial implementation of using uniffi-bindgen-react-native to create a similar binding as Android and iOS. One downside of this is we have to implement the views all again just for react-native but this downside is worth it long term definitely since the FerrostarCore-RS is still changing it's model quite frequently.

Implementation overview

Implementation of the core integration is following the current Android implementation quite closely apart from segments where there our missing language features and such. We are using uniffi-bindgen-react-native to create the Rust binding the generated TypeScript types are located in src/generated.

Current status

Please let me know missing implementations that should be on the list and I will update it.

  • FerrostarCore
  • LocationProvider
  • RouteProvider
  • AlternativeRouteProcessor
  • RouteDeviationHandler
  • NavigationUiState
  • BorderedPolyline
  • NavigationView
  • NavigationMapViewCamera
  • TripProgressView
  • Navigating Puck (snap to route still needs to be sorted.)
  • InstructionView
  • MapControls
  • Speed Limit
  • Spoken TTS
  • Road Name
  • Annotation
  • Landscape
  • Documentation
  • NPM package page

@bjtrounson
Copy link
Contributor Author

bjtrounson commented Dec 23, 2024

/react-native/cpp/generated/ and /react-native/src/generated should be ignored from the CI checks other typos need to be fixed

Edit: I've added these.

@bjtrounson
Copy link
Contributor Author

bjtrounson commented Dec 23, 2024

Initial version of puck, route and trip progress view.

Screenrecorder-2024-12-24-07-28-28-106.mp4

I have discover one issue and it's that I don't think we can currently override the current location that MapLibre is using within maplibre-react-native. I'm wondering if @KiwiKilian might know of any available solution here or if it's something that's going to need to be exposed on that libraries side.

@KiwiKilian
Copy link

Just glanced at your recent commits, do I understand correctly:

  • Ferrostar retrieves the location from MapLibre Native and snaps to the route
  • You are rendering the UserLocation component from MapLibre React Native
  • You want the UserLocation component to use the snapped coordinates instead of the actual ones, correct?

Currently there is no clean way to do this.

I'm not sure if we you actually want to override the LocationManager. Users might want to use both locations for some reason? We could just extract a dumb UserLocationPuck component, which you can feed any coordinate?

@bjtrounson
Copy link
Contributor Author

bjtrounson commented Dec 23, 2024

You want the UserLocation component to use the snapped coordinates instead of the actual ones, correct?

Yes we only want to use the snapped location when we are navigating and if our snappedToRoute options is enable in the FerrostarCore, I think the android version does this using a StaticEngine and inserts that into MapLibre @ianthetechie might be able to explain that a bit better. But I don't think that will probably be the best approach here.

I'm not sure if we you actually want to override the LocationManager. Users might want to use both locations for some reason? We could just extract a dumb UserLocationPuck component, which you can feed any coordinate?

I really like this idea and I agree users might want a different functionality here, is this something that could be extracted here or have to be expose on the maplibre-react-native side?

@bjtrounson bjtrounson marked this pull request as draft December 26, 2024 03:58
@bjtrounson
Copy link
Contributor Author

MapControl need a bit of work, we need some fonts for the +, -, mute, route and recenter button (I've tried + & - as just normal character but it doesn't look good) will look at extracting some google fonts as I think that's what we are using on Android.

We will also need to sort out the camera state mostly for the route overview and recenter. I don't think we can just apply a the navigation camera again to reset like we do on Android. So will have to look at keeping a camera state some where probably a provider that will get updated via the onUserTrackingModeChange event. Then we can reset the camera state that is looking at the provider, not 100% sure this will reset the pitch and zoom though will need to test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants