-
Notifications
You must be signed in to change notification settings - Fork 313
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
Integrated new directions API fields with the tertiary instruction and lane indications #1514
Conversation
MapboxNavigation/LanesView.swift
Outdated
} | ||
let step = currentLegProgress.currentStep | ||
|
||
guard durationRemaining < RouteControllerMediumAlertInterval, |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
# Conflicts: # Cartfile # MapboxNavigation-Documentation.podspec
MapboxCoreNavigation.podspec
Outdated
@@ -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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😞
…hecks to access the lanes.
MapboxNavigation/LanesView.swift
Outdated
stackView.addArrangedSubview(laneView) | ||
} | ||
let step = currentLegProgress.currentStep | ||
guard let firstInstruction = step.instructionsDisplayedAlongStep?.first, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there is more than one visual instruction on the step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need something like what we have for the currentSpokenInstruction but for visual instruction:
mapbox-navigation-ios/MapboxCoreNavigation/RouteProgress.swift
Lines 458 to 462 in 03b93ad
@objc public var currentSpokenInstruction: SpokenInstruction? { | |
guard let instructionsSpokenAlongStep = step.instructionsSpokenAlongStep else { return nil } | |
guard spokenInstructionIndex < instructionsSpokenAlongStep.count else { return nil } | |
return instructionsSpokenAlongStep[spokenInstructionIndex] | |
} |
We have all the pieces slightly above this computed variable to create currentVisualInstruction
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. That was an oversight. I will make the necessary changes to account for multiple visual instructions.
MapboxNavigation/LanesView.swift
Outdated
} else { | ||
hide() | ||
} | ||
let subviews = lanes.map { LaneView(component: $0, direction: step.maneuverDirection) } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see.
There was a problem hiding this comment.
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 LaneIndicationComponent
s from the API.
MapboxNavigation/LanesView.swift
Outdated
return | ||
} | ||
|
||
let components: [ComponentRepresentable] = instructionsDisplayedAlongStep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vincethecoder I'm still not seeing how we're finding the current visual instruction that should be displayed. If a step has 3 different tertiary instructions, how do we know which one to show?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsudekum smh - using the current spoken instruction index. Will update in a moment.
MapboxNavigation/LanesView.swift
Outdated
} else { | ||
hide() | ||
let currentInstruction = visualInstructions[spokenInstructionIndex] | ||
guard let lanes: [LaneIndicationComponent] = currentInstruction.tertiaryInstruction?.components.compactMap({ component in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to pull this out into an optional variable? I think it would make this guard easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
MapboxNavigation/LanesView.swift
Outdated
show() | ||
} else { | ||
hide() | ||
let currentInstruction = visualInstructions[spokenInstructionIndex] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we're still using spokenInstructionIndex
instead of the visual index.
…or to lane indications to enhance readability.
Waiting on dependent PR mapbox/mapbox-directions-swift#258 to be merged and published. Then this PR can pass the CI tests before it's merged into master. |
Started to test a few test cases, here is one that I'm looking at, request, visual link. However, it looks like something is stuck in an infinite loop: |
@bsudekum Upon changes made here, here is the new memory report. /cc @akitchen - decided to post the memory report, as the current function is not unit testable at the moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind capturing some current screenshots of the new UI in action? I’m particularly curious to see turn lanes with multiple usable lanes, “then” banners around arrival steps, and intermediate waypoint steps.
MapboxNavigation/ExitView.swift
Outdated
@@ -141,4 +141,10 @@ class ExitView: StylableView { | |||
let labelTrailing = trailingAnchor.constraint(equalTo: exitNumberLabel.trailingAnchor, constant: 8) | |||
return [imageLeading, imageLabelSpacing, labelTrailing] | |||
} | |||
|
|||
static func criticalHash(side: ExitSide, dataSource: DataSource) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this called “critical”? Is there something important about this method and similarly named methods that needs to be documented somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JThramer could you chime in to elucidate the essence of this refactor for ExitView
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still unclear on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes -- the reason why it's called criticalHash
is because the side:
and dataSource:
arguments contain critical values that affect the appearance of the ExitView
.
Considering that we're caching views by their rendered images, any property that affects how an ExitView
might appear needs to be accounted for in the cache key logic.
@@ -93,7 +93,7 @@ open class BaseInstructionsBannerView: UIControl { | |||
/** | |||
Updates the instructions banner info with a given `VisualInstructionBanner`. | |||
*/ | |||
public func updateInstruction(_ instruction: VisualInstructionBanner?) { | |||
public func update(for instruction: VisualInstructionBanner?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this method is public, we should mention in the changelog that it has been renamed. Also, it appears to be inaccessible to Objective-C.
MapboxNavigation/LanesView.swift
Outdated
if stackView.arrangedSubviews.count > 0 { | ||
show() | ||
} else { | ||
let laneIndications: [LaneIndicationComponent]? = tertiaryInstruction.components.compactMap({ component in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we can use trailing closure syntax here, since it isn’t confusing.
MapboxNavigation/LanesView.swift
Outdated
show() | ||
} else { | ||
let laneIndications: [LaneIndicationComponent]? = tertiaryInstruction.components.compactMap({ component in | ||
guard let lane = component as? LaneIndicationComponent else { return nil } |
There was a problem hiding this comment.
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 { component as? LaneIndicationComponent }
.
…ctor for mapping lane indication component in tertiary instruction.
….com:mapbox/mapbox-navigation-ios into navigation/tertiary_instructions_lane_update # Conflicts: # MapboxNavigation/NextBannerView.swift
@vincethecoder I think we're close, just need a few screenshots that @1ec5 is asking for and we can merge. |
CHANGELOG.md
Outdated
@@ -11,8 +11,9 @@ | |||
* Fixed an issue when selecting a step from the steps list, you could be brought to the wrong step. [#1524](https://github.com/mapbox/mapbox-navigation-ios/pull/1524/) | |||
* `StyleManager.locationFor(styleManager:)` now allows for an optional CLLocation to be returned. [#1523](https://github.com/mapbox/mapbox-navigation-ios/pull/1523) | |||
* NavigationViewController now uses the recommended way `.preferredStatusBarStyle` to set the style of the status bar. [#1535](https://github.com/mapbox/mapbox-navigation-ios/pull/1535) | |||
* Renamed `InstructionsBannerView.updateInstruction(_:)` to `InstructionsBannerView.update(for:)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to this PR from any new changeset entries, so that developers can get the full story from the PR description (which should be expanded to explain the API changes too).
CHANGELOG.md
Outdated
* Deleted `InstructionsBannerView.update(_:)`, which previously updated the banner instruction and the current distance. | ||
* This is replaced with `InstructionsBannerView.updateDistance(for:)` and `InstructionsBannerView.updateInstruction(_:)`. `InstructionsBannerView.updateDistance(for:)` should be called on every location update, while `InstructionsBannerView.updateInstruction(_:)` should be called when `NSNotification.Name. routeControllerDidPassVisualInstructionPoint` is emitted. | ||
* This is replaced with `InstructionsBannerView.updateDistance(for:)` and `InstructionsBannerView.update(for:)`. `InstructionsBannerView.updateDistance(for:)` should be called on every location update, while `InstructionsBannerView.update(for:)` should be called when `NSNotification.Name. routeControllerDidPassVisualInstructionPoint` is emitted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three points can potentially be combined into one with less repetition.
@@ -93,7 +93,7 @@ open class BaseInstructionsBannerView: UIControl { | |||
/** | |||
Updates the instructions banner info with a given `VisualInstructionBanner`. | |||
*/ | |||
public func updateInstruction(_ instruction: VisualInstructionBanner?) { | |||
@objc public func update(for instruction: VisualInstructionBanner?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Objective-C name of this method is -updateWithFor:
. It should be -updateForVisualInstructionBanner:
. (×3)
@@ -166,7 +167,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 } |
There was a problem hiding this comment.
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 }
There was a problem hiding this comment.
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 }
😏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…r the new instruction banner view revision.
MapboxNavigation/ExitView.swift
Outdated
@@ -141,4 +141,10 @@ class ExitView: StylableView { | |||
let labelTrailing = trailingAnchor.constraint(equalTo: exitNumberLabel.trailingAnchor, constant: 8) | |||
return [imageLeading, imageLabelSpacing, labelTrailing] | |||
} | |||
|
|||
static func criticalHash(side: ExitSide, dataSource: DataSource) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still unclear on this.
@@ -93,7 +93,8 @@ open class BaseInstructionsBannerView: UIControl { | |||
/** | |||
Updates the instructions banner info with a given `VisualInstructionBanner`. | |||
*/ | |||
public func updateInstruction(_ instruction: VisualInstructionBanner?) { | |||
@objc(updateForVisualInstruction:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be -updateForVisualInstructionBanner:
, given the parameter’s type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation, plus that “critical hash” thing in #1514 (comment), but otherwise good to go.
MapboxNavigation/LanesView.swift
Outdated
guard !currentLegProgress.userHasArrivedAtWaypoint else { return } | ||
let durationRemaining = currentLegProgress.currentStepProgress.durationRemaining | ||
|
||
@objc(updateForVisualInstructionBanner:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a documentation comment. (×3)
MapboxNavigation/ManeuverView.swift
Outdated
} | ||
} | ||
|
||
@objc public var drivingSide: DrivingSide = .right { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two properties are missing documentation comments.
…ther exit view and generic route shield.
…perties. Minor refactor.
MapboxNavigation/ExitView.swift
Outdated
@@ -141,4 +141,13 @@ class ExitView: StylableView { | |||
let labelTrailing = trailingAnchor.constraint(equalTo: exitNumberLabel.trailingAnchor, constant: 8) | |||
return [imageLeading, imageLabelSpacing, labelTrailing] | |||
} | |||
|
|||
/** | |||
`criticalHash(side:dataSource:)` generates the cache key needed to hold the `ExitView`'s `imageRepresentation` in the `ImageCache` caching engine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Possessive its'
is with the apostrophe at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Possessive its' is with the apostrophe at the end.
wait, what? where?
"its" is the possessive form (think "his")
"it's" is the contraction for "it is"
There is no such thing as its'
Perhaps you are thinking of the plural possessive? For example, "Our engineers' computers are too slow"
but I don't see how any of those apply here.
</grammar police>
These updates make sure we rely on the new directions
LaneIndicationComponents
class for lane information. This information is usually retrieved from the tertiary instruction -- which can either be aLaneIndicationComponent
orVisualInstructionComponent
. The instructions banner and integrated tests were also modified to reflect the new changes.Relies on mapbox/mapbox-directions-swift#258