@complexify/expo-mapbox-navigation 1.0.6 → 1.0.7
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.
@@ -421,85 +421,46 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
421
421
|
navigationOptions: navigationOptions
|
422
422
|
)
|
423
423
|
|
424
|
-
|
425
|
-
topBanner.instructionsBannerView.secondaryLabel.textColor = topBannerSecondaryTextColor ?? UIColor(hex: "#666666")
|
426
|
-
topBanner.instructionsBannerView.distanceLabel.textColor = topBannerDistanceTextColor ?? UIColor(hex: "#666666")
|
427
|
-
topBanner.instructionsBannerView.separatorView.backgroundColor = topBannerSeparatorColor ?? UIColor(hex: "#EEEEEE")
|
428
|
-
|
429
|
-
bottomBanner.timeRemainingLabel.textColor = bottomBannerTimeRemainingTextColor ?? UIColor(hex: "#000000")
|
430
|
-
bottomBanner.distanceRemainingLabel.textColor = bottomBannerDistanceRemainingTextColor ?? UIColor(hex: "#666666")
|
431
|
-
bottomBanner.arrivalTimeLabel.textColor = bottomBannerArrivalTimeTextColor ?? UIColor(hex: "#666666")
|
432
|
-
|
433
|
-
let navigationMapView = navigationViewController.navigationMapView
|
434
|
-
navigationMapView.puckType = .puck2D(.navigationDefault)
|
435
|
-
|
436
|
-
let style = currentMapStyle != nil ? StyleURI(rawValue: currentMapStyle!) : StyleURI.streets
|
437
|
-
navigationMapView!.mapView.mapboxMap.loadStyle(style!, completion: { _ in
|
438
|
-
navigationMapView!.localizeLabels(locale: self.currentLocale)
|
439
|
-
do{
|
440
|
-
try navigationMapView!.mapView.mapboxMap.localizeLabels(into: self.currentLocale)
|
441
|
-
} catch {}
|
442
|
-
})
|
443
|
-
|
444
|
-
let cancelButton = navigationView.bottomBannerContainerView.findViews(subclassOf: CancelButton.self).first
|
445
|
-
cancelButton?.addTarget(self, action: #selector(cancelButtonClicked), for: UIControl.Event.touchUpInside)
|
424
|
+
let navigationView = navigationViewController.navigationView
|
446
425
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
navigationViewController.view.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
|
455
|
-
navigationViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
|
456
|
-
])
|
457
|
-
navigationViewController.didMove(toParent: self)
|
458
|
-
mapboxNavigation!.tripSession().startActiveGuidance(with: navigationRoutes, startLegIndex: 0)
|
459
|
-
|
460
|
-
// Apply custom colors if set
|
461
|
-
if let routeColor = currentRouteColor {
|
462
|
-
navigationMapView?.routeColor = routeColor
|
463
|
-
}
|
464
|
-
if let alternateColor = currentRouteAlternateColor {
|
465
|
-
navigationMapView?.routeAlternateColor = alternateColor
|
466
|
-
}
|
467
|
-
if let casingColor = currentRouteCasingColor {
|
468
|
-
navigationMapView?.routeCasingColor = casingColor
|
469
|
-
}
|
470
|
-
if let alternateCasingColor = currentRouteAlternateCasingColor {
|
471
|
-
navigationMapView?.routeAlternateCasingColor = alternateCasingColor
|
472
|
-
}
|
473
|
-
if let traversedColor = currentTraversedRouteColor {
|
474
|
-
navigationMapView?.traversedRouteColor = traversedColor
|
475
|
-
}
|
476
|
-
if let arrowColor = currentManeuverArrowColor {
|
477
|
-
navigationMapView?.maneuverArrowColor = arrowColor
|
478
|
-
}
|
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")
|
479
433
|
|
480
434
|
// 2. Information Stack
|
481
|
-
let
|
482
|
-
|
483
|
-
for view in
|
435
|
+
let informationStack = navigationView.informationStackView
|
436
|
+
informationStack.backgroundColor = informationStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
437
|
+
for view in informationStack.arrangedSubviews {
|
484
438
|
if let label = view as? UILabel {
|
485
439
|
label.textColor = informationStackTextColor ?? UIColor(hex: "#000000")
|
486
440
|
}
|
487
441
|
}
|
488
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
|
+
|
489
450
|
// 4. Resume Button
|
490
|
-
let resumeButton =
|
451
|
+
let resumeButton = navigationView.resumeButton
|
491
452
|
resumeButton.backgroundColor = resumeButtonBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
492
|
-
resumeButton.setTitleColor(resumeButtonTextColor ?? UIColor(hex: "#000000"), for:
|
453
|
+
resumeButton.setTitleColor(resumeButtonTextColor ?? UIColor(hex: "#000000"), for: .normal)
|
493
454
|
|
494
455
|
// 5. Speed Limit View
|
495
|
-
let speedLimitView =
|
456
|
+
let speedLimitView = navigationView.speedLimitView
|
496
457
|
speedLimitView.backgroundColor = speedLimitBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
497
|
-
if let speedLabel = speedLimitView.
|
458
|
+
if let speedLabel = speedLimitView.valueLabel {
|
498
459
|
speedLabel.textColor = speedLimitTextColor ?? UIColor(hex: "#000000")
|
499
460
|
}
|
500
461
|
|
501
462
|
// 6. Floating Stack
|
502
|
-
let floatingStack =
|
463
|
+
let floatingStack = navigationView.floatingStackView
|
503
464
|
floatingStack.backgroundColor = floatingStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
504
465
|
for button in floatingStack.arrangedSubviews {
|
505
466
|
if let floatingButton = button as? UIButton {
|
@@ -507,10 +468,55 @@ class ExpoMapboxNavigationViewController: UIViewController {
|
|
507
468
|
}
|
508
469
|
}
|
509
470
|
|
471
|
+
// 7. Navigation Map
|
472
|
+
let navigationMapView = navigationViewController.navigationMapView
|
473
|
+
navigationMapView.puckType = .puck2D(.navigationDefault)
|
474
|
+
|
475
|
+
let style = currentMapStyle != nil ? StyleURI(rawValue: currentMapStyle!) : StyleURI.streets
|
476
|
+
navigationMapView.mapView.mapboxMap.loadStyle(style!, completion: { _ in
|
477
|
+
navigationMapView.localizeLabels(locale: self.currentLocale)
|
478
|
+
do {
|
479
|
+
try navigationMapView.mapView.mapboxMap.localizeLabels(into: self.currentLocale)
|
480
|
+
} catch {}
|
481
|
+
})
|
482
|
+
|
483
|
+
// Apply map colors
|
484
|
+
if let routeColor = currentRouteColor {
|
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
|
+
|
510
503
|
// 8. Way Name Label
|
511
|
-
let wayNameView =
|
504
|
+
let wayNameView = navigationView.wayNameView
|
512
505
|
wayNameView.backgroundColor = wayNameViewBackgroundColor ?? UIColor(hex: "#FFFFFF")
|
513
|
-
wayNameView.
|
506
|
+
wayNameView.valueLabel.textColor = wayNameViewTextColor ?? UIColor(hex: "#000000")
|
507
|
+
|
508
|
+
navigationViewController.delegate = self
|
509
|
+
addChild(navigationViewController)
|
510
|
+
view.addSubview(navigationViewController.view)
|
511
|
+
navigationViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
512
|
+
NSLayoutConstraint.activate([
|
513
|
+
navigationViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
|
514
|
+
navigationViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
|
515
|
+
navigationViewController.view.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
|
516
|
+
navigationViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
|
517
|
+
])
|
518
|
+
navigationViewController.didMove(toParent: self)
|
519
|
+
mapboxNavigation!.tripSession().startActiveGuidance(with: navigationRoutes, startLegIndex: 0)
|
514
520
|
}
|
515
521
|
}
|
516
522
|
extension ExpoMapboxNavigationViewController: NavigationViewControllerDelegate {
|