Skip to content

Commit 057bb28

Browse files
authored
feat!: support latest navigation sdk library (#21)
* feat: change package names to use googlemaps scope * chore: update directory structures * chore: add docker backend for example apps
1 parent dac1164 commit 057bb28

File tree

212 files changed

+17043
-33465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+17043
-33465
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pbxproj -text
2+
# specific for windows script files
3+
*.bat text eol=crlf

.gitignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# XDE
6+
.expo/
7+
8+
# VSCode
9+
.vscode/
10+
jsconfig.json
11+
12+
# Xcode
13+
#
14+
build/
15+
*.pbxuser
16+
!default.pbxuser
17+
*.mode1v3
18+
!default.mode1v3
19+
*.mode2v3
20+
!default.mode2v3
21+
*.perspectivev3
22+
!default.perspectivev3
23+
xcuserdata
24+
*.xccheckout
25+
*.moved-aside
26+
DerivedData
27+
*.hmap
28+
*.ipa
29+
*.xcuserstate
30+
project.xcworkspace
31+
.xcode.env.local
32+
33+
# Android/IJ
34+
#
35+
.classpath
36+
.cxx
37+
.gradle
38+
.idea
39+
.project
40+
.settings
41+
local.properties
42+
android.iml
43+
44+
# Cocoapods
45+
#
46+
example/**/ios/Pods
47+
example/**/ios/Podfile.lock
48+
49+
# node.js
50+
#
51+
node_modules/
52+
npm-debug.log
53+
yarn-debug.log
54+
yarn-error.log
55+
package-lock.json
56+
57+
# BUCK
58+
buck-out/
59+
\.buckd/
60+
android/app/libs
61+
android/keystores/debug.keystore
62+
63+
# Yarn
64+
.yarn/*
65+
!.yarn/patches
66+
!.yarn/plugins
67+
!.yarn/releases
68+
!.yarn/sdks
69+
!.yarn/versions
70+
71+
# Expo
72+
.expo/
73+
74+
# Turborepo
75+
.turbo/
76+
77+
# generated by bob
78+
lib/
79+
80+
# tests
81+
coverage/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
example
2+
coverage
3+
node_modules

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 541 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-3.6.1.cjs

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
#! bin/bash
21
# Copyright 2024 Google LLC
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");
54
# you may not use this file except in compliance with the License.
65
# You may obtain a copy of the License at
76
#
8-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# https://www.apache.org/licenses/LICENSE-2.0
98
#
109
# Unless required by applicable law or agreed to in writing, software
1110
# distributed under the License is distributed on an "AS IS" BASIS,
1211
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1312
# See the License for the specific language governing permissions and
1413
# limitations under the License.
1514

16-
grep -r '@ts-expect-error' -h ../components | # Find all lines containing "@ts-expect-error"
17-
sed -E 's/^.*\/[*/] | \*\/|,//g' | # Remove whitespace and brackets
18-
wc -l # Count number of lines
15+
nodeLinker: node-modules
16+
nmHoistingLimits: workspaces
17+
18+
plugins:
19+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
20+
spec: "@yarnpkg/plugin-interactive-tools"
21+
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
22+
spec: "@yarnpkg/plugin-workspace-tools"
23+
24+
yarnPath: .yarn/releases/yarn-3.6.1.cjs

CONTRIBUTING.md

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This project follows
2828
- Linux, Mac OS X, or Windows.
2929
- [git](https://git-scm.com) (used for source version control).
3030
- An IDE such as [Android Studio](https://developer.android.com/studio) or [Visual Studio Code](https://code.visualstudio.com/).
31+
- [addlicense](https://github.com/google/addlicense)
3132

3233
## 2. Forking & cloning the repository
3334

@@ -72,27 +73,6 @@ To update the Javascript codes, edit the library files inside node_modules
7273

7374
Simply run the sample app to test your changes.
7475

75-
## Submitting changes
76-
77-
Copy your changes from the node_modules folder and paste it over to the root directory. Don't copy the entire contents of the node_modules, instead just copy the changes you made. This process can also be optimized with shell commands.
78-
79-
### Android
80-
81-
![rnProjectAndroid](/images/submit_android.png)
82-
83-
84-
### iOS
85-
86-
Just copy the .m and .h files. There's no need to copy the .xcodeproj file unless new files are added to the library.
87-
88-
![rnProjectXcode](/images/submit_ios.png)
89-
90-
91-
### Javacript
92-
93-
![rnProjectJS](/images/submit_javascript.png)
94-
95-
9676
### Code reviews
9777

9878
All submissions, including submissions by project members, require review. We
@@ -113,14 +93,16 @@ keep the code consistent and avoid common pitfalls.
11393

11494
#### Commit changes
11595

116-
1. `git commit -a -m "<your informative commit message>"`
96+
1. This project uses `lefthook` to ensure tests pass before committing. Please configure your environment paths to include the Go binary path for `addlicense` and the Node binary path for `npx` in the `~/.lefthookrc` file. For more information, refer to the [lefthook documentation](https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md#rc).
97+
98+
2. `git commit -a -m "<your informative commit message>"`
11799

118-
Please make sure all your check-ins have detailed commit messages explaining the patch.
119-
When naming the title of your pull request, please follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) guide. For example, for a fix to the Driver library:
100+
Please make sure all your check-ins have detailed commit messages explaining the patch.
101+
When naming the title of your pull request, please follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) guide. For example, for a fix to the Driver library:
120102

121-
`fix(navigation_view): fixed a bug!`
103+
`fix: fixed a bug!`
122104

123-
2. `git push origin <name_of_your_branch>`
105+
3. `git push origin <name_of_your_branch>`
124106

125107
#### Create pull request
126108

README.md

Lines changed: 70 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,23 @@ This is the beta release of the Google Driver SDK package for React Native. It i
2424

2525
1. To install the library run the following command from your project root:
2626

27-
`npm install --save https://github.com/googlemaps/react-native-driver-sdk#{version_tag}`
27+
```bash
28+
npm install --save https://github.com/googlemaps/react-native-driver-sdk#{version_tag}
29+
```
30+
or
31+
```bash
32+
yarn add https://github.com/googlemaps/react-native-driver-sdk#{version_tag}
33+
```
34+
35+
1. Install the `@googlemaps/react-native-navigation-sdk` dependency:
36+
37+
```bash
38+
npm install --save @googlemaps/react-native-navigation-sdk
39+
```
40+
or
41+
```bash
42+
yarn add @googlemaps/react-native-navigation-sdk
43+
```
2844

2945
### Android
3046

@@ -49,33 +65,40 @@ android {
4965
### Ridesharing
5066
#### Initializing the API
5167

52-
1. As mentioned above, this library depends on the React Native: NavigationSDK library. Specifically, it depends on the existence of a `NavigationView` component in the application. Please refer to the Navigation SDK [Sample app](https://github.com/googlemaps/react-native-navigation-sdk/tree/main/SampleApp) for all details on how to set up the navigation component.
68+
1. As mentioned above, this library depends on the React Native: NavigationSDK library. Specifically, it depends on the existence of a `NavigationView` component in the application.
5369

5470
1. In your react-native component, import and instantiate the RidesharingDriverapi and reference it through variable.
5571

56-
```typescript
57-
import RidesharingDriverapi from "react-native-driver-sdk/components/ridesharing/RidesharingDriverApi";
58-
59-
const ridesharing = new RidesharingDriverapi();
60-
```
61-
62-
1. Second step is to initialize the Api. Make sure to capture the viewId associated to the `NavigationView` component prior to this as it's needed.
63-
64-
```typescript
65-
await ridesharingDriverApi
66-
.initialize(
67-
PROVIDER_ID,
68-
VEHICLE_ID,
69-
navigationViewId,
70-
(tokenContext) => {
71-
// Check if the token is expired, in such case request a new one.
72-
return Promise.resolve(authToken || "");
73-
},
74-
(statusLevel, statusCode, message) => {
75-
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
76-
}
77-
);
78-
```
72+
```typescript
73+
import RidesharingDriverApi from "@googlemaps/react-native-driver-sdk";
74+
75+
const ridesharing = new RidesharingDriverapi();
76+
```
77+
78+
2. Start navigation. Please refer to the Navigation SDK [Sample app](https://github.com/googlemaps/react-native-navigation-sdk/tree/main/example) for all details on how to set up the navigation component and its listeners.
79+
80+
```typescript
81+
const { navigationController } = useNavigation();
82+
...
83+
await navigationController.init();
84+
```
85+
86+
3. Second step is to initialize the Api. Navigation must be initialized before the Driver SDK is initialized.
87+
88+
```typescript
89+
await ridesharingDriverApi
90+
.initialize(
91+
PROVIDER_ID,
92+
VEHICLE_ID,
93+
(tokenContext) => {
94+
// Check if the token is expired, in such case request a new one.
95+
return Promise.resolve(authToken || "");
96+
},
97+
(statusLevel, statusCode, message) => {
98+
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
99+
}
100+
);
101+
```
79102
80103
Note: The `initialize` method takes a `onGetTokenCallback` field as parameter. This will be called periodically to ensure the token stays refresh while there's requests to Fleet Engine. Please make sure to check that the token is valid (e.g. checking expiration time) before setting it.
81104
@@ -97,29 +120,28 @@ The vehicle reporter allows developers to enable/disable location reporting to F
97120
98121
1. In your react-native component, import and instantiate the RidesharingDriverapi and reference it through variable.
99122
100-
```typescript
101-
import DeliveryDriverapi from "react-native-driver-sdk/components/delivery/DeliveryDriverapi";
102-
103-
const deliveryApi = new DeliveryDriverapi();
104-
```
105-
106-
1. Second step is to initialize the Api. Make sure to capture the viewId associated to the `NavigationView` component prior to this as it's needed.
107-
108-
```typescript
109-
await deliveryApi
110-
.initialize(
111-
PROVIDER_ID,
112-
DELIVERY_VEHICLE_ID,
113-
navigationViewId,
114-
(tokenContext) => {
115-
// Check if the token is expired, in such case request a new one.
116-
return Promise.resolve(authToken || "");
117-
},
118-
(statusLevel, statusCode, message) => {
119-
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
120-
}
121-
);
122-
```
123+
```typescript
124+
import DeliveryDriverApi from "@googlemaps/react-native-driver-sdk";
125+
126+
const deliveryApi = new DeliveryDriverapi();
127+
```
128+
129+
2. Second step is to initialize the Api.
130+
131+
```typescript
132+
await deliveryApi
133+
.initialize(
134+
PROVIDER_ID,
135+
DELIVERY_VEHICLE_ID,
136+
(tokenContext) => {
137+
// Check if the token is expired, in such case request a new one.
138+
return Promise.resolve(authToken || "");
139+
},
140+
(statusLevel, statusCode, message) => {
141+
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
142+
}
143+
);
144+
```
123145
124146
Note: The `initialize` method takes a `onGetTokenCallback` field as parameter. This will be called periodically to ensure the token stays refresh while there's requests to Fleet Engine. Please make sure to check that the token is valid (e.g. checking expiration time) before setting it.
125147

0 commit comments

Comments
 (0)