@complexify/expo-mapbox-navigation 1.0.7 → 1.0.8
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.
@@ -137,71 +137,6 @@ public class ExpoMapboxNavigationModule: Module {
|
|
137
137
|
view.controller.setBottomBannerArrivalTimeTextColor(hexColor: hexColor)
|
138
138
|
}
|
139
139
|
}
|
140
|
-
|
141
|
-
// Information Stack
|
142
|
-
Prop("informationStackBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
143
|
-
if let hexColor = color {
|
144
|
-
view.controller.setInformationStackBackgroundColor(hexColor: hexColor)
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
Prop("informationStackTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
149
|
-
if let hexColor = color {
|
150
|
-
view.controller.setInformationStackTextColor(hexColor: hexColor)
|
151
|
-
}
|
152
|
-
}
|
153
|
-
|
154
|
-
// Resume Button
|
155
|
-
Prop("resumeButtonBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
156
|
-
if let hexColor = color {
|
157
|
-
view.controller.setResumeButtonBackgroundColor(hexColor: hexColor)
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
Prop("resumeButtonTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
162
|
-
if let hexColor = color {
|
163
|
-
view.controller.setResumeButtonTextColor(hexColor: hexColor)
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
// Speed Limit
|
168
|
-
Prop("speedLimitBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
169
|
-
if let hexColor = color {
|
170
|
-
view.controller.setSpeedLimitBackgroundColor(hexColor: hexColor)
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
|
-
Prop("speedLimitTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
175
|
-
if let hexColor = color {
|
176
|
-
view.controller.setSpeedLimitTextColor(hexColor: hexColor)
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
// Floating Stack
|
181
|
-
Prop("floatingStackBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
182
|
-
if let hexColor = color {
|
183
|
-
view.controller.setFloatingStackBackgroundColor(hexColor: hexColor)
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
Prop("floatingButtonsBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
188
|
-
if let hexColor = color {
|
189
|
-
view.controller.setFloatingButtonsBackgroundColor(hexColor: hexColor)
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
// Way Name View
|
194
|
-
Prop("wayNameViewBackgroundColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
195
|
-
if let hexColor = color {
|
196
|
-
view.controller.setWayNameViewBackgroundColor(hexColor: hexColor)
|
197
|
-
}
|
198
|
-
}
|
199
|
-
|
200
|
-
Prop("wayNameViewTextColor") { (view: ExpoMapboxNavigationView, color: String?) in
|
201
|
-
if let hexColor = color {
|
202
|
-
view.controller.setWayNameViewTextColor(hexColor: hexColor)
|
203
|
-
}
|
204
|
-
}
|
205
140
|
}
|
206
141
|
}
|
207
|
-
}
|
142
|
+
}
|
@@ -73,27 +73,16 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
73
73
|
var currentTraversedRouteColor: UIColor?
|
74
74
|
var currentManeuverArrowColor: UIColor?
|
75
75
|
|
76
|
-
var
|
77
|
-
var
|
78
|
-
var
|
79
|
-
var
|
80
|
-
var
|
81
|
-
|
82
|
-
var
|
83
|
-
var
|
84
|
-
var
|
85
|
-
var
|
86
|
-
|
87
|
-
var informationStackBackgroundColor: UIColor?
|
88
|
-
var informationStackTextColor: UIColor?
|
89
|
-
var resumeButtonBackgroundColor: UIColor?
|
90
|
-
var resumeButtonTextColor: UIColor?
|
91
|
-
var speedLimitBackgroundColor: UIColor?
|
92
|
-
var speedLimitTextColor: UIColor?
|
93
|
-
var floatingStackBackgroundColor: UIColor?
|
94
|
-
var floatingButtonsBackgroundColor: UIColor?
|
95
|
-
var wayNameViewBackgroundColor: UIColor?
|
96
|
-
var wayNameViewTextColor: UIColor?
|
76
|
+
var currentTopBannerBackgroundColor: UIColor?
|
77
|
+
var currentTopBannerPrimaryTextColor: UIColor?
|
78
|
+
var currentTopBannerSecondaryTextColor: UIColor?
|
79
|
+
var currentTopBannerDistanceTextColor: UIColor?
|
80
|
+
var currentTopBannerSeparatorColor: UIColor?
|
81
|
+
|
82
|
+
var currentBottomBannerBackgroundColor: UIColor?
|
83
|
+
var currentBottomBannerTimeRemainingTextColor: UIColor?
|
84
|
+
var currentBottomBannerDistanceRemainingTextColor: UIColor?
|
85
|
+
var currentBottomBannerArrivalTimeTextColor: UIColor?
|
97
86
|
|
98
87
|
init() {
|
99
88
|
super.init(nibName: nil, bundle: nil)
|
@@ -235,98 +224,39 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
235
224
|
}
|
236
225
|
|
237
226
|
func setTopBannerBackgroundColor(hexColor: String) {
|
238
|
-
|
239
|
-
update()
|
227
|
+
currentTopBannerBackgroundColor = UIColor(hex: hexColor)
|
240
228
|
}
|
241
229
|
|
242
230
|
func setTopBannerPrimaryTextColor(hexColor: String) {
|
243
|
-
|
244
|
-
update()
|
231
|
+
currentTopBannerPrimaryTextColor = UIColor(hex: hexColor)
|
245
232
|
}
|
246
233
|
|
247
234
|
func setTopBannerSecondaryTextColor(hexColor: String) {
|
248
|
-
|
249
|
-
update()
|
235
|
+
currentTopBannerSecondaryTextColor = UIColor(hex: hexColor)
|
250
236
|
}
|
251
237
|
|
252
238
|
func setTopBannerDistanceTextColor(hexColor: String) {
|
253
|
-
|
254
|
-
update()
|
239
|
+
currentTopBannerDistanceTextColor = UIColor(hex: hexColor)
|
255
240
|
}
|
256
241
|
|
257
242
|
func setTopBannerSeparatorColor(hexColor: String) {
|
258
|
-
|
259
|
-
update()
|
243
|
+
currentTopBannerSeparatorColor = UIColor(hex: hexColor)
|
260
244
|
}
|
261
245
|
|
262
246
|
func setBottomBannerBackgroundColor(hexColor: String) {
|
263
|
-
|
264
|
-
update()
|
247
|
+
currentBottomBannerBackgroundColor = UIColor(hex: hexColor)
|
265
248
|
}
|
266
249
|
|
267
250
|
func setBottomBannerTimeRemainingTextColor(hexColor: String) {
|
268
|
-
|
269
|
-
update()
|
251
|
+
currentBottomBannerTimeRemainingTextColor = UIColor(hex: hexColor)
|
270
252
|
}
|
271
253
|
|
272
254
|
func setBottomBannerDistanceRemainingTextColor(hexColor: String) {
|
273
|
-
|
274
|
-
update()
|
255
|
+
currentBottomBannerDistanceRemainingTextColor = UIColor(hex: hexColor)
|
275
256
|
}
|
276
257
|
|
277
258
|
func setBottomBannerArrivalTimeTextColor(hexColor: String) {
|
278
|
-
|
279
|
-
update()
|
280
|
-
}
|
281
|
-
|
282
|
-
func setInformationStackBackgroundColor(hexColor: String) {
|
283
|
-
informationStackBackgroundColor = UIColor(hex: hexColor)
|
284
|
-
update()
|
285
|
-
}
|
286
|
-
|
287
|
-
func setInformationStackTextColor(hexColor: String) {
|
288
|
-
informationStackTextColor = UIColor(hex: hexColor)
|
289
|
-
update()
|
290
|
-
}
|
291
|
-
|
292
|
-
func setResumeButtonBackgroundColor(hexColor: String) {
|
293
|
-
resumeButtonBackgroundColor = UIColor(hex: hexColor)
|
294
|
-
update()
|
295
|
-
}
|
296
|
-
|
297
|
-
func setResumeButtonTextColor(hexColor: String) {
|
298
|
-
resumeButtonTextColor = UIColor(hex: hexColor)
|
299
|
-
update()
|
300
|
-
}
|
301
|
-
|
302
|
-
func setSpeedLimitBackgroundColor(hexColor: String) {
|
303
|
-
speedLimitBackgroundColor = UIColor(hex: hexColor)
|
304
|
-
update()
|
305
|
-
}
|
306
|
-
|
307
|
-
func setSpeedLimitTextColor(hexColor: String) {
|
308
|
-
speedLimitTextColor = UIColor(hex: hexColor)
|
309
|
-
update()
|
310
|
-
}
|
311
|
-
|
312
|
-
func setFloatingStackBackgroundColor(hexColor: String) {
|
313
|
-
floatingStackBackgroundColor = UIColor(hex: hexColor)
|
314
|
-
update()
|
315
|
-
}
|
316
|
-
|
317
|
-
func setFloatingButtonsBackgroundColor(hexColor: String) {
|
318
|
-
floatingButtonsBackgroundColor = UIColor(hex: hexColor)
|
319
|
-
update()
|
320
|
-
}
|
321
|
-
|
322
|
-
func setWayNameViewBackgroundColor(hexColor: String) {
|
323
|
-
wayNameViewBackgroundColor = UIColor(hex: hexColor)
|
324
|
-
update()
|
325
|
-
}
|
326
|
-
|
327
|
-
func setWayNameViewTextColor(hexColor: String) {
|
328
|
-
wayNameViewTextColor = UIColor(hex: hexColor)
|
329
|
-
update()
|
259
|
+
currentBottomBannerArrivalTimeTextColor = UIColor(hex: hexColor)
|
330
260
|
}
|
331
261
|
|
332
262
|
func update(){
|
@@ -392,28 +322,53 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
392
322
|
onCancelNavigation?()
|
393
323
|
}
|
394
324
|
|
395
|
-
func onRoutesCalculated(navigationRoutes: NavigationRoutes)
|
325
|
+
func onRoutesCalculated(navigationRoutes: NavigationRoutes){
|
396
326
|
onRoutesLoaded?()
|
397
327
|
|
398
328
|
let topBanner = TopBannerViewController()
|
399
|
-
topBanner.view.backgroundColor = topBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
400
|
-
topBanner.instructionsBannerView.backgroundColor = topBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
401
329
|
topBanner.instructionsBannerView.distanceFormatter.locale = currentLocale
|
330
|
+
|
331
|
+
// Apply top banner colors
|
332
|
+
if let backgroundColor = currentTopBannerBackgroundColor {
|
333
|
+
topBanner.view.backgroundColor = backgroundColor
|
334
|
+
}
|
335
|
+
if let primaryTextColor = currentTopBannerPrimaryTextColor {
|
336
|
+
topBanner.instructionsBannerView.primaryLabel.textColor = primaryTextColor
|
337
|
+
}
|
338
|
+
if let secondaryTextColor = currentTopBannerSecondaryTextColor {
|
339
|
+
topBanner.instructionsBannerView.secondaryLabel.textColor = secondaryTextColor
|
340
|
+
}
|
341
|
+
if let distanceTextColor = currentTopBannerDistanceTextColor {
|
342
|
+
topBanner.instructionsBannerView.distanceLabel.textColor = distanceTextColor
|
343
|
+
}
|
344
|
+
if let separatorColor = currentTopBannerSeparatorColor {
|
345
|
+
topBanner.instructionsBannerView.separatorView.backgroundColor = separatorColor
|
346
|
+
}
|
402
347
|
|
403
348
|
let bottomBanner = BottomBannerViewController()
|
404
|
-
bottomBanner.view.backgroundColor = bottomBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
405
349
|
bottomBanner.distanceFormatter.locale = currentLocale
|
406
350
|
bottomBanner.dateFormatter.locale = currentLocale
|
407
351
|
|
352
|
+
// Apply bottom banner colors
|
353
|
+
if let backgroundColor = currentBottomBannerBackgroundColor {
|
354
|
+
bottomBanner.view.backgroundColor = backgroundColor
|
355
|
+
}
|
356
|
+
if let timeRemainingColor = currentBottomBannerTimeRemainingTextColor {
|
357
|
+
bottomBanner.timeRemainingLabel.textColor = timeRemainingColor
|
358
|
+
}
|
359
|
+
if let distanceRemainingColor = currentBottomBannerDistanceRemainingTextColor {
|
360
|
+
bottomBanner.distanceRemainingLabel.textColor = distanceRemainingColor
|
361
|
+
}
|
362
|
+
if let arrivalTimeColor = currentBottomBannerArrivalTimeTextColor {
|
363
|
+
bottomBanner.arrivalTimeLabel.textColor = arrivalTimeColor
|
364
|
+
}
|
365
|
+
|
408
366
|
let navigationOptions = NavigationOptions(
|
409
367
|
mapboxNavigation: self.mapboxNavigation!,
|
410
368
|
voiceController: ExpoMapboxNavigationViewController.navigationProvider.routeVoiceController,
|
411
369
|
eventsManager: ExpoMapboxNavigationViewController.navigationProvider.eventsManager(),
|
412
|
-
styles: nil,
|
413
370
|
topBanner: topBanner,
|
414
|
-
bottomBanner: bottomBanner
|
415
|
-
predictiveCacheManager: nil,
|
416
|
-
navigationMapView: nil
|
371
|
+
bottomBanner: bottomBanner
|
417
372
|
)
|
418
373
|
|
419
374
|
let navigationViewController = NavigationViewController(
|
@@ -421,89 +376,20 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
421
376
|
navigationOptions: navigationOptions
|
422
377
|
)
|
423
378
|
|
424
|
-
let navigationView = navigationViewController.navigationView
|
425
|
-
|
426
|
-
// 1. Instructions Banner (Top Banner)
|
427
|
-
let instructionsBanner = navigationView.instructionsBannerView
|
428
|
-
instructionsBanner.backgroundColor = topBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
429
|
-
instructionsBanner.primaryLabel.textColor = topBannerPrimaryTextColor ?? UIColor(hex: "#000000")
|
430
|
-
instructionsBanner.secondaryLabel.textColor = topBannerSecondaryTextColor ?? UIColor(hex: "#666666")
|
431
|
-
instructionsBanner.distanceLabel.textColor = topBannerDistanceTextColor ?? UIColor(hex: "#666666")
|
432
|
-
instructionsBanner.separatorView.backgroundColor = topBannerSeparatorColor ?? UIColor(hex: "#EEEEEE")
|
433
|
-
|
434
|
-
// 2. Information Stack
|
435
|
-
let informationStack = navigationView.informationStackView
|
436
|
-
informationStack.backgroundColor = informationStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
437
|
-
for view in informationStack.arrangedSubviews {
|
438
|
-
if let label = view as? UILabel {
|
439
|
-
label.textColor = informationStackTextColor ?? UIColor(hex: "#000000")
|
440
|
-
}
|
441
|
-
}
|
442
|
-
|
443
|
-
// 3. Bottom Banner
|
444
|
-
let bottomBanner = navigationView.bottomBannerView
|
445
|
-
bottomBanner.backgroundColor = bottomBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
446
|
-
bottomBanner.timeRemainingLabel.textColor = bottomBannerTimeRemainingTextColor ?? UIColor(hex: "#000000")
|
447
|
-
bottomBanner.distanceRemainingLabel.textColor = bottomBannerDistanceRemainingTextColor ?? UIColor(hex: "#666666")
|
448
|
-
bottomBanner.arrivalTimeLabel.textColor = bottomBannerArrivalTimeTextColor ?? UIColor(hex: "#666666")
|
449
|
-
|
450
|
-
// 4. Resume Button
|
451
|
-
let resumeButton = navigationView.resumeButton
|
452
|
-
resumeButton.backgroundColor = resumeButtonBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
453
|
-
resumeButton.setTitleColor(resumeButtonTextColor ?? UIColor(hex: "#000000"), for: .normal)
|
454
|
-
|
455
|
-
// 5. Speed Limit View
|
456
|
-
let speedLimitView = navigationView.speedLimitView
|
457
|
-
speedLimitView.backgroundColor = speedLimitBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
458
|
-
if let speedLabel = speedLimitView.valueLabel {
|
459
|
-
speedLabel.textColor = speedLimitTextColor ?? UIColor(hex: "#000000")
|
460
|
-
}
|
461
|
-
|
462
|
-
// 6. Floating Stack
|
463
|
-
let floatingStack = navigationView.floatingStackView
|
464
|
-
floatingStack.backgroundColor = floatingStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
465
|
-
for button in floatingStack.arrangedSubviews {
|
466
|
-
if let floatingButton = button as? UIButton {
|
467
|
-
floatingButton.backgroundColor = floatingButtonsBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
468
|
-
}
|
469
|
-
}
|
470
|
-
|
471
|
-
// 7. Navigation Map
|
472
379
|
let navigationMapView = navigationViewController.navigationMapView
|
473
|
-
navigationMapView
|
380
|
+
navigationMapView!.puckType = .puck2D(.navigationDefault)
|
474
381
|
|
475
382
|
let style = currentMapStyle != nil ? StyleURI(rawValue: currentMapStyle!) : StyleURI.streets
|
476
|
-
navigationMapView
|
477
|
-
navigationMapView
|
478
|
-
do
|
479
|
-
try navigationMapView
|
383
|
+
navigationMapView!.mapView.mapboxMap.loadStyle(style!, completion: { _ in
|
384
|
+
navigationMapView!.localizeLabels(locale: self.currentLocale)
|
385
|
+
do{
|
386
|
+
try navigationMapView!.mapView.mapboxMap.localizeLabels(into: self.currentLocale)
|
480
387
|
} catch {}
|
481
388
|
})
|
389
|
+
|
482
390
|
|
483
|
-
|
484
|
-
|
485
|
-
navigationMapView.routeColor = routeColor
|
486
|
-
}
|
487
|
-
if let alternateColor = currentRouteAlternateColor {
|
488
|
-
navigationMapView.routeAlternateColor = alternateColor
|
489
|
-
}
|
490
|
-
if let casingColor = currentRouteCasingColor {
|
491
|
-
navigationMapView.routeCasingColor = casingColor
|
492
|
-
}
|
493
|
-
if let alternateCasingColor = currentRouteAlternateCasingColor {
|
494
|
-
navigationMapView.routeAlternateCasingColor = alternateCasingColor
|
495
|
-
}
|
496
|
-
if let traversedColor = currentTraversedRouteColor {
|
497
|
-
navigationMapView.traversedRouteColor = traversedColor
|
498
|
-
}
|
499
|
-
if let arrowColor = currentManeuverArrowColor {
|
500
|
-
navigationMapView.maneuverArrowColor = arrowColor
|
501
|
-
}
|
502
|
-
|
503
|
-
// 8. Way Name Label
|
504
|
-
let wayNameView = navigationView.wayNameView
|
505
|
-
wayNameView.backgroundColor = wayNameViewBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
506
|
-
wayNameView.valueLabel.textColor = wayNameViewTextColor ?? UIColor(hex: "#000000")
|
391
|
+
let cancelButton = navigationViewController.navigationView.bottomBannerContainerView.findViews(subclassOf: CancelButton.self)[0]
|
392
|
+
cancelButton.addTarget(self, action: #selector(cancelButtonClicked), for: .touchUpInside)
|
507
393
|
|
508
394
|
navigationViewController.delegate = self
|
509
395
|
addChild(navigationViewController)
|
@@ -515,8 +401,28 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
515
401
|
navigationViewController.view.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
|
516
402
|
navigationViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
|
517
403
|
])
|
518
|
-
|
404
|
+
didMove(toParent: self)
|
519
405
|
mapboxNavigation!.tripSession().startActiveGuidance(with: navigationRoutes, startLegIndex: 0)
|
406
|
+
|
407
|
+
// Apply custom colors if set
|
408
|
+
if let routeColor = currentRouteColor {
|
409
|
+
navigationMapView?.routeColor = routeColor
|
410
|
+
}
|
411
|
+
if let alternateColor = currentRouteAlternateColor {
|
412
|
+
navigationMapView?.routeAlternateColor = alternateColor
|
413
|
+
}
|
414
|
+
if let casingColor = currentRouteCasingColor {
|
415
|
+
navigationMapView?.routeCasingColor = casingColor
|
416
|
+
}
|
417
|
+
if let alternateCasingColor = currentRouteAlternateCasingColor {
|
418
|
+
navigationMapView?.routeAlternateCasingColor = alternateCasingColor
|
419
|
+
}
|
420
|
+
if let traversedColor = currentTraversedRouteColor {
|
421
|
+
navigationMapView?.traversedRouteColor = traversedColor
|
422
|
+
}
|
423
|
+
if let arrowColor = currentManeuverArrowColor {
|
424
|
+
navigationMapView?.maneuverArrowColor = arrowColor
|
425
|
+
}
|
520
426
|
}
|
521
427
|
}
|
522
428
|
extension ExpoMapboxNavigationViewController: NavigationViewControllerDelegate {
|
@@ -553,4 +459,4 @@ extension UIColor {
|
|
553
459
|
|
554
460
|
self.init(red: r, green: g, blue: b, alpha: 1.0)
|
555
461
|
}
|
556
|
-
}
|
462
|
+
}
|