From 41c5c1b7f66e5a4c6545ced4ebe281d9b58123aa Mon Sep 17 00:00:00 2001 From: Maxim Makhun Date: Mon, 11 Apr 2022 14:51:34 -0700 Subject: [PATCH] Add `NavigationViewViewController` skeleton example. --- Navigation-Examples.xcodeproj/project.pbxproj | 13 ++++- Navigation-Examples/Constants.swift | 7 +++ .../Examples/Navigation-View.swift | 33 +++++++++++ Podfile | 4 +- Podfile.lock | 56 ++++++++++++------- 5 files changed, 89 insertions(+), 24 deletions(-) create mode 100644 Navigation-Examples/Examples/Navigation-View.swift diff --git a/Navigation-Examples.xcodeproj/project.pbxproj b/Navigation-Examples.xcodeproj/project.pbxproj index c87fd042..2de3e539 100644 --- a/Navigation-Examples.xcodeproj/project.pbxproj +++ b/Navigation-Examples.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 8A33629624E4844E0086C647 /* Building-Extrusion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A33629524E4844E0086C647 /* Building-Extrusion.swift */; }; 8A96379C2492B366008DEF2A /* Route-Deserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */; }; 8A96379D2492B366008DEF2A /* route.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A96379B2492B366008DEF2A /* route.json */; }; + 8AA038742804C1110007BD2D /* Navigation-View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AA038732804C1110007BD2D /* Navigation-View.swift */; }; 8AC9129D2494106100B6941E /* Route-Initialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC9129C2494106100B6941E /* Route-Initialization.swift */; }; 8AE033222628EDFF000E7145 /* Route-Lines-Styling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE033212628EDFF000E7145 /* Route-Lines-Styling.swift */; }; 8DF510741FEB08F70049DB9C /* Embedded-Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DF510731FEB08F70049DB9C /* Embedded-Navigation.swift */; }; @@ -70,6 +71,7 @@ 8A33629524E4844E0086C647 /* Building-Extrusion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Building-Extrusion.swift"; sourceTree = ""; }; 8A96379A2492B366008DEF2A /* Route-Deserialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Route-Deserialization.swift"; sourceTree = ""; }; 8A96379B2492B366008DEF2A /* route.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = route.json; sourceTree = ""; }; + 8AA038732804C1110007BD2D /* Navigation-View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Navigation-View.swift"; sourceTree = ""; }; 8AC9129C2494106100B6941E /* Route-Initialization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Route-Initialization.swift"; sourceTree = ""; }; 8AD2F2132489B5C800F81353 /* apply-mapbox-access-token.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "apply-mapbox-access-token.sh"; sourceTree = ""; }; 8AE033212628EDFF000E7145 /* Route-Lines-Styling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Route-Lines-Styling.swift"; sourceTree = ""; }; @@ -263,6 +265,7 @@ 11DC36F126161DAF0042CD4A /* Location-Snapping.swift */, 11B6E81626176F3600872E4D /* Upcoming-Intersection.swift */, B4F805ED26791AD900D5F1C8 /* Custom-User-Location.swift */, + 8AA038732804C1110007BD2D /* Navigation-View.swift */, 8AFBF217265E851700468551 /* CustomSegue */, 8A2DFA52261650600034A87E /* NavigationCamera */, 8AC9129E2494118400B6941E /* TestData */, @@ -279,7 +282,6 @@ 4EF74F60792B221A1A61A3CE /* Pods-Navigation-Examples.debug.xcconfig */, A8BC0BE26AF9683D3B034741 /* Pods-Navigation-Examples.release.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -451,7 +453,8 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Navigation-Examples/Pods-Navigation-Examples-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework", - "${BUILT_PRODUCTS_DIR}/MapboxDirections/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxDirections-pre/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxGeocoder.swift/MapboxGeocoder.framework", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework", "${BUILT_PRODUCTS_DIR}/MapboxSpeech/MapboxSpeech.framework", @@ -467,6 +470,7 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxDirections.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxGeocoder.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework", @@ -565,7 +569,8 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-DocsCode/Pods-DocsCode-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxCoreNavigation/MapboxCoreNavigation.framework", - "${BUILT_PRODUCTS_DIR}/MapboxDirections/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxDirections-pre/MapboxDirections.framework", + "${BUILT_PRODUCTS_DIR}/MapboxGeocoder.swift/MapboxGeocoder.framework", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework", "${BUILT_PRODUCTS_DIR}/MapboxSpeech/MapboxSpeech.framework", @@ -581,6 +586,7 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxDirections.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxGeocoder.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework", @@ -628,6 +634,7 @@ 2B521D502409240E00984CF8 /* CustomBottomBannerView.swift in Sources */, B480E428261E4C4600C16FA0 /* Route-Alerts.swift in Sources */, C58FB8771FE98B0E00C4B491 /* Waypoint-Arrival-Screen.swift in Sources */, + 8AA038742804C1110007BD2D /* Navigation-View.swift in Sources */, C35F1E4D2656967E00EC54CD /* Offline-Regions.swift in Sources */, C5F130A61FEB2D7800463E86 /* Advanced.swift in Sources */, C58FB86C1FE89CEC00C4B491 /* ExampleContainerViewController.swift in Sources */, diff --git a/Navigation-Examples/Constants.swift b/Navigation-Examples/Constants.swift index 173fa958..3f615ab8 100644 --- a/Navigation-Examples/Constants.swift +++ b/Navigation-Examples/Constants.swift @@ -174,5 +174,12 @@ let listOfExamples: [NamedController] = [ controller: OfflineRegionsViewController.self, storyboard: nil, pushExampleToViewController: true + ), + ( + name: "Navigation View", + description: "Demonstrates how to use NavigationView.", + controller: NavigationViewViewController.self, + storyboard: nil, + pushExampleToViewController: true ) ] diff --git a/Navigation-Examples/Examples/Navigation-View.swift b/Navigation-Examples/Examples/Navigation-View.swift new file mode 100644 index 00000000..845e8ff5 --- /dev/null +++ b/Navigation-Examples/Examples/Navigation-View.swift @@ -0,0 +1,33 @@ +import UIKit +import MapboxCoreNavigation +import MapboxNavigation +import MapboxDirections + +class NavigationViewViewController: UIViewController { + + var navigationView: NavigationView! + + override func viewDidLoad() { + super.viewDidLoad() + + navigationView = NavigationView(frame: view.bounds) + navigationView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + + let navigationViewportDataSource = NavigationViewportDataSource(navigationView.navigationMapView.mapView, + viewportDataSourceType: .raw) + navigationView.navigationMapView.navigationCamera.viewportDataSource = navigationViewportDataSource + navigationView.navigationMapView.navigationCamera.follow() + + view.addSubview(navigationView) + + navigationView.bottomBannerContainerView.isHidden = false + navigationView.bottomBannerContainerView.heightAnchor.constraint(equalToConstant: 150.0).isActive = true + navigationView.bottomBannerContainerView.backgroundColor = .white + navigationView.isBottomBannerContainerViewExpandable = true + navigationView.bottomBannerContainerViewOffset = 50.0 + + navigationView.topBannerContainerView.isHidden = false + navigationView.topBannerContainerView.heightAnchor.constraint(equalToConstant: 50.0).isActive = true + navigationView.topBannerContainerView.backgroundColor = .white + } +} diff --git a/Podfile b/Podfile index 7811a67f..c380d8af 100644 --- a/Podfile +++ b/Podfile @@ -3,8 +3,8 @@ install! 'cocoapods', :warn_for_unused_master_specs_repo => false platform :ios, '11.0' use_frameworks! -pod 'MapboxCoreNavigation', '~> 2.0' -pod 'MapboxNavigation', '~> 2.0' +pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/1622-make-navigation-view-publicly-usable' +pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :branch => 'maxim/1622-make-navigation-view-publicly-usable' target 'Navigation-Examples' do end diff --git a/Podfile.lock b/Podfile.lock index ae181101..9ea472f8 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -2,65 +2,83 @@ PODS: - MapboxCommon (21.2.0) - MapboxCoreMaps (10.4.2): - MapboxCommon (~> 21.2) - - MapboxCoreNavigation (2.3.1): - - MapboxDirections (~> 2.3) + - MapboxCoreNavigation (2.4.0-rc.1): + - MapboxDirections-pre (= 2.4.0-rc.1) - MapboxMobileEvents (~> 1.0) - - MapboxNavigationNative (~> 88.0) - - MapboxDirections (2.3.0): + - MapboxNavigationNative (~> 94.0) + - MapboxDirections-pre (2.4.0-rc.1): - Polyline (~> 5.0) - Turf (~> 2.0) + - MapboxGeocoder.swift (0.14.0) - MapboxMaps (10.4.2): - MapboxCommon (= 21.2.0) - MapboxCoreMaps (= 10.4.2) - MapboxMobileEvents (= 1.0.7) - Turf (~> 2.0) - MapboxMobileEvents (1.0.7) - - MapboxNavigation (2.3.1): - - MapboxCoreNavigation (= 2.3.1) - - MapboxMaps (~> 10.3) + - MapboxNavigation (2.4.0-rc.1): + - MapboxCoreNavigation (= 2.4.0-rc.1) + - MapboxGeocoder.swift (~> 0.14) + - MapboxMaps (< 11.0.0, >= 10.4.1) - MapboxMobileEvents (~> 1.0) - MapboxSpeech (~> 2.0) - Solar-dev (~> 3.0) - - MapboxNavigationNative (88.0.0): - - MapboxCommon (~> 21.1) + - MapboxNavigationNative (94.0.0): + - MapboxCommon (~> 21.2) - MapboxSpeech (2.0.0) - Polyline (5.0.2) - Solar-dev (3.0.1) - Turf (2.3.0) DEPENDENCIES: - - MapboxCoreNavigation (~> 2.0) - - MapboxNavigation (~> 2.0) + - MapboxCoreNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/1622-make-navigation-view-publicly-usable`) + - MapboxNavigation (from `https://github.com/mapbox/mapbox-navigation-ios.git`, branch `maxim/1622-make-navigation-view-publicly-usable`) SPEC REPOS: trunk: - MapboxCommon - MapboxCoreMaps - - MapboxCoreNavigation - - MapboxDirections + - MapboxDirections-pre + - MapboxGeocoder.swift - MapboxMaps - MapboxMobileEvents - - MapboxNavigation - MapboxNavigationNative - MapboxSpeech - Polyline - Solar-dev - Turf +EXTERNAL SOURCES: + MapboxCoreNavigation: + :branch: maxim/1622-make-navigation-view-publicly-usable + :git: https://github.com/mapbox/mapbox-navigation-ios.git + MapboxNavigation: + :branch: maxim/1622-make-navigation-view-publicly-usable + :git: https://github.com/mapbox/mapbox-navigation-ios.git + +CHECKOUT OPTIONS: + MapboxCoreNavigation: + :commit: c9a22dd86c6e79ab6b1e069b24fa60d1f099926f + :git: https://github.com/mapbox/mapbox-navigation-ios.git + MapboxNavigation: + :commit: c9a22dd86c6e79ab6b1e069b24fa60d1f099926f + :git: https://github.com/mapbox/mapbox-navigation-ios.git + SPEC CHECKSUMS: MapboxCommon: eb826fdc45e8b77f87aca2519986d992fd4881b7 MapboxCoreMaps: 227b33943eb5b257fdebc56474007e214981f43d - MapboxCoreNavigation: 3ca55ca21aa8e19e1ea755d26b1047596e2791da - MapboxDirections: 305d743dbee1e0b49d6100a2b946b47cec18b42c + MapboxCoreNavigation: 7c4becf21080038075037c79fb3134b8dd2726e6 + MapboxDirections-pre: 8d80dba7d137332c0ca757f54afda55d9eb782d9 + MapboxGeocoder.swift: a288e92ec13fbd65bbdfd7c54c61b0e80d19e734 MapboxMaps: 7a613c740ceb4179e839727494e192371b237546 MapboxMobileEvents: f7f3e8daeb4b83688ae62a4172dce79169a97233 - MapboxNavigation: ce6fca5051bbc3f20025c883af160845534c939c - MapboxNavigationNative: 7c588083547b121cf154402560364059aa5271e9 + MapboxNavigation: 7bcb989524df5d481f4656020ba3266d1fb560bf + MapboxNavigationNative: 74b6bbc4d48ffef7e10217bb2e7f2fc452984f8d MapboxSpeech: e4ed02984444b6373374c72c369edaf045cc490c Polyline: fce41d72e1146c41c6d081f7656827226f643dff Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 Turf: d8d52444483c968cf2d65b8b54640f8faf4dda03 -PODFILE CHECKSUM: ade747cd70b06f12dd4076e55177eb029b4813b0 +PODFILE CHECKSUM: 6c00ac7a36a0aba3136251462f071edc0a309ac4 COCOAPODS: 1.11.3