Skip to content

Commit

Permalink
Uniffi React Native Integration (#401)
Browse files Browse the repository at this point in the history
* Initial uniffi setup

* Initial FerrostarCore and Route Provider implementation

* FerrostarCore mostly done but without the location provider and spoken instructions

* Location Provider Implementation

* intergration of LocationProvider into FerrostarCore

* Event listener for navigation state so we can since the external FerrostarCore state to the view

* Early NavigationView

* Working FerrostarCore

* Initial views and UI

* Working puck and trip progress view with formatters

* typo fixes

* forgot one word in typo check

* added icons

* changed TripProgressView styling

* Added InstructionView

* fix navigation camera to have pitch and zoom

* fix icons names

* change some styling in the instruction view

* fix the estimatedArrival time

* Add initial map control till needs onPress handlers

* chore: update and install new deps

* feat: add example app with dotenv

* chore: add location permissions to example app

* fix: handling location edge cases

* feat: add map control events and state

* chore: remove deprecated setAccessToken from default export

* feat: add more icons and improve icons on other elements

* Trying to fix camera issues when route focus

* Update react-native/android/build.gradle

Co-authored-by: Ian Wagner <[email protected]>

* chore: delete auto-generated code

* chore: add auto-generated code to .gitignore

* chore: update package.json for new license and ts for new imports

* Update react-native/src/core/FerrostarCore.ts

Co-authored-by: Ian Wagner <[email protected]>

* changed fastestInterval to 1000 as suggested

* Update react-native/example/ios/FerrostarExample/Info.plist

Co-authored-by: Ian Wagner <[email protected]>

* Add JSDoc link to comments since syntax is different to Android

* Changed the AndroidManifest that build.gradle is pointing at

* Revert back the AndroidManifestNew.xml since it's used for better compatibility

* Update the example README.md with some helpful information

* Add to the .gitignore

* added package name to auto-generation and build.gradle

* remove CMakeList.txt and AndroidManifest.xml since they are auto-generated

* correct AndroidManifest.xml ignore

* Add TripState extensions as utils functions and apply them to the NavigationUiState correctly

---------

Co-authored-by: Ian Wagner <[email protected]>
  • Loading branch information
bjtrounson and ianthetechie authored Jan 28, 2025
1 parent 911067d commit be820af
Show file tree
Hide file tree
Showing 97 changed files with 21,033 additions and 4 deletions.
14 changes: 10 additions & 4 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
[default]
extend-ignore-re = [
"VALHALLA_EXTENDED_OSRM_RESPONSE.*",
]
extend-ignore-re = ["VALHALLA_EXTENDED_OSRM_RESPONSE.*"]

[default.extend-words]
rememberable = "rememberable"

[files]
extend-exclude = ["**/build/*", "*.pbxproj", "**/dist/*", "guide/**/*.js", "**/fixtures/*"]
extend-exclude = [
"**/build/*",
"*.pbxproj",
"**/dist/*",
"guide/**/*.js",
"**/fixtures/*",
"react-native/cpp/generated/*",
"react-native/src/generated/*",
]
15 changes: 15 additions & 0 deletions react-native/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]

indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
3 changes: 3 additions & 0 deletions react-native/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pbxproj -text
# specific for windows script files
*.bat text eol=crlf
27 changes: 27 additions & 0 deletions react-native/.github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Setup
description: Setup Node.js and install dependencies

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Cache dependencies
id: yarn-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
shell: bash
157 changes: 157 additions & 0 deletions react-native/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
types:
- checks_requested

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Lint files
run: yarn lint

- name: Typecheck files
run: yarn typecheck

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage

build-library:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Build package
run: yarn prepare

build-android:
runs-on: ubuntu-latest
env:
TURBO_CACHE_DIR: .turbo/android
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Cache turborepo for Android
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-android-
- name: Check turborepo cache for Android
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi
- name: Install JDK
if: env.turbo_cache_hit != 1
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Finalize Android SDK
if: env.turbo_cache_hit != 1
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
- name: Cache Gradle
if: env.turbo_cache_hit != 1
uses: actions/cache@v3
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build example for Android
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
run: |
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
build-ios:
runs-on: macos-14
env:
TURBO_CACHE_DIR: .turbo/ios
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Cache turborepo for iOS
uses: actions/cache@v3
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-ios-
- name: Check turborepo cache for iOS
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
fi
- name: Cache cocoapods
if: env.turbo_cache_hit != 1
id: cocoapods-cache
uses: actions/cache@v3
with:
path: |
**/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-
- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd example/ios
pod install
env:
NO_FLIPPER: 1

- name: Build example for iOS
run: |
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
96 changes: 96 additions & 0 deletions react-native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# OSX
#
.DS_Store

# XDE
.expo/

# VSCode
.vscode/
jsconfig.json

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
#
.classpath
.cxx
.gradle
.idea
.project
.settings
local.properties
android.iml

# Cocoapods
#
example/ios/Pods

# Ruby
example/vendor/

# node.js
#
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Expo
.expo/

# Turborepo
.turbo/

# generated by bob
lib/

# React Native Codegen
ios/generated
android/generated

# Uniffi bindings
rust_modules/
*.a
cpp/
android/src/main/java/
android/cpp-adapter.cpp
android/CMakeLists.txt
android/src/main/AndroidManifest.xml
ios/
src/Native*
src/generated/
src/index.ts*

1 change: 1 addition & 0 deletions react-native/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
1 change: 1 addition & 0 deletions react-native/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
541 changes: 541 additions & 0 deletions react-native/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions react-native/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

874 changes: 874 additions & 0 deletions react-native/.yarn/releases/yarn-3.6.1.cjs

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions react-native/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
nodeLinker: node-modules
nmHoistingLimits: workspaces

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.1.cjs
Loading

0 comments on commit be820af

Please sign in to comment.