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

Add MapView annotation callback when it gets / lost the focus #5167

Closed
wants to merge 1 commit into from
Closed

Add MapView annotation callback when it gets / lost the focus #5167

wants to merge 1 commit into from

Conversation

christoph-jerolimov
Copy link
Contributor

For my project it was required to receive a notification when the MapView annotation was deselected.

So I renamed onAnnotationPress to onAnnotationSelected and added a new method onAnnotationDeselected, this names was "inspired" by the underlaying iOS API. The old API was still called and marked as deprecated.

But maybe you have an idea for a better naming (onAnnotationFocus/-Blur?) -- or should a deselected call the press method again without an annotation (undefined)?

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @nicklockwood, @ultralame and @tadeuzagallo to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Jan 7, 2016
@nicklockwood
Copy link
Contributor

Might be better to add onFocus/onBlur events to the annotation object itself?

@christoph-jerolimov
Copy link
Contributor Author

Sounds good, will re-implement it.

@facebook-github-bot
Copy link
Contributor

@jerolimov updated the pull request.

@christoph-jerolimov
Copy link
Contributor Author

I have pushed an annotation-based onFocus and onBlur implementation like you suggested.

It is implement similar to onAnnotationDragStateChange and still calls the old, marked as deprecated onAnnotationPress method.

@christoph-jerolimov christoph-jerolimov changed the title Add MapView handler when annotation was deselected Add MapView handler when annotation gets / lost the focus Jan 7, 2016
@christoph-jerolimov christoph-jerolimov changed the title Add MapView handler when annotation gets / lost the focus Add MapView annotation callback when it gets / lost the focus Jan 7, 2016
alert('Annotation gets focus');
},
onBlur: () => {
alert('Annotation lost focus');

Choose a reason for hiding this comment

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

no-alert: Unexpected alert.

Choose a reason for hiding this comment

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

no-undef: "alert" is not defined.

@facebook-github-bot
Copy link
Contributor

@jerolimov updated the pull request.

@@ -17,6 +17,7 @@

var React = require('react-native');
var {
Alert,

Choose a reason for hiding this comment

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

property Alert Property not found in Object.create

@christoph-jerolimov
Copy link
Contributor Author

Just rebased on the current master..

@@ -309,7 +310,7 @@ exports.examples = [
rightCalloutView: (
<TouchableOpacity
onPress={() => {
alert('You Are Here');
Alert.alert('You Are Here');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't it recommended to use the Alert module instead of the polyfil?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I'm aware of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, your decision. Revert or keep? 😏

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll probably revert it when I merge this. But for future reference, it's better to avoid making unrelated changes in PRs anyway, even if they are uncontroversial, as it makes it harder to review.

If we do ever want to move away from using alert(), we can just do it once as a codemod across the whole project.

@nicklockwood
Copy link
Contributor

This looks fine, I think.

@nicklockwood
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1634599690135008/int_phab to review.

@facebook-github-bot
Copy link
Contributor

@jerolimov updated the pull request.

@facebook-github-bot
Copy link
Contributor

@jerolimov updated the pull request.

@christoph-jerolimov
Copy link
Contributor Author

@nicklockwood Sorry there was a mistakenly change on the RCTWebView in the last commit. I pushed a new version which remove this change again. Sorry for the trouble and thanks for your community work / merging my PR anyway. 👍

return <AnnotationExample style={styles.map} annotation={{
title: 'More Info...',
onFocus: () => {
alert('Annotation gets focus');

Choose a reason for hiding this comment

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

no-undef: "alert" is not defined.

Choose a reason for hiding this comment

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

no-alert: Unexpected alert.

Choose a reason for hiding this comment

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

no-alert: Unexpected alert.

Choose a reason for hiding this comment

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

no-undef: "alert" is not defined.

@ghost ghost closed this in cb874a5 Jan 29, 2016
@christoph-jerolimov christoph-jerolimov deleted the add-mapview-annotation-deselect branch January 30, 2016 02:41
doostin pushed a commit to doostin/react-native that referenced this pull request Feb 1, 2016
Summary:
For my project it was required to receive a notification when the MapView annotation was deselected.

So I renamed `onAnnotationPress` to `onAnnotationSelected` and added a new method `onAnnotationDeselected`, this names was "inspired" by the underlaying iOS API. The old API was still called and marked as deprecated.

But maybe you have an idea for a better naming (onAnnotationFocus/-Blur?) -- or should a deselected call the press method again without an annotation (undefined)?
Closes facebook#5167

Reviewed By: svcscm

Differential Revision: D2869695

Pulled By: nicklockwood

fb-gh-sync-id: 91795ac3f1e4533b250af8901534d8870729d9db
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants