Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated new directions API fields with the tertiary instruction and lane indications #1514

Merged
merged 57 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
352f70b
Updated cartfile file with then branch off Directions
vincethecoder Jun 21, 2018
c73c2a3
Changes made to accommodate the new API changes made in instructions …
vincethecoder Jun 21, 2018
f7e88a1
Filtered instructions for visual instruction components to facilitate…
vincethecoder Jun 21, 2018
61287aa
Updates Lane tests upon changes made in both lane and lanes views.
vincethecoder Jun 21, 2018
18be61f
Added a new test for another maneuver.
vincethecoder Jun 21, 2018
e3d839d
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jun 21, 2018
3a3fc0d
Updated podspec with directions then branch.
vincethecoder Jun 21, 2018
966ec8a
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jun 21, 2018
4f450cb
Updates to make routecontroller a class property. Removed the extra c…
vincethecoder Jun 22, 2018
409e2fa
Accommodates multiple lane banner instructions.
vincethecoder Jun 22, 2018
37018f8
[Update] Accommodates multiple lane banner instructions.
vincethecoder Jun 22, 2018
d8a0234
Updates to use visualInstructionIndex for visual instructions. Refact…
vincethecoder Jun 23, 2018
7892bff
Updated podspec to point to then branch.
vincethecoder Jun 25, 2018
fa9f08b
Updates to use a published MapboxDirections.swift dependency
vincethecoder Jun 25, 2018
fa1b32c
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jun 25, 2018
bff3b2f
Fixed issue where component was not being stored and looked up by sam…
vincethecoder Jun 25, 2018
560c8ba
Removed poorly composed unit test for cache key for exit label.
vincethecoder Jun 26, 2018
0bf61ed
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jun 26, 2018
6c8806e
Updated directions swift with latest changes.
vincethecoder Jun 26, 2018
f074bdd
WIP - added a placeholder to extract critical hash as a property on g…
vincethecoder Jun 26, 2018
2ebd13b
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jun 27, 2018
fb56051
Extracted the critical hash logic into static functions within the Ex…
vincethecoder Jun 27, 2018
6dc222c
Ensures both the lane view and then banner do not appear at the same …
vincethecoder Jun 28, 2018
67f0ab5
Added a note to indicate the purpose of the conditional statement for…
vincethecoder Jun 28, 2018
a1d71e4
1514 - Modifications to update lanes and next banner views to be hidd…
vincethecoder Jun 29, 2018
b00f946
Added a new visual instruction extension to detect instructions with …
vincethecoder Jul 2, 2018
bdebc16
[GH-1514] Fixed tautology. Deleted unwarranted function to update the…
vincethecoder Jul 2, 2018
abdb380
[GH-1514] - Updated next banner view to detect tertiary instructions …
vincethecoder Jul 2, 2018
8b13242
[GH-1514] - Updated lanes view to detect tertiary instructions with l…
vincethecoder Jul 2, 2018
8f36366
[GH-1514] - Modified instructions banner view signature to accept a n…
vincethecoder Jul 2, 2018
a241dbb
[GH-1514] - Modified to reflect the new (non-required) field, navigat…
vincethecoder Jul 2, 2018
5e3c16d
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jul 10, 2018
d555b9a
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jul 10, 2018
5dcc682
Merge branch 'master' into navigation/tertiary_instructions_lane_update
vincethecoder Jul 10, 2018
d755726
[GH-1532] - changes to update the lanes view and next banner view onl…
vincethecoder Jul 10, 2018
f08eb8e
[GH-1514] - points to the master branch of MapboxDirections.swift
vincethecoder Jul 10, 2018
63af724
[GH-1514] - points to the master branch of MapboxDirections.swift
vincethecoder Jul 11, 2018
1dd33da
[GH-1514] - Minor clean up after code refactor.
vincethecoder Jul 11, 2018
76cb369
[GH-1514] - No need to check for distance along step at this point.
vincethecoder Jul 11, 2018
a2c45ab
[GH-1514] - Refactored method signature.
vincethecoder Jul 11, 2018
6b1be17
[GH-1514] - Minor refactor
vincethecoder Jul 11, 2018
291ef60
[GH-1514] - Revised the signature for the updating the visual instruc…
vincethecoder Jul 11, 2018
6af14a8
[GH-1514] - Fixed broken test cases.
vincethecoder Jul 11, 2018
0e25212
[GH-1514] - Revised podspec to use MapboxDirections.swift's master br…
vincethecoder Jul 11, 2018
ba701e6
[GH-1514] - Updated file with the recently published version of Mapbo…
vincethecoder Jul 11, 2018
b6fdc38
Dont hardcode maneuver view to primary instruction
Jul 13, 2018
436889c
Merge branch 'master' into navigation/tertiary_instructions_lane_update
Jul 13, 2018
4ada71c
right
Jul 13, 2018
890f28f
[GH-1514] - Updates to change log to reflect changes to update instru…
vincethecoder Jul 15, 2018
feaf4d9
[GH-1514] - Exposed update(for:) functions to Objective-C. Minor refa…
vincethecoder Jul 16, 2018
13f2d71
Merge branch 'navigation/tertiary_instructions_lane_update' of github…
vincethecoder Jul 16, 2018
27f91a2
[GH-1514] - Updated function with objective-c friendly signature.
vincethecoder Jul 16, 2018
901e229
[GH-1514] - Updated the change log with a more concise description fo…
vincethecoder Jul 16, 2018
11902ca
[GH-1514] - Updated function with objective-c friendly signature.
vincethecoder Jul 16, 2018
6461783
[GH-1514] - Added documentation for the critical hash function for bo…
vincethecoder Jul 16, 2018
a117366
[GH-1514] - Added the missing documentation in the declared class pro…
vincethecoder Jul 16, 2018
00e211a
[GH-1514] - Minor refactor.
vincethecoder Jul 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 4.1
github "mapbox/MapboxDirections.swift" ~> 0.21.0
github "mapbox/MapboxDirections.swift" "then"
github "mapbox/turf-swift" ~> 0.2
github "mapbox/mapbox-events-ios" ~> 0.4
github "ceeK/Solar" ~> 2.1.0
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "4.1.0"
github "Quick/Nimble" "v7.1.2"
github "Quick/Quick" "v1.3.0"
github "ceeK/Solar" "2.1.0"
github "mapbox/MapboxDirections.swift" "v0.21.0"
github "mapbox/MapboxDirections.swift" "75818163ea4a6b611eb60746a948a298a2b20bab"
github "mapbox/mapbox-events-ios" "v0.4.1"
github "mapbox/mapbox-voice-swift" "v0.0.1"
github "mapbox/turf-swift" "v0.2.0"
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxCoreNavigation"

s.dependency "MapboxDirections.swift", "~> 0.21.0"
s.dependency "MapboxDirections.swift", :git => "https://github.com/mapbox/MapboxDirections.swift.git", :branch => "then"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, something like this does not work. Only published pods are able to be pulled in as deps here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

s.dependency "MapboxMobileEvents", "~> 0.4"
s.dependency "Turf", "~> 0.2"

Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation-Documentation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxNavigation"

s.dependency "MapboxDirections.swift", "~> 0.21.0"
s.dependency "MapboxDirections.swift", :git => "https://github.com/mapbox/MapboxDirections.swift.git", :branch => "then"
s.dependency "Mapbox-iOS-SDK", "~> 4.1"
s.dependency "MapboxMobileEvents", "~> 0.4"
s.dependency "Solar", "~> 2.1"
Expand Down
7 changes: 5 additions & 2 deletions MapboxNavigation/InstructionPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class InstructionPresenter {
typealias AttributedInstructionComponents = (components: [VisualInstructionComponent], attributedStrings: [NSAttributedString])

func attributedPairs(for instruction: VisualInstruction, dataSource: DataSource, imageRepository: ImageRepository, onImageDownload: @escaping ImageDownloadCompletion) -> AttributedInstructionComponents {
let components = instruction.textComponents
let components = instruction.components.compactMap { $0 as? VisualInstructionComponent }
var strings: [NSAttributedString] = []
var processedComponents: [VisualInstructionComponent] = []

Expand Down Expand Up @@ -166,7 +166,10 @@ class InstructionPresenter {
}

private func instructionHasDownloadedAllShields() -> Bool {
for component in instruction.textComponents {
let textComponents = instruction.components.compactMap { $0 as? VisualInstructionComponent }
guard !textComponents.isEmpty else { return false }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written more succinctly as:

guard let _ = instruction.components.contains(where: { $0 is VisualInstructionComponent }) else { return false }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guard instruction.components.contains(where: { $0 is VisualInstructionComponent }) else { return false } 😏

Copy link
Contributor Author

@vincethecoder vincethecoder Jul 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1ec5 Indeed that is succinct. However, for the purpose of this function scope, we need the variable and also an early exit if it's empty. Essentially, we need the contents of textComponent to iterate at this line

https://github.com/mapbox/mapbox-navigation-ios/pull/1514/files/13f2d71321b7d5e320721e611c983e6411a2d904#diff-af48d70309ee195e34cc5e6cc6b27caaR173


for component in textComponents {
guard let key = component.cacheKey else {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/InstructionsBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ open class BaseInstructionsBannerView: UIControl {
super.prepareForInterfaceBuilder()
maneuverView.isStart = true
let component = VisualInstructionComponent(type: .text, text: "Primary text label", imageURL: nil, abbreviation: nil, abbreviationPriority: NSNotFound)
let instruction = VisualInstruction(text: nil, maneuverType: .none, maneuverDirection: .none, textComponents: [component])
let instruction = VisualInstruction(text: nil, maneuverType: .none, maneuverDirection: .none, components: [component])
primaryLabel.instruction = instruction

distance = 100
Expand Down
10 changes: 10 additions & 0 deletions MapboxNavigation/LaneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ open class LaneView: UIView {
return isValid ? primaryColor : secondaryColor
}

static let defaultFrame: CGRect = CGRect(origin: .zero, size: 30.0)

convenience init(component: LaneIndicationComponent, direction: ManeuverDirection) {
self.init(frame: LaneView.defaultFrame)
backgroundColor = .clear
lane = Lane(indications: component.indications)
maneuverDirection = direction
isValid = component.isUsable
}

override open func draw(_ rect: CGRect) {
super.draw(rect)
if let lane = lane {
Expand Down
35 changes: 16 additions & 19 deletions MapboxNavigation/LanesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,27 @@ open class LanesView: UIView {
}

func update(for currentLegProgress: RouteLegProgress) {
guard let step = currentLegProgress.upComingStep else { return }
guard !currentLegProgress.userHasArrivedAtWaypoint else { return }
let durationRemaining = currentLegProgress.currentStepProgress.durationRemaining

clearLaneViews()

if let allLanes = step.intersections?.first?.approachLanes,
let usableLanes = step.intersections?.first?.usableApproachLanes,
durationRemaining < RouteControllerMediumAlertInterval {

for (i, lane) in allLanes.enumerated() {
let laneView = laneArrowView()
laneView.lane = lane
laneView.maneuverDirection = step.maneuverDirection
laneView.isValid = usableLanes.contains(i as Int)
stackView.addArrangedSubview(laneView)
}
let step = currentLegProgress.currentStep

guard durationRemaining < RouteControllerMediumAlertInterval,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsudekum do you think we should reduce the time threshold for tertiaryInstructions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not actually be doing any check like this now. The server should tell us exactly when and what to show.

!currentLegProgress.userHasArrivedAtWaypoint,
let firstInstruction = step.instructionsDisplayedAlongStep?.first,
let lanes: [LaneIndicationComponent] = firstInstruction.tertiaryInstruction?.components.compactMap({ component in
guard let lane = component as? LaneIndicationComponent else { return nil }
return lane
}),
!lanes.isEmpty
else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, move this up a line.

Copy link
Contributor Author

@vincethecoder vincethecoder Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsudekum what do you mean? Move it up a line... can you be more explicit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vincethecoder Move the else { one line up from line 88 to 87.

hide()
return
}

if stackView.arrangedSubviews.count > 0 {
show()
} else {
hide()
}
let subviews = lanes.map { LaneView(component: $0, direction: step.maneuverDirection) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to init new LaneView's? Shouldn't we already have these objects?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we are given the LaneIndicationComponents from the API.

stackView.addArrangedSubviews(subviews)
show()
}

public func show(animated: Bool = true) {
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/NextBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ open class NextBannerView: UIView {
super.prepareForInterfaceBuilder()
maneuverView.isEnd = true
let component = VisualInstructionComponent(type: .text, text: "Next step", imageURL: nil, abbreviation: nil, abbreviationPriority: NSNotFound)
let instruction = VisualInstruction(text: nil, maneuverType: .none, maneuverDirection: .none, textComponents: [component])
let instruction = VisualInstruction(text: nil, maneuverType: .none, maneuverDirection: .none, components: [component])
instructionLabel.instruction = instruction
}

Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigationTests/Fixtures/route-for-lane-testing.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"waypoints":[{"name":"16th Street Northwest","location":[-77.036548,38.901166]},{"name":"H Street Northwest","location":[-77.033792,38.900206]}],"routes":[{"legs":[{"steps":[{"intersections":[{"out":1,"in":0,"lanes":[{"valid":true,"indications":["right"]},{"valid":true,"indications":["right"]}],"entry":[false,true,false],"location":[-77.036554,38.900201],"bearings":[0,90,270]},{"out":1,"in":2,"entry":[true,true,false],"location":[-77.035129,38.900202],"bearings":[30,90,270]}],"geometry":{"coordinates":[[-77.036554,38.900201]],"type":"LineString"},"duration":41.3,"distance":239.1,"name":"H Street Northwest","weight":45.3,"mode":"driving","driving_side":"right","maneuver":{"bearing_after":88,"location":[-77.036554,38.900201],"type":"turn","bearing_before":180,"modifier":"left","instruction":"Turn left onto H Street Northwest"}},{"intersections":[{"out":1,"in":0,"lanes":[{"valid":true,"indications":["right"]},{"valid":true,"indications":["none"]}],"entry":[false,true,false],"location":[-77.036554,38.900201],"bearings":[0,90,270]},{"out":1,"in":2,"entry":[true,true,false],"location":[-77.035129,38.900202],"bearings":[30,90,270]}],"geometry":{"coordinates":[[-77.036554,38.900201]],"type":"LineString"},"duration":41.3,"distance":239.1,"name":"H Street Northwest","weight":45.3,"mode":"driving","driving_side":"right","maneuver":{"bearing_after":88,"location":[-77.036554,38.900201],"type":"turn","bearing_before":180,"modifier":"left","instruction":"Turn left onto H Street Northwest"}}],"weight":196.3,"distance":346.4,"summary":"16th Street Northwest, H Street Northwest","duration":177.5}],"weight_name":"routability","geometry":{"coordinates":[[-77.036548,38.901166],[-77.036551,38.900663],[-77.036554,38.900201],[-77.03643,38.900201],[-77.035534,38.900202],[-77.035388,38.900202],[-77.035276,38.900203],[-77.035204,38.900203],[-77.035129,38.900202],[-77.034948,38.900206],[-77.034433,38.900204],[-77.033792,38.900206]],"type":"LineString"},"weight":196.3,"distance":346.4,"duration":177.5}],"code":"Ok"}
{"routes":[{"geometry":"k~ymFd~|bOIdBcD~AmRh@gBZmDtAeBPiE?","legs":[{"summary":"Marshall Avenue, Central Parkway","weight":89.5,"duration":63.4,"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[275],"location":[-84.531074,39.132063]}],"driving_side":"right","geometry":"k~ymFd~|bOARCp@C^","mode":"driving","maneuver":{"bearing_after":275,"bearing_before":0,"location":[-84.531074,39.132063],"type":"depart","instruction":"Head west on Marshall Avenue"},"weight":24.7,"duration":10.9,"name":"Marshall Avenue","distance":44.1,"bannerInstructions":[{"distanceAlongGeometry":44.1,"primary":{"text":"Central Parkway","components":[{"text":"Central Parkway","type":"text","abbr":"Central Pky","abbr_priority":0}],"type":"turn","modifier":"right"},"secondary":{"text":"US 127 / I-75 Alt North / US 27 / US 52","components":[{"text":"US 127","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/us-127"},{"text":"/","type":"delimiter","delimiter":true},{"text":"I-75","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/i-75"},{"text":"Alt","type":"text"},{"text":"North","type":"text","abbr":"N","abbr_priority":0},{"text":"/","type":"delimiter","delimiter":true},{"text":"US 27","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/us-27"},{"text":"/","type":"delimiter","delimiter":true},{"text":"US 52","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/us-52"}],"type":"turn","modifier":"right"},"sub":{"text":"","components":[{"text":"","type":"lane","active":false,"directions":["straight"]},{"text":"","type":"lane","active":true,"directions":["right"]}]}}]},{"intersections":[{"lanes":[{"valid":false,"indications":["straight"]},{"valid":true,"indications":["right"]}],"out":3,"in":0,"entry":[false,false,true,true],"bearings":[90,150,270,330],"location":[-84.531582,39.132105]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[0,75,180],"location":[-84.532938,39.138135]}],"driving_side":"right","geometry":"u~ymFja}bOcAn@a@TOFKDMDSD[DuAH{NXaALe@L_@Po@^c@NSDe@L]DSBUB]Bg@@aDA","mode":"driving","maneuver":{"bearing_after":331,"bearing_before":275,"location":[-84.531582,39.132105],"modifier":"right","type":"turn","instruction":"Turn right onto Central Parkway (US 127)"},"ref":"US 127; I-75 Alt North; US 27; US 52","weight":64.8,"duration":52.5,"name":"Central Parkway (US 127; I-75 Alt North; US 27; US 52)","distance":780.5,"bannerInstructions":[{"distanceAlongGeometry":780.5,"primary":{"text":"You will arrive","components":[{"text":"You will arrive","type":"text"}],"type":"arrive","modifier":"straight"},"secondary":null,"sub":{"text":"","components":[{"text":"","type":"lane","active":true,"directions":["right"]},{"text":"","type":"lane","active":true,"directions":["right"]}]}},{"distanceAlongGeometry":148.7,"primary":{"text":"You have arrived","components":[{"text":"You have arrived","type":"text"}],"type":"arrive","modifier":"straight"},"secondary":null}]},{"intersections":[{"in":0,"entry":[true],"bearings":[180],"location":[-84.532934,39.138953]}],"driving_side":"right","geometry":"mi{mFxi}bO","mode":"driving","maneuver":{"bearing_after":0,"bearing_before":0,"location":[-84.532934,39.138953],"type":"arrive","instruction":"You have arrived at your destination"},"ref":"US 127; I-75 Alt North","weight":0,"duration":0,"name":"Central Parkway (US 127; I-75 Alt North)","distance":0,"bannerInstructions":[]}],"distance":824.6}],"weight_name":"routability","weight":89.5,"duration":63.4,"distance":824.6}],"waypoints":[{"name":"Marshall Avenue","location":[-84.531074,39.132063]},{"name":"Central Parkway","location":[-84.532934,39.138953]}],"code":"Ok"}
2 changes: 1 addition & 1 deletion MapboxNavigationTests/InstructionPresenterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class InstructionPresenterTests: XCTestCase {

let exitAttribute = VisualInstructionComponent(type: .exit, text: "Exit", imageURL: nil, abbreviation: nil, abbreviationPriority: 0)
let exitCodeAttribute = VisualInstructionComponent(type: .exitCode, text: "123A", imageURL: nil, abbreviation: nil, abbreviationPriority: 0)
let exitInstruction = VisualInstruction(text: nil, maneuverType: .takeOffRamp, maneuverDirection: .right, textComponents: [exitAttribute, exitCodeAttribute])
let exitInstruction = VisualInstruction(text: nil, maneuverType: .takeOffRamp, maneuverDirection: .right, components: [exitAttribute, exitCodeAttribute])

let label = InstructionLabel(frame: CGRect(origin: .zero, size:CGSize(width: 50, height: 50)))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ func makeVisualInstruction(_ maneuverType: ManeuverType = .arrive,
primaryInstruction: [VisualInstructionComponent],
secondaryInstruction: [VisualInstructionComponent]?) -> VisualInstructionBanner {

let primary = VisualInstruction(text: "Instruction", maneuverType: maneuverType, maneuverDirection: maneuverDirection, textComponents: primaryInstruction)
let primary = VisualInstruction(text: "Instruction", maneuverType: maneuverType, maneuverDirection: maneuverDirection, components: primaryInstruction)
var secondary: VisualInstruction? = nil
if let secondaryInstruction = secondaryInstruction {
secondary = VisualInstruction(text: "Instruction", maneuverType: maneuverType, maneuverDirection: maneuverDirection, textComponents: secondaryInstruction)
secondary = VisualInstruction(text: "Instruction", maneuverType: maneuverType, maneuverDirection: maneuverDirection, components: secondaryInstruction)
}

return VisualInstructionBanner(distanceAlongStep: 482.803, primaryInstruction: primary, secondaryInstruction: secondary, drivingSide: .right)
return VisualInstructionBanner(distanceAlongStep: 482.803, primaryInstruction: primary, secondaryInstruction: secondary, tertiaryInstruction: nil, drivingSide: .right)
}

class InstructionsBannerViewIntegrationTests: XCTestCase {
Expand Down Expand Up @@ -261,7 +261,7 @@ class InstructionsBannerViewIntegrationTests: XCTestCase {
let exitAttribute = VisualInstructionComponent(type: .exit, text: "Exit", imageURL: nil, abbreviation: nil, abbreviationPriority: 0)
let exitCodeAttribute = VisualInstructionComponent(type: .exitCode, text: "123A", imageURL: nil, abbreviation: nil, abbreviationPriority: 0)
let mainStreetString = VisualInstructionComponent(type: .text, text: "Main Street", imageURL: nil, abbreviation: "Main St", abbreviationPriority: 0)
let exitInstruction = VisualInstruction(text: nil, maneuverType: .takeOffRamp, maneuverDirection: .right, textComponents: [exitAttribute, exitCodeAttribute, mainStreetString])
let exitInstruction = VisualInstruction(text: nil, maneuverType: .takeOffRamp, maneuverDirection: .right, components: [exitAttribute, exitCodeAttribute, mainStreetString])

let label = InstructionLabel(frame: CGRect(origin: .zero, size:CGSize(width: 375, height: 100)))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class InstructionsBannerViewSnapshotTests: FBSnapshotTestCase {
let primaryThen = [
VisualInstructionComponent(type: .image, text: "I 280", imageURL: ShieldImage.i280.url, abbreviation: nil, abbreviationPriority: 0)
]
let primaryThenInstruction = VisualInstruction(text: nil, maneuverType: .none, maneuverDirection: .none, textComponents: primaryThen)
let primaryThenInstruction = VisualInstruction(text: nil, maneuverType: .none, maneuverDirection: .none, components: primaryThen)

nextBannerView.instructionLabel.instruction = primaryThenInstruction
nextBannerView.maneuverView.backgroundColor = .clear
Expand Down
17 changes: 10 additions & 7 deletions MapboxNavigationTests/LaneTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let directions = Directions(accessToken: bogusToken)

class LaneTests: FBSnapshotTestCase {

let route = Fixture.route(from: "route-for-lane-testing", waypoints: [Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.795042, longitude: -122.413165)), Waypoint(coordinate: CLLocationCoordinate2D(latitude: 37.7727, longitude: -122.433378))])
let route = Fixture.route(from: "route-for-lane-testing", waypoints: [Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.132063, longitude: -84.531074)), Waypoint(coordinate: CLLocationCoordinate2D(latitude: 39.138953, longitude: -84.532934))])

var steps: [RouteStep]!
var routeProgress: RouteProgress!
Expand All @@ -27,22 +27,25 @@ class LaneTests: FBSnapshotTestCase {
routeProgress = routeController.routeProgress
}

func assertLanes(step: RouteStep) {
func assertLanes(stepIndex: Array<RouteStep>.Index) {
let rect = CGRect(origin: .zero, size: .iPhone6Plus)
let navigationView = NavigationView(frame: rect)

navigationView.lanesView.update(for: routeProgress.currentLegProgress)
let routeController = RouteController(along: route, directions: directions)
routeController.advanceStepIndex(to: stepIndex)

navigationView.lanesView.update(for: routeController.routeProgress.currentLegProgress)
navigationView.lanesView.show(animated: false)

FBSnapshotVerifyView(navigationView.lanesView)
}

func testRightRight() {
assertLanes(step: steps[0])
func testStraightRight() {
assertLanes(stepIndex: 0)
}

func testRightNone() {
assertLanes(step: steps[1])
func testRightRight() {
assertLanes(stepIndex: 1)
}

func testSlightRight() {
Expand Down
4 changes: 2 additions & 2 deletions MapboxNavigationTests/ManeuverViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class ManeuverViewTests: FBSnapshotTestCase {

func maneuverInstruction(_ maneuverType: ManeuverType, _ maneuverDirection: ManeuverDirection, _ drivingSide: DrivingSide, _ degrees: CLLocationDegrees = 180) -> VisualInstructionBanner {
let component = VisualInstructionComponent(type: .delimiter, text: "", imageURL: nil, abbreviation: nil, abbreviationPriority: 0)
let primary = VisualInstruction(text: "", maneuverType: maneuverType, maneuverDirection: maneuverDirection, textComponents: [component], degrees: degrees)
return VisualInstructionBanner(distanceAlongStep: 0, primaryInstruction: primary, secondaryInstruction: nil, drivingSide: drivingSide)
let primary = VisualInstruction(text: "", maneuverType: maneuverType, maneuverDirection: maneuverDirection, components: [component], degrees: degrees)
return VisualInstructionBanner(distanceAlongStep: 0, primaryInstruction: primary, secondaryInstruction: nil, tertiaryInstruction: nil, drivingSide: drivingSide)
}

func testStraightRoundabout() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.