RouteResponse usage refactoring#3182
Conversation
|
This PR will clash with #3159 |
6ef05e4 to
8b8a416
Compare
There was a problem hiding this comment.
#2589 mentions:
A convenience initializer for MapboxNavigationService can wrap a Route in a RouteResponse, and a convenience initializer for NavigationViewController can wrap a Route in a RouteResponse and MapboxNavigationService.
Shall we add these convenience inits in this PR? Or what's the reason of not including them?
There was a problem hiding this comment.
My motivation not to add these was that all of the routes are supposed to be a result of API calling, and thus are always wrapped in RouteResponse. If, for some uncommon reason, user is creating a Route object differently, he should take care about correctly wrapping it, providing other required fields like options and identifier.
There was a problem hiding this comment.
Hi @Udumft ,
I have a use case in which I would prefer injecting a Route and am wondering if I now need to create a convenience init to support? It seems strange to move from a strong required Route, to a model of optionals?
Given our UI/ViewModels are intentionally separate from network models, exposing a network response object seemed heavy.
For additional context, in an upcoming feature change, we will be displaying multiple direction options. Which we will display, and begin navigation upon selection of a given route.
cc: @irtemed88
There was a problem hiding this comment.
Hi @Udumft ,
I was seeing if I could get your suggestion for how I could approach this? I took a first stab at the upgrade migration.
There was a problem hiding this comment.
I think this code was added to support Storyboards. @MaximAlien please review.
|
@1ec5 Your review is required since you created the original ticket. |
8b8a416 to
4ac8389
Compare
There was a problem hiding this comment.
I think the following should be done before merge:
- Verify that Storyboards integration isn't broken cc @MaximAlien
- Review from @1ec5
| public let routeResponse: RouteResponse | ||
| public let routeIndex: Int |
There was a problem hiding this comment.
Remember to add documentation comments about these properties and also the initializer below so that jazzy recognizes them.
| /// The `RouteResponse` containing the route along which the user is expected to travel, plus its index in this `RouteResponse`, if applicable. | ||
| /// | ||
| /// If you want to update the route use `Router.updateRoute(with:routeOptions:)` method. | ||
| var indexedRouteResponse: IndexedRouteResponse { get } |
There was a problem hiding this comment.
If it isn’t valid to set indexedRouteResponse directly, let’s make it publicly read-only.
There was a problem hiding this comment.
Meant to attach this approval to #3182 (review):
I think it would be quite beneficial to remove some redundancy in a subsequent PR, now that RouteResponse encapsulates more information, but this PR is mergeable as is once the few bits of missing documentation are added.
MaximAlien
left a comment
There was a problem hiding this comment.
This PR brings quite a lot of public API changes. We'll need to create another PR in https://github.com/mapbox/mapbox-navigation-ios-examples to address compilation issues.
| /** | ||
| A `Route` object constructed by [MapboxDirections](https://docs.mapbox.com/ios/api/directions/). | ||
| */ | ||
| public var route: Route? { |
There was a problem hiding this comment.
Why NavigationViewController.route, NavigationViewController.routeIndex and NavigationViewController.routeOptions were converted to get-only properties? At this point it breaks functionality, which allows to create NavigationViewController instance via UIStoryboard.
There was a problem hiding this comment.
These properties were made read-only to introduce single entry-point method for changing the route: updateRoute(with:routeOptions:). Not sure what to do with storyboard scenario...
There was a problem hiding this comment.
#3159 was primarily concerned with changing the route during a trip, but the storyboard code path is about setting up the trip in the first place, at a point when we’re not as concerned about the navigator getting only piecemeal input. Can we introduce something specific to storyboards, perhaps even with “forStoryboard” in the name?
There was a problem hiding this comment.
Would be good to have a special method which setups vc after view controller. This method will set appropriate private variables (could be even grouped in a struct) which will be read in the code which setups vc in storyboards case.
When I read this code I found it confusing why route variable has such strange get/set.
|
We'll have to also revise documentation after landing current PR: e.g. in https://docs.mapbox.com/ios/beta/navigation |
95c2db9 to
0849319
Compare
b0575c3 to
164a251
Compare
There was a problem hiding this comment.
Why do we need to perform check to see if view was really loaded? I recall that in previous implementation in #2974 it wasn't needed. Just want to make sure that this will not cause any side effects.
There was a problem hiding this comment.
This check is added since updating routeResponse, routeIndex or routeOptions will not have effect on the contents NavigationViewController if view is already loaded. In this case view - is the Navigation View, and these properties are only stored in NavigationViewController to initialize the NavigationView. So, this check lets user know if this update actually happened or not. Previous implementation did silent update of a local property, but that did not affect the NavigationView if it was already loaded.
There was a problem hiding this comment.
It'd be great to create a follow-up ticket to update documentation everywhere. In scope of this PR files like README.md and cover.md can be updated as they show how to use NavigationViewController.
There was a problem hiding this comment.
I missed that, thanks
…teResponse+RouteIndex. Updated Codebase, Tests, code docs.
…tifier usage from tests.
…uple to struct entity type.
…comments, improved method naming, removed obsolete parts.
…ed, Removed unnecessary usage of routeOptions from CPTrip, NavigationViewController convenience initializer refined.
… method for storyboard scenario. CHANGELOG updated
…ionViewController usage.
ab51a6d to
fae8fd7
Compare
MaximAlien
left a comment
There was a problem hiding this comment.
This PR changes so many public APIs that it's hard to see what can be wrong. On high level seems to look good to me. We should review all docs and update examples to make sure that there is not major regression and everything is up-to-date.
|
Ticket to update examples project : mapbox/mapbox-navigation-ios-examples/issues/135 |
Description
This PR replaces usage of
Route+ Route index in favor of it's originalRouteResponse. It also removes usage ofRoute.routeIdentifier, as this is a redundant property should be removed too.Implementation
Most of the changes is just a replacing of
IndexedRoutewithRouteResponse. But it also forced updating some related entities likeCPTrip.userInfo, removingRouteProgress.routeIndex or updatingSessionStatewith dedicatedrouteIdentifier`. There are many public API changes.