Skip to content

[refactor] Make react native usable#883

Draft
bjtrounson wants to merge 22 commits into
stadiamaps:mainfrom
bjtrounson:refactor/bun-and-package-upgrade
Draft

[refactor] Make react native usable#883
bjtrounson wants to merge 22 commits into
stadiamaps:mainfrom
bjtrounson:refactor/bun-and-package-upgrade

Conversation

@bjtrounson
Copy link
Copy Markdown
Collaborator

@bjtrounson bjtrounson commented Apr 28, 2026

This is a complete upgrade of the existing react native ferrostar build. Things this PR does is improve the state management and DX of all the components across the UI. This also adds quite a few of the missing features that are lacking compared to the android and ios versions.

Note this project now uses bun, and it requires the latest bun to install the packages. Bun 1.3.13 is required to install since there is a bug in older versions that cause the install process to stall with peer-dependencies.

This PR fixes the following issue tickets.

Currently there are a few things that aren't adding in yet. These aren't blockers for me at least as I don't use these in our production app.

  • Annotation implementation
  • Foreground service. (Not sure of a framework agnostic way to implement this one.)

I also recommend using a linux based or macos machine when building the source of this. You will probably have linking issues when compiling the uniffi-bindgen on windows, I'm not sure how to fix it. I have confirmed you can install this once it's packaged on windows.

bjtrounson and others added 21 commits March 29, 2026 10:40
Introduces new type definitions for RouteProvider to accommodate both
well-known and custom providers.
Adds a `withJsonOptions` helper function to easily configure well-known
providers with additional JSON options.
This change aligns the RouteProvider structure with conventions used in
other platforms and bindings.
This commit introduces a "recenter" button to the `MapControls`
component, allowing users to recenter the map. It also adds a
`cameraMode` prop to `MapControls` and `NavigationMapViewCamera` to
manage different camera behaviors: 'following', 'overview', and
'detached'.

The `NavigationView` component now uses this `cameraMode` to
conditionally render the recenter button and control the behavior of the
map camera. The `handleRoutePress` function has been updated to switch
to 'overview' mode when showing the route bounds and to 'following' mode
when already in 'overview'. The `handleCameraChanged` callback is added
to detect when the user manually interacts with the map and switches the
`cameraMode` to 'detached'.

Additionally, this commit refactors the `useMemo` hooks in
`NavigationView` and `Index.tsx` to use plain objects for configuration,
improving readability and potentially performance. The `console.log`
statement for route debugging in `Index.tsx` has been removed.
the components more composable and less reliant on prop drilling
fix: auto-complete-search filtering
fix: dynamic layout for landscape
This commit introduces several refactors to improve the robustness and
flexibility of the `LocationProvider` and `FerrostarCore` components.

Key changes include:

- **`LocationProvider` Interface:**
    - Renamed `LocationProviderInterface` to `LocationProvider`.
    - Renamed `LocationUpdateListener` to `LocationObserver`.
    - Added `onLocationError` to `LocationObserver` for better error
      handling.
    - Introduced `LocationSnapshot` to represent the current location
      and heading.
    - Introduced `LocationSubscription` for managing listener
      subscriptions.
    - Modified `ManualLocationProvider` to adhere to the new
      `LocationProvider` interface, using `observers` instead of
      `listeners`.
    - Added `getSnapshot()` to `ManualLocationProvider`.

- **`FerrostarCore` Enhancements:**
    - Updated `FerrostarCore` to work with the new `LocationProvider`
      interface.
    - Implemented `connectLocationProvider` to correctly subscribe and
      unsubscribe from location providers.
    - Improved state management and listener notification logic.
    - Added tests for `ManualLocationProvider` and
      `SimulatedLocationProvider` to ensure correct observer management.
    - Enhanced `FerrostarCore` tests to cover various scenarios,
      including provider changes, subscription cleanup, and state
      updates.
    - Added `_lastHeading` to `NavigationUiState` and updated
      `useNavigationState` to include heading information.

- **Testing and Configuration:**
    - Migrated testing from Jest to Vitest for improved performance and
      features.
    - Added `vitest.config.ts` for Vitest configuration.
    - Updated `package.json` to reflect the change to Vitest.
    - Adjusted `tsconfig.base.json` for better type checking across the
      monorepo.
    - Introduced aliases for `react` and `react-test-renderer` in Vitest
      config to ensure proper resolution within the monorepo.

- **Documentation:**
    - Updated type definitions and comments to reflect the changes.

These changes aim to provide a more robust and maintainable location
tracking system within Ferrostar, along with improved testing
infrastructure.
@bjtrounson bjtrounson marked this pull request as draft April 28, 2026 01:08
@bjtrounson bjtrounson self-assigned this Apr 28, 2026
@bjtrounson bjtrounson changed the title [React Native] usable version [refactor] Make react native usable Apr 28, 2026
@bjtrounson
Copy link
Copy Markdown
Collaborator Author

I have mention the issues with the binding generation upstream to the uniffi-bindgen-react-native repo. Encase they would like to fix them on that end. Currently I have just fixed them to work for the react native side but I don't know if the changes will effect the android or ios side yet.

Here are the two issues if anyone is interested.
jhugman/uniffi-bindgen-react-native#388
jhugman/uniffi-bindgen-react-native#387

@bjtrounson
Copy link
Copy Markdown
Collaborator Author

Here is the PR for the delete related reserved word issue, we found out it was actually the C++ template generator that was the source of the issue. There was no reserved word checking on the C++ side at all.

This PR once merged should fix that issue: jhugman/uniffi-bindgen-react-native#389

@bjtrounson
Copy link
Copy Markdown
Collaborator Author

I've dug some more into jhugman/uniffi-bindgen-react-native#388 and have found out this has been fix in a recent PR that hasn't been included in a release yet. So it looks like we should be all good to go with the initial release of this very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant