@complexify/expo-mapbox-navigation 1.0.3 → 1.0.4

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.
@@ -397,48 +397,49 @@ class ExpoMapboxNavigationViewController: UIViewController {
397
397
 
398
398
  let navigationViewController = NavigationViewController(
399
399
  navigationRoutes: navigationRoutes,
400
- navigationOptions: navigationOptions
400
+ navigationOptions: NavigationOptions(
401
+ styles: [.dayStyle],
402
+ navigationMapView: nil,
403
+ voiceController: ExpoMapboxNavigationViewController.navigationProvider.routeVoiceController,
404
+ eventsManager: ExpoMapboxNavigationViewController.navigationProvider.eventsManager()
405
+ )
401
406
  )
402
407
 
408
+ let navigationView = navigationViewController.navigationView
409
+
403
410
  // Customize top banner colors
404
- let topBanner = navigationViewController.navigationView.topBannerContainerView
411
+ let topBanner = navigationView.topBannerContainerView
405
412
  topBanner.backgroundColor = topBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
406
- let instructionsView = navigationViewController.navigationView.instructionsBannerView
413
+ let instructionsView = navigationView.instructionsBannerView
407
414
  instructionsView.primaryLabel.textColor = topBannerPrimaryTextColor ?? UIColor(hex: "#000000")
408
415
  instructionsView.secondaryLabel.textColor = topBannerSecondaryTextColor ?? UIColor(hex: "#666666")
409
416
  instructionsView.distanceLabel.textColor = topBannerDistanceTextColor ?? UIColor(hex: "#666666")
410
417
  instructionsView.separatorView.backgroundColor = topBannerSeparatorColor ?? UIColor(hex: "#EEEEEE")
411
418
 
412
419
  // Customize bottom banner colors
413
- let bottomBanner = navigationViewController.navigationView.bottomBannerContainerView
420
+ let bottomBanner = navigationView.bottomBannerContainerView
414
421
  bottomBanner.backgroundColor = bottomBannerBackgroundColor ?? UIColor(hex: "#FFFFFF")
415
- let bottomView = navigationViewController.navigationView.bottomBannerView
422
+ let bottomView = navigationView.bottomBannerView
416
423
  bottomView.timeRemainingLabel.textColor = bottomBannerTimeRemainingTextColor ?? UIColor(hex: "#000000")
417
424
  bottomView.distanceRemainingLabel.textColor = bottomBannerDistanceRemainingTextColor ?? UIColor(hex: "#666666")
418
425
  bottomView.arrivalTimeLabel.textColor = bottomBannerArrivalTimeTextColor ?? UIColor(hex: "#666666")
419
426
 
420
- let navigationOptions = NavigationOptions(
421
- mapboxNavigation: self.mapboxNavigation!,
422
- voiceController: ExpoMapboxNavigationViewController.navigationProvider.routeVoiceController,
423
- eventsManager: ExpoMapboxNavigationViewController.navigationProvider.eventsManager(),
424
- topBanner: topBanner,
425
- bottomBanner: bottomBanner
426
- )
427
-
428
- let navigationMapView = navigationViewController.navigationMapView
429
- navigationMapView!.puckType = .puck2D(.navigationDefault)
430
-
431
- let style = currentMapStyle != nil ? StyleURI(rawValue: currentMapStyle!) : StyleURI.streets
432
- navigationMapView!.mapView.mapboxMap.loadStyle(style!, completion: { _ in
433
- navigationMapView!.localizeLabels(locale: self.currentLocale)
434
- do{
435
- try navigationMapView!.mapView.mapboxMap.localizeLabels(into: self.currentLocale)
436
- } catch {}
437
- })
438
-
427
+ let navigationMapView = navigationView.navigationMapView
428
+ navigationMapView?.puckConfiguration = .puck2D()
429
+
430
+ if let style = currentMapStyle {
431
+ navigationMapView?.mapView.mapboxMap.loadStyle(StyleURI(rawValue: style)) { _ in
432
+ navigationMapView?.localizeLabels(locale: self.currentLocale)
433
+ do {
434
+ try navigationMapView?.mapView.mapboxMap.localizeLabels(into: self.currentLocale)
435
+ } catch {
436
+ print("Failed to localize map labels: \(error)")
437
+ }
438
+ }
439
+ }
439
440
 
440
- let cancelButton = navigationViewController.navigationView.bottomBannerContainerView.findViews(subclassOf: CancelButton.self)[0]
441
- cancelButton.addTarget(self, action: #selector(cancelButtonClicked), for: .touchUpInside)
441
+ let cancelButton = navigationView.bottomBannerContainerView.findViews(subclassOf: CancelButton.self).first
442
+ cancelButton?.addTarget(self, action: #selector(cancelButtonClicked), for: UIControl.Event.touchUpInside)
442
443
 
443
444
  navigationViewController.delegate = self
444
445
  addChild(navigationViewController)
@@ -450,9 +451,9 @@ class ExpoMapboxNavigationViewController: UIViewController {
450
451
  navigationViewController.view.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
451
452
  navigationViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
452
453
  ])
453
- didMove(toParent: self)
454
+ navigationViewController.didMove(toParent: self)
454
455
  mapboxNavigation!.tripSession().startActiveGuidance(with: navigationRoutes, startLegIndex: 0)
455
-
456
+
456
457
  // Apply custom colors if set
457
458
  if let routeColor = currentRouteColor {
458
459
  navigationMapView?.routeColor = routeColor
@@ -474,7 +475,7 @@ class ExpoMapboxNavigationViewController: UIViewController {
474
475
  }
475
476
 
476
477
  // 2. Information Stack
477
- let infoStack = navigationViewController.navigationView.informationStackView
478
+ let infoStack = navigationView.informationStackView
478
479
  infoStack.backgroundColor = informationStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
479
480
  for view in infoStack.arrangedSubviews {
480
481
  if let label = view as? UILabel {
@@ -483,19 +484,19 @@ class ExpoMapboxNavigationViewController: UIViewController {
483
484
  }
484
485
 
485
486
  // 4. Resume Button
486
- let resumeButton = navigationViewController.navigationView.resumeButton
487
+ let resumeButton = navigationView.resumeButton
487
488
  resumeButton.backgroundColor = resumeButtonBackgroundColor ?? UIColor(hex: "#FFFFFF")
488
- resumeButton.setTitleColor(resumeButtonTextColor ?? UIColor(hex: "#000000"), for: .normal)
489
+ resumeButton.setTitleColor(resumeButtonTextColor ?? UIColor(hex: "#000000"), for: UIControl.State.normal)
489
490
 
490
491
  // 5. Speed Limit View
491
- let speedLimitView = navigationViewController.navigationView.speedLimitView
492
+ let speedLimitView = navigationView.speedLimitView
492
493
  speedLimitView.backgroundColor = speedLimitBackgroundColor ?? UIColor(hex: "#FFFFFF")
493
494
  if let speedLabel = speedLimitView.subviews.first as? UILabel {
494
495
  speedLabel.textColor = speedLimitTextColor ?? UIColor(hex: "#000000")
495
496
  }
496
497
 
497
498
  // 6. Floating Stack
498
- let floatingStack = navigationViewController.navigationView.floatingStackView
499
+ let floatingStack = navigationView.floatingStackView
499
500
  floatingStack.backgroundColor = floatingStackBackgroundColor ?? UIColor(hex: "#FFFFFF")
500
501
  for button in floatingStack.arrangedSubviews {
501
502
  if let floatingButton = button as? UIButton {
@@ -504,7 +505,7 @@ class ExpoMapboxNavigationViewController: UIViewController {
504
505
  }
505
506
 
506
507
  // 8. Way Name Label
507
- let wayNameView = navigationViewController.navigationView.wayNameView
508
+ let wayNameView = navigationView.wayNameView
508
509
  wayNameView.backgroundColor = wayNameViewBackgroundColor ?? UIColor(hex: "#FFFFFF")
509
510
  wayNameView.label.textColor = wayNameViewTextColor ?? UIColor(hex: "#000000")
510
511
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@complexify/expo-mapbox-navigation",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Expo module for Mapbox's Navigation SDK",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",