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

Inform delegate when canceling through eorvc #1318

Merged
merged 3 commits into from
Apr 24, 2018
Merged

Conversation

frederoni
Copy link
Contributor

Dismissing a view controller only works if it was presented with a UINavigationViewController. By informing the delegate when the navigation is ended, we dismiss by default but also let the developer pop or replace the view controller by implementing NavigationViewController.mapViewControllerDidCancelNavigation(_:).

@JThramer

@@ -459,7 +459,7 @@ func defaultFeedbackHandlers(source: FeedbackSource = .user) -> (send: FeedbackV
endOfRoute.dismissHandler = { [weak self] (stars, comment) in
guard let rating = self?.rating(for: stars) else { return }
self?.routeController.setEndOfRoute(rating: rating, comment: comment)
self?.dismiss(animated: true, completion: nil)
self?.delegate?.mapViewControllerDidCancelNavigation(self!)
Copy link
Contributor Author

@frederoni frederoni Apr 20, 2018

Choose a reason for hiding this comment

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

Perhaps we should add a new …didEndNavigation() delegate method? /cc @JThramer

Copy link
Contributor

Choose a reason for hiding this comment

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

@frederoni instead of force unwrapping self, why not safely unwrap at the guard on line 460?

Copy link
Contributor

Choose a reason for hiding this comment

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

@frederoni agreed, It's time. Although what about something like didEndNavigation(cancelled: Bool)?

Copy link
Contributor Author

@frederoni frederoni Apr 24, 2018

Choose a reason for hiding this comment

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

The optionally chained self? and delegate? is evaluated before self! so this could arguably be considered a safe unwrap. I preferred this way because we'd still want the feedback and the delegate to trigger rather than getting stuck in the guard.

@frederoni frederoni merged commit ce9ae2f into master Apr 24, 2018
@frederoni frederoni deleted the fred/fix-exit-eorvc branch April 24, 2018 16:18
@1ec5 1ec5 added the backwards incompatible changes that break backwards compatibility of public API label Dec 18, 2018
@1ec5 1ec5 added this to the v0.17.0 milestone Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards incompatible changes that break backwards compatibility of public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants