@complexify/expo-mapbox-navigation 1.2.2 → 1.3.0

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.
@@ -34,330 +34,6 @@ class ExpoMapboxNavigationView: ExpoView {
34
34
  override func layoutSubviews() {
35
35
  controller.view.frame = bounds
36
36
  }
37
-
38
- // Steps List
39
- func setStepsBackgroundColor(hexColor: String) {
40
- controller.customDayStyle.customStepsBackgroundColor = UIColor(hex: hexColor)
41
- controller.update()
42
- }
43
-
44
- func setStepsPrimaryTextColor(hexColor: String) {
45
- controller.customDayStyle.customStepsPrimaryTextColor = UIColor(hex: hexColor)
46
- controller.update()
47
- }
48
-
49
- func setStepsSecondaryTextColor(hexColor: String) {
50
- controller.customDayStyle.customStepsSecondaryTextColor = UIColor(hex: hexColor)
51
- controller.update()
52
- }
53
-
54
- func setStepsManeuverViewPrimaryColor(hexColor: String) {
55
- controller.customDayStyle.customStepsManeuverViewPrimaryColor = UIColor(hex: hexColor)
56
- controller.update()
57
- }
58
-
59
- func setStepsManeuverViewSecondaryColor(hexColor: String) {
60
- controller.customDayStyle.customStepsManeuverViewSecondaryColor = UIColor(hex: hexColor)
61
- controller.update()
62
- }
63
-
64
- func setStepsSeparatorColor(hexColor: String) {
65
- controller.customDayStyle.customStepsSeparatorColor = UIColor(hex: hexColor)
66
- controller.update()
67
- }
68
-
69
- // Lane View
70
- func setLaneViewBackgroundColor(hexColor: String) {
71
- controller.customDayStyle.customLaneViewBackgroundColor = UIColor(hex: hexColor)
72
- controller.update()
73
- }
74
-
75
- func setLaneViewForegroundColor(hexColor: String) {
76
- controller.customDayStyle.customLaneViewForegroundColor = UIColor(hex: hexColor)
77
- controller.update()
78
- }
79
-
80
- func setLaneViewSeparatorColor(hexColor: String) {
81
- controller.customDayStyle.customLaneViewSeparatorColor = UIColor(hex: hexColor)
82
- controller.update()
83
- }
84
-
85
- // Next Banner View
86
- func setNextBannerBackgroundColor(hexColor: String) {
87
- controller.customDayStyle.customNextBannerBackgroundColor = UIColor(hex: hexColor)
88
- controller.update()
89
- }
90
-
91
- func setNextBannerPrimaryTextColor(hexColor: String) {
92
- controller.customDayStyle.customNextBannerPrimaryTextColor = UIColor(hex: hexColor)
93
- controller.update()
94
- }
95
-
96
- func setNextBannerSecondaryTextColor(hexColor: String) {
97
- controller.customDayStyle.customNextBannerSecondaryTextColor = UIColor(hex: hexColor)
98
- controller.update()
99
- }
100
-
101
- func setNextBannerDistanceTextColor(hexColor: String) {
102
- controller.customDayStyle.customNextBannerDistanceTextColor = UIColor(hex: hexColor)
103
- controller.update()
104
- }
105
-
106
- // Progress Bar
107
- func setProgressBarProgressColor(hexColor: String) {
108
- controller.customDayStyle.customProgressBarProgressColor = UIColor(hex: hexColor)
109
- controller.update()
110
- }
111
-
112
- func setProgressBarBackgroundColor(hexColor: String) {
113
- controller.customDayStyle.customProgressBarBackgroundColor = UIColor(hex: hexColor)
114
- controller.update()
115
- }
116
-
117
- // Instructions Card
118
- func setInstructionsCardBackgroundColor(hexColor: String) {
119
- controller.customDayStyle.customInstructionsCardBackgroundColor = UIColor(hex: hexColor)
120
- controller.update()
121
- }
122
-
123
- func setInstructionsCardSeparatorColor(hexColor: String) {
124
- controller.customDayStyle.customInstructionsCardSeparatorColor = UIColor(hex: hexColor)
125
- controller.update()
126
- }
127
-
128
- func setInstructionsCardHighlightedSeparatorColor(hexColor: String) {
129
- controller.customDayStyle.customInstructionsCardHighlightedSeparatorColor = UIColor(hex: hexColor)
130
- controller.update()
131
- }
132
-
133
- // Exit View
134
- func setExitViewForegroundColor(hexColor: String) {
135
- controller.customDayStyle.customExitViewForegroundColor = UIColor(hex: hexColor)
136
- controller.update()
137
- }
138
-
139
- func setExitViewBorderColor(hexColor: String) {
140
- controller.customDayStyle.customExitViewBorderColor = UIColor(hex: hexColor)
141
- controller.update()
142
- }
143
-
144
- func setExitViewHighlightColor(hexColor: String) {
145
- controller.customDayStyle.customExitViewHighlightColor = UIColor(hex: hexColor)
146
- controller.update()
147
- }
148
-
149
- // Route Shield
150
- func setRouteShieldForegroundColor(hexColor: String) {
151
- controller.customDayStyle.customRouteShieldForegroundColor = UIColor(hex: hexColor)
152
- controller.update()
153
- }
154
-
155
- func setRouteShieldBorderColor(hexColor: String) {
156
- controller.customDayStyle.customRouteShieldBorderColor = UIColor(hex: hexColor)
157
- controller.update()
158
- }
159
-
160
- func setRouteShieldHighlightColor(hexColor: String) {
161
- controller.customDayStyle.customRouteShieldHighlightColor = UIColor(hex: hexColor)
162
- controller.update()
163
- }
164
-
165
- // Distance Labels
166
- func setDistanceRemainingColor(hexColor: String) {
167
- controller.customDayStyle.customDistanceRemainingColor = UIColor(hex: hexColor)
168
- controller.update()
169
- }
170
-
171
- func setDistanceUnitColor(hexColor: String) {
172
- controller.customDayStyle.customDistanceUnitColor = UIColor(hex: hexColor)
173
- controller.update()
174
- }
175
-
176
- func setDistanceValueColor(hexColor: String) {
177
- controller.customDayStyle.customDistanceValueColor = UIColor(hex: hexColor)
178
- controller.update()
179
- }
180
-
181
- // Navigation Map
182
- func setRouteAnnotationSelectedColor(hexColor: String) {
183
- controller.customDayStyle.customRouteAnnotationSelectedColor = UIColor(hex: hexColor)
184
- controller.update()
185
- }
186
-
187
- func setRouteAnnotationColor(hexColor: String) {
188
- controller.customDayStyle.customRouteAnnotationColor = UIColor(hex: hexColor)
189
- controller.update()
190
- }
191
-
192
- // Route Shield Colors
193
- func setRoadShieldBlackColor(hexColor: String) {
194
- controller.customDayStyle.customRoadShieldBlackColor = UIColor(hex: hexColor)
195
- controller.update()
196
- }
197
-
198
- func setRoadShieldBlueColor(hexColor: String) {
199
- controller.customDayStyle.customRoadShieldBlueColor = UIColor(hex: hexColor)
200
- controller.update()
201
- }
202
-
203
- func setRoadShieldGreenColor(hexColor: String) {
204
- controller.customDayStyle.customRoadShieldGreenColor = UIColor(hex: hexColor)
205
- controller.update()
206
- }
207
-
208
- func setRoadShieldRedColor(hexColor: String) {
209
- controller.customDayStyle.customRoadShieldRedColor = UIColor(hex: hexColor)
210
- controller.update()
211
- }
212
-
213
- func setRoadShieldWhiteColor(hexColor: String) {
214
- controller.customDayStyle.customRoadShieldWhiteColor = UIColor(hex: hexColor)
215
- controller.update()
216
- }
217
-
218
- func setRoadShieldYellowColor(hexColor: String) {
219
- controller.customDayStyle.customRoadShieldYellowColor = UIColor(hex: hexColor)
220
- controller.update()
221
- }
222
-
223
- func setRoadShieldDefaultColor(hexColor: String) {
224
- controller.customDayStyle.customRoadShieldDefaultColor = UIColor(hex: hexColor)
225
- controller.update()
226
- }
227
-
228
- // Button Properties
229
- func setButtonTextColor(hexColor: String) {
230
- controller.customDayStyle.customButtonTextColor = UIColor(hex: hexColor)
231
- controller.update()
232
- }
233
-
234
- func setCancelButtonTintColor(hexColor: String) {
235
- controller.customDayStyle.customCancelButtonTintColor = UIColor(hex: hexColor)
236
- controller.update()
237
- }
238
-
239
- func setPreviewButtonTintColor(hexColor: String) {
240
- controller.customDayStyle.customPreviewButtonTintColor = UIColor(hex: hexColor)
241
- controller.update()
242
- }
243
-
244
- func setStartButtonTintColor(hexColor: String) {
245
- controller.customDayStyle.customStartButtonTintColor = UIColor(hex: hexColor)
246
- controller.update()
247
- }
248
-
249
- func setDismissButtonBackgroundColor(hexColor: String) {
250
- controller.customDayStyle.customDismissButtonBackgroundColor = UIColor(hex: hexColor)
251
- controller.update()
252
- }
253
-
254
- func setDismissButtonTextColor(hexColor: String) {
255
- controller.customDayStyle.customDismissButtonTextColor = UIColor(hex: hexColor)
256
- controller.update()
257
- }
258
-
259
- func setBackButtonBackgroundColor(hexColor: String) {
260
- controller.customDayStyle.customBackButtonBackgroundColor = UIColor(hex: hexColor)
261
- controller.update()
262
- }
263
-
264
- func setBackButtonTintColor(hexColor: String) {
265
- controller.customDayStyle.customBackButtonTintColor = UIColor(hex: hexColor)
266
- controller.update()
267
- }
268
-
269
- func setBackButtonTextColor(hexColor: String) {
270
- controller.customDayStyle.customBackButtonTextColor = UIColor(hex: hexColor)
271
- controller.update()
272
- }
273
-
274
- func setBackButtonBorderColor(hexColor: String) {
275
- controller.customDayStyle.customBackButtonBorderColor = UIColor(hex: hexColor)
276
- controller.update()
277
- }
278
-
279
- // Navigation View
280
- func setNavigationViewBackgroundColor(hexColor: String) {
281
- controller.customDayStyle.customNavigationViewBackgroundColor = UIColor(hex: hexColor)
282
- controller.update()
283
- }
284
-
285
- // Distance Label Properties
286
- func setDistanceLabelUnitTextColor(hexColor: String) {
287
- controller.customDayStyle.customDistanceLabelUnitTextColor = UIColor(hex: hexColor)
288
- controller.update()
289
- }
290
-
291
- func setDistanceLabelValueTextColor(hexColor: String) {
292
- controller.customDayStyle.customDistanceLabelValueTextColor = UIColor(hex: hexColor)
293
- controller.update()
294
- }
295
-
296
- // Rating Control
297
- func setRatingControlNormalColor(hexColor: String) {
298
- controller.customDayStyle.customRatingControlNormalColor = UIColor(hex: hexColor)
299
- controller.update()
300
- }
301
-
302
- func setRatingControlSelectedColor(hexColor: String) {
303
- controller.customDayStyle.customRatingControlSelectedColor = UIColor(hex: hexColor)
304
- controller.update()
305
- }
306
-
307
- // Steps Properties
308
- func setStepsBackgroundViewColor(hexColor: String) {
309
- controller.customDayStyle.customStepsBackgroundViewColor = UIColor(hex: hexColor)
310
- controller.update()
311
- }
312
-
313
- func setStepsTableHeaderTintColor(hexColor: String) {
314
- controller.customDayStyle.customStepsTableHeaderTintColor = UIColor(hex: hexColor)
315
- controller.update()
316
- }
317
-
318
- func setStepsTableHeaderTextColor(hexColor: String) {
319
- controller.customDayStyle.customStepsTableHeaderTextColor = UIColor(hex: hexColor)
320
- controller.update()
321
- }
322
-
323
- func setStepInstructionsBackgroundColor(hexColor: String) {
324
- controller.customDayStyle.customStepInstructionsBackgroundColor = UIColor(hex: hexColor)
325
- controller.update()
326
- }
327
-
328
- func setStepTableViewCellBackgroundColor(hexColor: String) {
329
- controller.customDayStyle.customStepTableViewCellBackgroundColor = UIColor(hex: hexColor)
330
- controller.update()
331
- }
332
-
333
- // Next Instruction
334
- func setNextInstructionNormalTextColor(hexColor: String) {
335
- controller.customDayStyle.customNextInstructionNormalTextColor = UIColor(hex: hexColor)
336
- controller.update()
337
- }
338
-
339
- func setNextInstructionContainedTextColor(hexColor: String) {
340
- controller.customDayStyle.customNextInstructionContainedTextColor = UIColor(hex: hexColor)
341
- controller.update()
342
- }
343
-
344
- // Secondary Label Properties
345
- func setSecondaryLabelNormalTextColor(hexColor: String) {
346
- controller.customDayStyle.customSecondaryLabelNormalTextColor = UIColor(hex: hexColor)
347
- controller.update()
348
- }
349
-
350
- // Stylable Label
351
- func setStylableLabelNormalTextColor(hexColor: String) {
352
- controller.customDayStyle.customStylableLabelNormalTextColor = UIColor(hex: hexColor)
353
- controller.update()
354
- }
355
-
356
- // CarPlay Properties
357
- func setCarPlayCompassBackgroundColor(hexColor: String) {
358
- controller.customDayStyle.customCarPlayCompassBackgroundColor = UIColor(hex: hexColor)
359
- controller.update()
360
- }
361
37
  }
362
38
 
363
39
 
@@ -390,6 +66,8 @@ class ExpoMapboxNavigationViewController: UIViewController {
390
66
  private var reroutingCancellable: AnyCancellable? = nil
391
67
  private var sessionCancellable: AnyCancellable? = nil
392
68
 
69
+ var currentRouteColor: UIColor?
70
+ var currentRouteAlternateColor: UIColor?
393
71
  var currentRouteCasingColor: UIColor?
394
72
  var currentRouteAlternateCasingColor: UIColor?
395
73
  var currentTraversedRouteColor: UIColor?
@@ -527,8 +205,18 @@ class ExpoMapboxNavigationViewController: UIViewController {
527
205
  }
528
206
  }
529
207
 
208
+ func setRouteColor(hexColor: String) {
209
+ currentRouteColor = UIColor(hex: hexColor)
210
+ update()
211
+ }
212
+
213
+ func setRouteAlternateColor(hexColor: String) {
214
+ currentRouteAlternateColor = UIColor(hex: hexColor)
215
+ update()
216
+ }
217
+
530
218
  func setRouteCasingColor(hexColor: String) {
531
- customDayStyle.customRouteCasingColor = UIColor(hex: hexColor)
219
+ currentRouteCasingColor = UIColor(hex: hexColor)
532
220
  update()
533
221
  }
534
222
 
@@ -656,16 +344,6 @@ class ExpoMapboxNavigationViewController: UIViewController {
656
344
  update()
657
345
  }
658
346
 
659
- func setManeuverViewPrimaryColorHighlighted(hexColor: String) {
660
- customDayStyle.customManeuverViewPrimaryColorHighlighted = UIColor(hex: hexColor)
661
- update()
662
- }
663
-
664
- func setManeuverViewSecondaryColorHighlighted(hexColor: String) {
665
- customDayStyle.customManeuverViewSecondaryColorHighlighted = UIColor(hex: hexColor)
666
- update()
667
- }
668
-
669
347
  func update(){
670
348
  calculateRoutesTask?.cancel()
671
349
 
@@ -686,7 +364,7 @@ class ExpoMapboxNavigationViewController: UIViewController {
686
364
  }
687
365
  }
688
366
 
689
- func calculateRoutes(waypoints: Array<Waypoint>) {
367
+ func calculateRoutes(waypoints: Array<Waypoint>){
690
368
  let routeOptions = NavigationRouteOptions(
691
369
  waypoints: waypoints,
692
370
  profileIdentifier: currentRouteProfile != nil ? ProfileIdentifier(rawValue: currentRouteProfile!) : nil,
@@ -696,21 +374,16 @@ class ExpoMapboxNavigationViewController: UIViewController {
696
374
  )
697
375
 
698
376
  calculateRoutesTask = Task {
699
- do {
700
- let result = try await self.routingProvider!.calculateRoutes(options: routeOptions)
701
- switch result.result {
702
- case .success(let navigationRoutes):
703
- onRoutesCalculated(navigationRoutes: navigationRoutes)
704
- case .failure(let error):
705
- print("Route calculation error: \(error.localizedDescription)")
706
- }
707
- } catch {
708
- print("Failed to calculate routes: \(error.localizedDescription)")
377
+ switch await self.routingProvider!.calculateRoutes(options: routeOptions).result {
378
+ case .failure(let error):
379
+ print(error.localizedDescription)
380
+ case .success(let navigationRoutes):
381
+ onRoutesCalculated(navigationRoutes: navigationRoutes)
709
382
  }
710
383
  }
711
384
  }
712
385
 
713
- func calculateMapMatchingRoutes(waypoints: Array<Waypoint>) {
386
+ func calculateMapMatchingRoutes(waypoints: Array<Waypoint>){
714
387
  let matchOptions = NavigationMatchOptions(
715
388
  waypoints: waypoints,
716
389
  profileIdentifier: currentRouteProfile != nil ? ProfileIdentifier(rawValue: currentRouteProfile!) : nil,
@@ -719,17 +392,13 @@ class ExpoMapboxNavigationViewController: UIViewController {
719
392
  )
720
393
  matchOptions.locale = currentLocale
721
394
 
395
+
722
396
  calculateRoutesTask = Task {
723
- do {
724
- let result = try await self.routingProvider!.calculateRoutes(options: matchOptions)
725
- switch result.result {
726
- case .success(let navigationRoutes):
727
- onRoutesCalculated(navigationRoutes: navigationRoutes)
728
- case .failure(let error):
729
- print("Map matching error: \(error.localizedDescription)")
730
- }
731
- } catch {
732
- print("Failed to match routes: \(error.localizedDescription)")
397
+ switch await self.routingProvider!.calculateRoutes(options: matchOptions).result {
398
+ case .failure(let error):
399
+ print(error.localizedDescription)
400
+ case .success(let navigationRoutes):
401
+ onRoutesCalculated(navigationRoutes: navigationRoutes)
733
402
  }
734
403
  }
735
404
  }
@@ -791,9 +460,18 @@ class ExpoMapboxNavigationViewController: UIViewController {
791
460
  mapboxNavigation!.tripSession().startActiveGuidance(with: navigationRoutes, startLegIndex: 0)
792
461
 
793
462
  // Apply custom colors if set
463
+ if let routeColor = currentRouteColor {
464
+ navigationMapView?.routeColor = routeColor
465
+ }
466
+ if let alternateColor = currentRouteAlternateColor {
467
+ navigationMapView?.routeAlternateColor = alternateColor
468
+ }
794
469
  if let casingColor = currentRouteCasingColor {
795
470
  navigationMapView?.routeCasingColor = casingColor
796
471
  }
472
+ if let alternateCasingColor = currentRouteAlternateCasingColor {
473
+ navigationMapView?.routeAlternateCasingColor = alternateCasingColor
474
+ }
797
475
  if let traversedColor = currentTraversedRouteColor {
798
476
  navigationMapView?.traversedRouteColor = traversedColor
799
477
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@complexify/expo-mapbox-navigation",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "Expo module for Mapbox's Navigation SDK",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",