@jadamsbit/react-native-mapbox-navigation 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/actions/setup/action.yml +27 -0
  3. package/.github/workflows/ci.yml +154 -0
  4. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
  5. package/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs +28 -0
  6. package/.yarn/releases/yarn-3.6.1.cjs +874 -0
  7. package/CONTRIBUTING.md +117 -6
  8. package/LICENSE +1 -2
  9. package/README.md +4 -4
  10. package/android/build.gradle +7 -3
  11. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  12. package/android/gradle/wrapper/gradle-wrapper.properties +2 -2
  13. package/android/gradle.properties +5 -3
  14. package/android/gradlew +17 -12
  15. package/android/gradlew.bat +10 -10
  16. package/android/src/main/AndroidManifest.xml +0 -1
  17. package/android/src/main/AndroidManifestNew.xml +2 -0
  18. package/android/src/main/java/com/jadamsbit/mapboxnavigation/{MapboxNavigationManager.kt → MapboxNavigationModule.kt} +30 -27
  19. package/android/src/main/java/com/jadamsbit/mapboxnavigation/MapboxNavigationPackage.kt +3 -2
  20. package/android/src/main/java/com/jadamsbit/mapboxnavigation/MapboxNavigationView.kt +12 -25
  21. package/android/src/main/res/layout/navigation_view.xml +6 -7
  22. package/example/.buckconfig +0 -0
  23. package/example/{_bundle → .bundle}/config +0 -0
  24. package/example/.eslintrc.js +1 -1
  25. package/example/.flowconfig +0 -0
  26. package/example/.prettierrc.js +2 -2
  27. package/example/.watchmanconfig +1 -1
  28. package/example/Gemfile +5 -2
  29. package/example/NavigationComponent.js +0 -1
  30. package/example/README.md +79 -0
  31. package/example/android/app/build.gradle +60 -173
  32. package/example/android/app/debug.keystore +0 -0
  33. package/example/android/app/proguard-rules.pro +0 -0
  34. package/example/android/app/src/debug/AndroidManifest.xml +1 -5
  35. package/example/android/app/src/main/AndroidManifest.xml +5 -9
  36. package/example/android/app/src/main/java/com/mapboxnavigationexample/MainActivity.kt +22 -0
  37. package/example/android/app/src/main/java/com/mapboxnavigationexample/MainApplication.kt +45 -0
  38. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +1 -1
  39. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  40. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  41. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  42. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  43. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  44. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  45. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  46. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  47. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  48. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  49. package/example/android/app/src/main/res/values/strings.xml +1 -1
  50. package/example/android/app/src/main/res/values/styles.xml +0 -0
  51. package/example/android/build.gradle +19 -35
  52. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  53. package/example/android/gradle/wrapper/gradle-wrapper.properties +3 -1
  54. package/example/android/gradle.properties +18 -7
  55. package/example/android/gradlew +173 -109
  56. package/example/android/gradlew.bat +19 -16
  57. package/example/android/settings.gradle +3 -3
  58. package/example/app.json +3 -3
  59. package/example/babel.config.js +1 -8
  60. package/example/index.js +3 -7
  61. package/example/ios/.xcode.env +1 -0
  62. package/example/ios/.xcode.env.local +2 -0
  63. package/example/ios/BasicApp/AppDelegate.h +1 -1
  64. package/example/ios/BasicApp/AppDelegate.m +1 -1
  65. package/example/ios/BasicApp/Info.plist +18 -18
  66. package/example/ios/BasicApp.xcodeproj/project.pbxproj +35 -9
  67. package/example/ios/BasicApp.xcodeproj/xcshareddata/xcschemes/BasicApp.xcscheme +1 -1
  68. package/example/ios/Podfile +48 -25
  69. package/example/ios/Podfile.lock +1257 -299
  70. package/example/jest.config.js +3 -0
  71. package/example/metro.config.js +19 -19
  72. package/example/package.json +14 -17
  73. package/example/react-native.config.js +10 -0
  74. package/example/{App.js → src/App.js} +3 -3
  75. package/package.json +1 -1
  76. package/src/__tests__/index.test.tsx +1 -0
  77. package/src/typings.ts +0 -1
  78. package/.vscode/settings.json +0 -3
  79. package/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
  80. package/android/.gradle/7.3.3/checksums/md5-checksums.bin +0 -0
  81. package/android/.gradle/7.3.3/checksums/sha1-checksums.bin +0 -0
  82. package/android/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock +0 -0
  83. package/android/.gradle/7.3.3/dependencies-accessors/gc.properties +0 -0
  84. package/android/.gradle/7.3.3/executionHistory/executionHistory.lock +0 -0
  85. package/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
  86. package/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
  87. package/android/.gradle/7.3.3/gc.properties +0 -0
  88. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  89. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  90. package/android/.gradle/vcs-1/gc.properties +0 -0
  91. package/android/README.md +0 -14
  92. package/dist/index.d.ts +0 -3
  93. package/dist/index.js +0 -12
  94. package/dist/typings.d.ts +0 -38
  95. package/dist/typings.js +0 -1
  96. package/example/Gemfile.lock +0 -100
  97. package/example/__tests__/App-test.js +0 -14
  98. package/example/_ruby-version +0 -1
  99. package/example/android/.gradle/8.2/checksums/checksums.lock +0 -0
  100. package/example/android/.gradle/8.2/fileChanges/last-build.bin +0 -0
  101. package/example/android/.gradle/8.2/fileHashes/fileHashes.lock +0 -0
  102. package/example/android/.gradle/8.2/gc.properties +0 -0
  103. package/example/android/.gradle/vcs-1/gc.properties +0 -0
  104. package/example/android/app/_BUCK +0 -55
  105. package/example/android/app/build_defs.bzl +0 -19
  106. package/example/android/app/src/debug/java/com/basicapp/ReactNativeFlipper.java +0 -72
  107. package/example/android/app/src/main/java/com/basicapp/MainActivity.java +0 -15
  108. package/example/android/app/src/main/java/com/basicapp/MainApplication.java +0 -81
  109. package/img/bridging-header.png +0 -0
  110. package/img/build-setting-linking.png +0 -0
  111. package/img/build-setting-path.png +0 -0
  112. /package/android/src/main/res/{values → value}/styles.xml +0 -0
package/CONTRIBUTING.md CHANGED
@@ -1,11 +1,122 @@
1
1
  # Contributing
2
2
 
3
- Contributing to this project should be as easy and transparent as possible.
3
+ Contributions are always welcome, no matter how large or small!
4
4
 
5
- ## Workflow
5
+ We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md).
6
6
 
7
- We use [GitHub Flow](https://guides.github.com/introduction/flow/), so all code changes happen through pull requests.
7
+ ## Development workflow
8
8
 
9
- 1. Fork the repository and create your branch from `master`.
10
- 2. If you've changed the functionality, update the documentation.
11
- 3. Issue that pull request! :tada:
9
+ This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
10
+
11
+ - The library package in the root directory.
12
+ - An example app in the `example/` directory.
13
+
14
+ To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
15
+
16
+ ```sh
17
+ yarn
18
+ ```
19
+
20
+ > Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development.
21
+
22
+ The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
23
+
24
+ It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
25
+
26
+ If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/MapboxNavigationExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-mapbox-navigation`.
27
+
28
+ To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-mapbox-navigation` under `Android`.
29
+
30
+ You can use various commands from the root directory to work with the project.
31
+
32
+ To start the packager:
33
+
34
+ ```sh
35
+ yarn example start
36
+ ```
37
+
38
+ To run the example app on Android:
39
+
40
+ ```sh
41
+ yarn example android
42
+ ```
43
+
44
+ To run the example app on iOS:
45
+
46
+ ```sh
47
+ yarn example ios
48
+ ```
49
+
50
+ Make sure your code passes TypeScript and ESLint. Run the following to verify:
51
+
52
+ ```sh
53
+ yarn typecheck
54
+ yarn lint
55
+ ```
56
+
57
+ To fix formatting errors, run the following:
58
+
59
+ ```sh
60
+ yarn lint --fix
61
+ ```
62
+
63
+ Remember to add tests for your change if possible. Run the unit tests by:
64
+
65
+ ```sh
66
+ yarn test
67
+ ```
68
+
69
+ ### Commit message convention
70
+
71
+ We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
72
+
73
+ - `fix`: bug fixes, e.g. fix crash due to deprecated method.
74
+ - `feat`: new features, e.g. add new method to the module.
75
+ - `refactor`: code refactor, e.g. migrate from class components to hooks.
76
+ - `docs`: changes into documentation, e.g. add usage example for the module..
77
+ - `test`: adding or updating tests, e.g. add integration tests using detox.
78
+ - `chore`: tooling changes, e.g. change CI config.
79
+
80
+ Our pre-commit hooks verify that your commit message matches this format when committing.
81
+
82
+ ### Linting and tests
83
+
84
+ [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
85
+
86
+ We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
87
+
88
+ Our pre-commit hooks verify that the linter and tests pass when committing.
89
+
90
+ ### Publishing to npm
91
+
92
+ We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
93
+
94
+ To publish new versions, run the following:
95
+
96
+ ```sh
97
+ yarn release
98
+ ```
99
+
100
+ ### Scripts
101
+
102
+ The `package.json` file contains various scripts for common tasks:
103
+
104
+ - `yarn`: setup project by installing dependencies.
105
+ - `yarn typecheck`: type-check files with TypeScript.
106
+ - `yarn lint`: lint files with ESLint.
107
+ - `yarn test`: run unit tests with Jest.
108
+ - `yarn example start`: start the Metro server for the example app.
109
+ - `yarn example android`: run the example app on Android.
110
+ - `yarn example ios`: run the example app on iOS.
111
+
112
+ ### Sending a pull request
113
+
114
+ > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
115
+
116
+ When you're sending a pull request:
117
+
118
+ - Prefer small pull requests focused on one change.
119
+ - Verify that linters and tests are passing.
120
+ - Review the documentation to make sure it looks good.
121
+ - Follow the pull request template when opening a pull request.
122
+ - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
package/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
1
  MIT License
2
2
 
3
3
  Copyright (c) 2024 Jamie Adams
4
-
5
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
5
  of this software and associated documentation files (the "Software"), to deal
7
6
  in the Software without restriction, including without limitation the rights
@@ -18,4 +17,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
17
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
18
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
19
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
20
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- <img alt="React Native Mapbox Navigation" src="./img/ios-nav.png?v=2" width="300" align="right" /> -->
4
4
 
5
- Smart Mapbox turn-by-turn routing based on real-time traffic for React Native. A navigation UI ready to drop into your React Native application.
5
+ Smart Mapbox turn-by-turn routing based on real-time traffic for React Native. A navigation UI ready to drop into your React Native application.
6
6
 
7
7
  ## Features
8
8
 
@@ -237,9 +237,9 @@ For more information you can read the [docs provided by Mapbox](https://docs.map
237
237
  ## Usage
238
238
 
239
239
  ```jsx
240
- import * as React from "react";
241
- import { StyleSheet, View } from "react-native";
242
- import MapboxNavigation from "@jadamsbit/react-native-mapbox-navigation";
240
+ import * as React from 'react';
241
+ import { StyleSheet, View } from 'react-native';
242
+ import MapboxNavigation from '@jadamsbit/react-native-mapbox-navigation';
243
243
 
244
244
  export const SomeComponent = () => {
245
245
  return (
@@ -8,7 +8,7 @@ buildscript {
8
8
  }
9
9
 
10
10
  dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.2"
11
+ classpath "com.android.tools.build:gradle:7.3.1"
12
12
  // noinspection DifferentKotlinGradleVersion
13
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
14
  }
@@ -66,8 +66,11 @@ android {
66
66
 
67
67
  buildFeatures {
68
68
  viewBinding true
69
+ buildConfig true
69
70
  }
70
71
 
72
+ namespace 'com.jadamsbit.mapboxnavigation'
73
+
71
74
  }
72
75
 
73
76
  repositories {
@@ -81,13 +84,14 @@ dependencies {
81
84
  // For < 0.71, this will be from the local maven repo
82
85
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
83
86
  //noinspection GradleDynamicVersion
84
- implementation "com.facebook.react:react-native:+"
87
+ implementation "com.facebook.react:react-native:0.20.1"
85
88
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
86
89
 
87
90
  // mapbox dependencies
88
91
  implementation "com.mapbox.navigation:android:2.18.1"
89
92
  implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
90
93
  implementation 'androidx.cardview:cardview:1.0.0'
94
+ implementation 'androidx.core:core:1.12.0'
91
95
  }
92
96
 
93
97
  if (isNewArchitectureEnabled()) {
@@ -96,4 +100,4 @@ if (isNewArchitectureEnabled()) {
96
100
  libraryName = "MapboxNavigationView"
97
101
  codegenJavaPackageName = "com.jadamsbit.mapboxnavigation"
98
102
  }
99
- }
103
+ }
@@ -1,7 +1,7 @@
1
- #Mon Feb 12 09:11:13 IST 2024
2
1
  distributionBase=GRADLE_USER_HOME
3
2
  distributionPath=wrapper/dists
4
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
5
4
  networkTimeout=10000
5
+ validateDistributionUrl=true
6
6
  zipStoreBase=GRADLE_USER_HOME
7
7
  zipStorePath=wrapper/dists
@@ -1,4 +1,6 @@
1
- MapboxNavigation_kotlinVersion=1.6.0
2
- MapboxNavigation_compileSdkVersion=33
1
+ MapboxNavigation_kotlinVersion=1.9.23
3
2
  MapboxNavigation_minSdkVersion=21
4
- MapboxNavigation_targetSdkVersion=33
3
+ MapboxNavigation_targetSdkVersion=34
4
+ MapboxNavigation_compileSdkVersion=34
5
+ MapboxNavigation_ndkversion=21.4.7075529
6
+ android.useAndroidX=true
package/android/gradlew CHANGED
@@ -83,10 +83,8 @@ done
83
83
  # This is normally unused
84
84
  # shellcheck disable=SC2034
85
85
  APP_BASE_NAME=${0##*/}
86
- APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87
-
88
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
- DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87
+ APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
90
88
 
91
89
  # Use the maximum available, or set MAX_FD != -1 to use that value.
92
90
  MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
133
131
  fi
134
132
  else
135
133
  JAVACMD=java
136
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134
+ if ! command -v java >/dev/null 2>&1
135
+ then
136
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
137
 
138
138
  Please set the JAVA_HOME variable in your environment to match the
139
139
  location of your Java installation."
140
+ fi
140
141
  fi
141
142
 
142
143
  # Increase the maximum file descriptors if we can.
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
145
  case $MAX_FD in #(
145
146
  max*)
146
147
  # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147
- # shellcheck disable=SC3045
148
+ # shellcheck disable=SC2039,SC3045
148
149
  MAX_FD=$( ulimit -H -n ) ||
149
150
  warn "Could not query maximum file descriptor limit"
150
151
  esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
152
153
  '' | soft) :;; #(
153
154
  *)
154
155
  # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155
- # shellcheck disable=SC3045
156
+ # shellcheck disable=SC2039,SC3045
156
157
  ulimit -n "$MAX_FD" ||
157
158
  warn "Could not set maximum file descriptor limit to $MAX_FD"
158
159
  esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
197
198
  done
198
199
  fi
199
200
 
200
- # Collect all arguments for the java command;
201
- # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202
- # shell script including quotes and variable substitutions, so put them in
203
- # double quotes to make sure that they get re-expanded; and
204
- # * put everything else in single quotes, so that it's not re-expanded.
201
+
202
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204
+
205
+ # Collect all arguments for the java command:
206
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207
+ # and any embedded shellness will be escaped.
208
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209
+ # treated as '${Hostname}' itself on the command line.
205
210
 
206
211
  set -- \
207
212
  "-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
43
43
  %JAVA_EXE% -version >NUL 2>&1
44
44
  if %ERRORLEVEL% equ 0 goto execute
45
45
 
46
- echo.
47
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48
- echo.
49
- echo Please set the JAVA_HOME variable in your environment to match the
50
- echo location of your Java installation.
46
+ echo. 1>&2
47
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48
+ echo. 1>&2
49
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50
+ echo location of your Java installation. 1>&2
51
51
 
52
52
  goto fail
53
53
 
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57
57
 
58
58
  if exist "%JAVA_EXE%" goto execute
59
59
 
60
- echo.
61
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62
- echo.
63
- echo Please set the JAVA_HOME variable in your environment to match the
64
- echo location of your Java installation.
60
+ echo. 1>&2
61
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62
+ echo. 1>&2
63
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64
+ echo location of your Java installation. 1>&2
65
65
 
66
66
  goto fail
67
67
 
@@ -1,4 +1,3 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
2
  package="com.jadamsbit.mapboxnavigation">
3
-
4
3
  </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -12,12 +12,17 @@ import com.mapbox.maps.ResourceOptionsManager
12
12
  import com.mapbox.maps.TileStoreUsageMode
13
13
  import javax.annotation.Nonnull
14
14
 
15
- class MapboxNavigationManager(var mCallerContext: ReactApplicationContext) : SimpleViewManager<MapboxNavigationView>() {
15
+ class MapboxNavigationModule(var mCallerContext: ReactApplicationContext) : SimpleViewManager<MapboxNavigationView>() {
16
16
  private var accessToken: String? = null
17
+
17
18
  init {
18
19
  mCallerContext.runOnUiQueueThread {
19
20
  try {
20
- val app = mCallerContext.packageManager.getApplicationInfo(mCallerContext.packageName, PackageManager.GET_META_DATA)
21
+ val app =
22
+ mCallerContext.packageManager.getApplicationInfo(
23
+ mCallerContext.packageName,
24
+ PackageManager.GET_META_DATA
25
+ )
21
26
  val bundle = app.metaData
22
27
  val accessToken = bundle.getString("MAPBOX_ACCESS_TOKEN")
23
28
  this.accessToken = accessToken
@@ -29,9 +34,19 @@ class MapboxNavigationManager(var mCallerContext: ReactApplicationContext) : Sim
29
34
  }
30
35
  }
31
36
  }
32
- override fun getName(): String = "MapboxNavigation"
33
37
 
34
- public override fun createViewInstance(@Nonnull reactContext: ThemedReactContext): MapboxNavigationView {
38
+
39
+ override fun getName(): String {
40
+ return NAME
41
+ }
42
+
43
+ companion object {
44
+ const val NAME = "MapboxNavigation"
45
+ }
46
+
47
+ public override fun createViewInstance(
48
+ @Nonnull reactContext: ThemedReactContext
49
+ ): MapboxNavigationView {
35
50
  return MapboxNavigationView(reactContext, this.accessToken)
36
51
  }
37
52
 
@@ -42,11 +57,16 @@ class MapboxNavigationManager(var mCallerContext: ReactApplicationContext) : Sim
42
57
 
43
58
  override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Map<String, String>>? {
44
59
  return MapBuilder.of<String, Map<String, String>>(
45
- "onLocationChange", MapBuilder.of("registrationName", "onLocationChange"),
46
- "onError", MapBuilder.of("registrationName", "onError"),
47
- "onCancelNavigation", MapBuilder.of("registrationName", "onCancelNavigation"),
48
- "onArrive", MapBuilder.of("registrationName", "onArrive"),
49
- "onRouteProgressChange", MapBuilder.of("registrationName", "onRouteProgressChange"),
60
+ "onLocationChange",
61
+ MapBuilder.of("registrationName", "onLocationChange"),
62
+ "onError",
63
+ MapBuilder.of("registrationName", "onError"),
64
+ "onCancelNavigation",
65
+ MapBuilder.of("registrationName", "onCancelNavigation"),
66
+ "onArrive",
67
+ MapBuilder.of("registrationName", "onArrive"),
68
+ "onRouteProgressChange",
69
+ MapBuilder.of("registrationName", "onRouteProgressChange"),
50
70
  )
51
71
  }
52
72
 
@@ -82,21 +102,4 @@ class MapboxNavigationManager(var mCallerContext: ReactApplicationContext) : Sim
82
102
  fun setMute(view: MapboxNavigationView, mute: Boolean) {
83
103
  view.setMute(mute)
84
104
  }
85
-
86
- @ReactProp(name = "waypoints")
87
- fun setWaypoints(view: MapboxNavigationView, waypointsArray: ReadableArray?) {
88
- waypointsArray?.let {
89
- val waypoints = mutableListOf<Point>()
90
- for (i in 0 until it.size()) {
91
- val waypointArray = it.getArray(i)
92
- if (waypointArray !== null && waypointArray.size() >= 2) {
93
- val longitude = waypointArray.getDouble(0)
94
- val latitude = waypointArray.getDouble(1)
95
- waypoints.add(Point.fromLngLat(longitude, latitude))
96
- }
97
- }
98
-
99
- view.setWaypoints(waypoints)
100
- }
101
- }
102
- }
105
+ }
@@ -4,6 +4,7 @@ import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.uimanager.ViewManager
7
+ import java.util.*
7
8
 
8
9
  class MapboxNavigationPackage : ReactPackage {
9
10
  override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
@@ -11,6 +12,6 @@ class MapboxNavigationPackage : ReactPackage {
11
12
  }
12
13
 
13
14
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
14
- return listOf(MapboxNavigationManager(reactContext))
15
+ return Arrays.asList<ViewManager<*, *>>(MapboxNavigationModule(reactContext))
15
16
  }
16
- }
17
+ }
@@ -87,7 +87,6 @@ class MapboxNavigationView(private val context: ThemedReactContext, private val
87
87
  }
88
88
 
89
89
  private var origin: Point? = null
90
- private var waypoints: List<Point>? = null
91
90
  private var destination: Point? = null
92
91
  private var shouldSimulateRoute = false
93
92
  private var showsEndOfRouteFeedback = false
@@ -470,7 +469,8 @@ class MapboxNavigationView(private val context: ThemedReactContext, private val
470
469
  this.locationPuck = LocationPuck2D(
471
470
  bearingImage = ContextCompat.getDrawable(
472
471
  context,
473
- R.drawable.mapbox_navigation_puck_icon
472
+ com.mapbox.navigation.ui.maps.R.drawable.mapbox_navigation_puck_icon
473
+
474
474
  )
475
475
  )
476
476
  setLocationProvider(navigationLocationProvider)
@@ -628,13 +628,7 @@ class MapboxNavigationView(private val context: ThemedReactContext, private val
628
628
  mapboxNavigation.registerVoiceInstructionsObserver(voiceInstructionsObserver)
629
629
  mapboxNavigation.registerRouteProgressObserver(replayProgressObserver)
630
630
 
631
- // Create a list of coordinates that includes origin, destination, and waypoints
632
- val coordinatesList = mutableListOf<Point>()
633
- this.origin?.let { coordinatesList.add(it) }
634
- this.waypoints?.let { coordinatesList.addAll(it) }
635
- this.destination?.let { coordinatesList.add(it) }
636
-
637
- findRoute(coordinatesList)
631
+ this.origin?.let { this.destination?.let { it1 -> this.findRoute(it, it1) } }
638
632
  }
639
633
 
640
634
  override fun onDetachedFromWindow() {
@@ -656,19 +650,16 @@ class MapboxNavigationView(private val context: ThemedReactContext, private val
656
650
  voiceInstructionsPlayer.shutdown()
657
651
  }
658
652
 
659
- private fun findRoute(coordinates: List<Point>) {
653
+ private fun findRoute(origin: Point, destination: Point) {
660
654
  try {
661
- val routeOptionsBuilder = RouteOptions.builder()
662
- .applyDefaultNavigationOptions()
663
- .applyLanguageAndVoiceUnitOptions(context)
664
- .coordinatesList(coordinates)
665
- .profile(DirectionsCriteria.PROFILE_DRIVING)
666
- .steps(true)
667
-
668
- val routeOptions = routeOptionsBuilder.build()
669
-
670
655
  mapboxNavigation.requestRoutes(
671
- routeOptions,
656
+ RouteOptions.builder()
657
+ .applyDefaultNavigationOptions()
658
+ .applyLanguageAndVoiceUnitOptions(context)
659
+ .coordinatesList(listOf(origin, destination))
660
+ .profile(DirectionsCriteria.PROFILE_DRIVING)
661
+ .steps(true)
662
+ .build(),
672
663
  object : RouterCallback {
673
664
  override fun onRoutesReady(
674
665
  routes: List<DirectionsRoute>,
@@ -759,10 +750,6 @@ class MapboxNavigationView(private val context: ThemedReactContext, private val
759
750
  this.origin = origin
760
751
  }
761
752
 
762
- fun setWaypoints(waypoints: List<Point>) {
763
- this.waypoints = waypoints
764
- }
765
-
766
753
  fun setDestination(destination: Point?) {
767
754
  this.destination = destination
768
755
  }
@@ -778,4 +765,4 @@ class MapboxNavigationView(private val context: ThemedReactContext, private val
778
765
  fun setMute(mute: Boolean) {
779
766
  this.isVoiceInstructionsMuted = mute
780
767
  }
781
- }
768
+ }
@@ -26,20 +26,19 @@
26
26
 
27
27
  <com.mapbox.navigation.ui.tripprogress.view.MapboxTripProgressView
28
28
  android:id="@+id/tripProgressView"
29
- android:layout_width="wrap_content"
29
+ android:layout_width="match_parent"
30
30
  android:layout_height="wrap_content"
31
- android:layout_gravity="fill|left"
32
- android:layout_marginStart="16dp"
33
- android:layout_marginTop="8dp" />
31
+ android:layout_gravity="left"
32
+ />
34
33
 
35
34
  <ImageView
36
35
  android:id="@+id/stop"
37
36
  android:layout_width="48dp"
38
37
  android:layout_height="48dp"
39
- android:layout_gravity="right|center_vertical"
38
+ android:layout_gravity="end|center_vertical"
40
39
  android:layout_marginEnd="12dp"
41
- app:srcCompat="@android:drawable/ic_delete"
42
- app:tint="@android:color/darker_gray" />
40
+ app:tint="@android:color/darker_gray"
41
+ app:srcCompat="@android:drawable/ic_delete" />
43
42
  </androidx.cardview.widget.CardView>
44
43
 
45
44
  <com.mapbox.navigation.ui.maneuver.view.MapboxManeuverView
File without changes
File without changes
@@ -1,4 +1,4 @@
1
1
  module.exports = {
2
2
  root: true,
3
- extends: '@react-native-community',
3
+ extends: "@react-native-community",
4
4
  };
File without changes
@@ -2,6 +2,6 @@ module.exports = {
2
2
  bracketSpacing: false,
3
3
  jsxBracketSameLine: true,
4
4
  singleQuote: true,
5
- trailingComma: 'all',
6
- arrowParens: 'avoid',
5
+ trailingComma: "all",
6
+ arrowParens: "avoid",
7
7
  };
@@ -1 +1 @@
1
- {}
1
+ {}
package/example/Gemfile CHANGED
@@ -1,6 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4
- ruby '2.7.4'
4
+ ruby ">= 2.6.10"
5
5
 
6
- gem 'cocoapods', '~> 1.11', '>= 1.11.2'
6
+ # Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
7
+ # bound in the template on Cocoapods with next React Native release.
8
+ gem 'cocoapods', '>= 1.13', '< 1.15'
9
+ gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
@@ -14,7 +14,6 @@ const Navigation = props => {
14
14
  shouldSimulateRoute={true}
15
15
  origin={origin}
16
16
  destination={destination}
17
- showsEndOfRouteFeedback={false}
18
17
  hideStatusView
19
18
  onLocationChange={event => {
20
19
  console.log('onLocationChange', event.nativeEvent);