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

Refactoring appearance logic out of RMVC and into Views #993

Closed
wants to merge 4 commits into from

Conversation

JThramer
Copy link
Contributor

@JThramer JThramer commented Jan 9, 2018

This PR concerns #994, where it is desired to refactor view-appearance logic out of the RMVC and into the appropriate views themselves. This makes things a bit more lonely coupled and easier to work with in a piecemeal fashion.

To-Do:

  • InstructionsBannerView
  • NextBannerView
  • BottomBannerView? (already pretty well-encapsulated)

Phase 2 To-Do:

  • Create TopBannerViewController
  • Plug it in to RMVC
  • Investigate "seconds" ambiguity
  • Make sure you remove all shims (such as tooFar)

/cc @bsudekum @1ec5 @frederoni @ericrwolfe

@bsudekum
Copy link
Contributor

bsudekum commented Jan 9, 2018

@JThramer feel free to break your todo list out into 3 different PRs.

@JThramer
Copy link
Contributor Author

JThramer commented Jan 9, 2018

Turned out to be unnecessary @bsudekum. I wasn't able to make as much of an impact on NextBannerView as I would have liked, due to there being a bunch of logic rules around whether-or-not the Next banner should show (are the "lanes" showing? etc)... We may want to consider breaking everything in the "top" out into it's own stack-view that could make those determinations itself, but that seems like a big lift for this PR, especially considering #981 is still in-flight.

@@ -71,6 +71,17 @@ open class BaseInstructionsBannerView: UIControl {
delegate?.didTapInstructionsBanner(self)
}

func update(progress: RouteLegProgress, location: CLLocation, secondsRemaining: TimeInterval) {
Copy link
Contributor

Choose a reason for hiding this comment

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

location and secondsRemaining are unused, so setRouteProgress(_:) would suffice as the method name.

@@ -70,4 +71,9 @@ open class NextBannerView: UIView {
instructionLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: -16).isActive = true
}

func update(step: RouteStep, instruction: VisualInstruction) {
maneuverView.step = step
instructionLabel.instruction = instruction.primaryTextComponents
Copy link
Contributor

Choose a reason for hiding this comment

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

An update(list:of:properties:to:update:) method is still a pretty raw wrapper on the previous approach of setting all the properties directly and individually. This is an opportunity for us to think about when RouteMapViewController updates these properties and why. That’ll naturally lead us to a more descriptive name for the method, so we don’t inadvertently call or neglect to call it in the future.

In this case, I noticed that InstructionsBannerView has separate methods for updating the step (as part of setting the route progress) and setting the instruction; why not follow the same pattern for NextBannerView?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, noting that maneuverView.step is used for deciding upon the which maneuver arrow to draw.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, a developer could just give us a RouteProgress, and we'd be able to draw the correct UI for them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. How about making as many of these classes as possible maintain a single RouteProgress-typed property? Each setter would take care of extracting the relevant information from that RouteProgress object. We could create a new protocol for classes that track state via a RouteProgress-typed property.

Copy link
Contributor

Choose a reason for hiding this comment

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

Come to think of it, we could have each of these views independently observe routeControllerProgressDidChange notifications. That reduces the need for a controller that manually updates its views.

@1ec5 1ec5 mentioned this pull request Jan 11, 2018
2 tasks
@JThramer
Copy link
Contributor Author

Status update: Yesterday it was agreed among members of @mapbox/navigation-ios that the views associated with the "Top banner" should be extracted into their own containing class to take this concept even further. I am doing this by creating a TopBannerViewController and associated XIB.


//update lanes
if let upComingStep = progress.currentLegProgress?.upComingStep, !progress.currentLegProgress.userHasArrivedAtWaypoint {
updateLaneViews(step: upComingStep, durationRemaining: progress.currentLegProgress.currentStepProgress.durationRemaining)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Investigate why one view uses the secondsRemaining argument and another view seems to pull the same value(?) out of RouteProgress.

@bsudekum bsudekum added this to the v0.13.0 milestone Jan 12, 2018
@bsudekum bsudekum modified the milestones: v0.13.0, v0.14.0 Jan 19, 2018
@JThramer JThramer added the blocked Blocked by dependency or unclarity. label Jan 23, 2018
@JThramer
Copy link
Contributor Author

This PR has been blocked by a major architectural change (#981) introduced upstream. I have started work on resolving this blocker, this effort is being tracked by #1062.

@JThramer
Copy link
Contributor Author

JThramer commented Mar 8, 2018

This is ultra-stale, and good progress was made in-parallel with the issue that this PR was meant to address. Going to close it.

@JThramer JThramer closed this Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by dependency or unclarity. ⚠️ DO NOT MERGE PR should not be merged!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants