-
Notifications
You must be signed in to change notification settings - Fork 27
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
base: main
Are you sure you want to change the base?
Conversation
…eing used even when we aren't navigating
There was a problem hiding this 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' |
There was a problem hiding this comment.
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.
def ferrostarVersion = '0.23.0' | ||
implementation "com.stadiamaps.ferrostar:core:${ferrostarVersion}" |
There was a problem hiding this comment.
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:+" |
There was a problem hiding this comment.
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.
include ':expo-modules-core' | ||
project(':expo-modules-core').projectDir = new File(rootProject.projectDir, '../../../node_modules/expo-modules-core/android') |
There was a problem hiding this comment.
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 -> |
There was a problem hiding this comment.
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.
mainScope.launch { | ||
viewModel.navigationUiState.collect { uiState -> | ||
onNavigationStateChange( | ||
mapOf( | ||
"isNavigating" to uiState.isNavigating(), | ||
"isCalculatingNewRoute" to if (uiState.isCalculatingNewRoute != null) uiState.isCalculatingNewRoute!! else false, | ||
) | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops ;)
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