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

Ferrostar support for Expo Modules & React Native (Android only for now) #394

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bjtrounson
Copy link
Contributor

Introduces a new directory /expo to the repo which contains a expo module wrapper for Ferrostar.

The directory is under expo as this module requires the expo package to be installed in your react native project. I also was thinking down the line @ianthetechie might want to look at creating Turbo Module with uniffi bindings for Ferrostar which could live in a react-native directory.

Expo modules can be integrated into existing bare react native projects by following this guide here: https://docs.expo.dev/bare/installing-expo-modules/#automatic-installation

The only major issue I have found in this module, is when switching between pages and back to the map. The map will disappear and not reload until the app is relaunched.

iOS is currently also not supported but I don't think it will be a huge task to do. We only need to sort out how to configure the SPM packages in CocoaPods. Then we can scaffold out a very similar implementation to Android.

Somethings that should probably will need to be done before fully releasing this

  • npm package (this is if we intend to release this as an npm package for others to use.)
  • Automated releases
  • Fallback when launched on an iOS device (currently I think the app will just crash, I haven't tried it yet.)
  • Documentation (looking at doing this on 16th & 17th of December.)

Copy link
Contributor

@ianthetechie ianthetechie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall solid start. As discussed on the call, the big thing we want to figure out is how to autogenerate all of the core bindings, since these will go out of sync pretty quickly (not to mention it's a lot of typing!).

// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
// Most of the time, you may like to manage the Android SDK versions yourself.
buildscript {
ext.kotlin_version = '1.9.24'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBD whether this is actually required.

Comment on lines +75 to +76
def ferrostarVersion = '0.23.0'
implementation "com.stadiamaps.ferrostar:core:${ferrostarVersion}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to figure out how to either ensure this is synced with the other projects (update-release-version.sh) or remove the need for hard-coding a version...

Can we reference the main Android gradle workspace? Can we reference its libs.toml?

debugImplementation "androidx.compose.ui:ui-tooling"

// React Native
implementation "com.facebook.react:react-native:+"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can delete this per the review call.

Comment on lines +1 to +2
include ':expo-modules-core'
project(':expo-modules-core').projectDir = new File(rootProject.projectDir, '../../../node_modules/expo-modules-core/android')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be removeable per the review call

"onNavigationStateChange"
)

AsyncFunction("createRouteFromOsrm") { view: ExpoFerrostarView, osrmRoute: String, waypoints: String ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting expo quirk: we have to export basically everything as async.

Comment on lines +218 to +227
mainScope.launch {
viewModel.navigationUiState.collect { uiState ->
onNavigationStateChange(
mapOf(
"isNavigating" to uiState.isNavigating(),
"isCalculatingNewRoute" to if (uiState.isCalculatingNewRoute != null) uiState.isCalculatingNewRoute!! else false,
)
)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some cleanup/optimization needed...

locationProvider.removeListener(this)
}

val previewRoute: MutableStateFlow<Route?> = MutableStateFlow(null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice addition that makes quickly trying things out easier. Might consider porting this to others.

@@ -0,0 +1,101 @@
package expo.modules.ferrostar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably be deleted?

@@ -0,0 +1,17 @@
package expo.modules.ferrostar.records
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's figure out how to generate these automatically.

<Ferrostar
style={{ flex: 1 }}
locationMode="default"
styleUrl="https://api.maptiler.com/maps/basic-v2/style.json?key=DQTRKy0N0WUe90KUjN4i"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops ;)

@bjtrounson bjtrounson mentioned this pull request Dec 23, 2024
20 tasks
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