-
Notifications
You must be signed in to change notification settings - Fork 25k
[MapView] add image support for annotation callouts, refactored config #1907
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
Conversation
|
Hmm, looks like I forgot about support for normal urls that are not project resources. I'll try to add that in the next days |
|
I realize this is just an extension of the style from #1247, but what do you think about making the callouts react components? Then we could support arbitrary callouts instead of just images and buttons. The way we typically do that is to pass the special views as children, then in native insertReactSubview we would grab the callout views and set them as the accessory views. You can differentiate the callout views from normal children/subviews by passing the tag IDs of the callouts as a prop to the parent MapView. I know that's a lot of work, so we can potentially keep this approach for now and change the API/approach later. Also, can you remove all unrelated changes to babel, podspec, etc? |
|
Passing to @a2 who handled the last one, and cc @nicklockwood and @vjeux for thoughts on API. |
|
Also, can you add usage of this stuff to the map example? |
|
Okay finally got the code in a state I'm happy with. I think using react components is a really cool idea and definitely something to add in the long term. When I started I didn't know how to implement this kind of behavior so went with the simpler solution to extend the API. I'll edit the map example when I'm back home later the day. |
|
Okay, cleaned the commits up and removed stuff that shouldn't be there. Also added some simple usage to MapViewExample.js |
|
ping @a2. Anything else needed for this? 😄 |
|
@facebook-github-bot import |
|
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/102516373428940/int_phab to review. |
|
@vjeux Can you look at the JavaScript API for this? I think we could DRY up the duplicate code for the two shapes, and I'm not sure if the inner "config" dictionary is necessary. |
|
I'm also with the opinion of @sahrens, at this point we're adding a lot more configurations to the popup and instead of hardcoding all those, it would be better to let the user render an arbitrary React component inside. This way we don't need to add a lot of complexity to that component that's not going to match all the use cases and instead provide a generic way to extend it. What do you think? |
|
That sounds good. Better to just put in arbitrary components that the user can specify. |
|
@vjeux What do we want to do with this PR then? |
|
I'll try to take a look at how to pass a react component to the annotation once I'm a bit more free on time. Do you guys have a class/component somewhere where this has already been done for reference? |
|
@dvcrn this is actually not a simple problem, and it's something I've been investigating. The problem is that unless a (non-root) React component is a direct descendant of another component, it's won't get processed by the resolver or layout system. Ideally it would work like this: But due to the aforementioned limitations, I think it would actually have to be more like this: i.e. the whole annotation would need to be a component in its own right, and a child of the MapView, otherwise it won't get processed correctly. @vjeux, does that sound right? Or am I missing something? Maybe there's a way to hide this implementation detail? |
|
Yeah this is annoying, I'm pretty sure that it hasn't been designed that way but it is just the result of the current way it is implemented and can be fixed |
|
I see, thanks for the explanation. Besides that, is this PR in a usable state until that kind of functionality can be implemented or should we directly try to add the annotation view as a react component? |
|
Ping. Is there anything I can help with here? |
|
I think we should close this until we have proper support for components in callouts. @nicklockwood and @vjeux, thoughts? |
React/Views/RCTMapManager.m
Outdated
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.
@machard good point and thanks for the comment. But since this PR is 'on hold', I am not sure whether it's worth changing the code now or just wait for react components in callouts
|
I read a bit through the code and found that TabBarIOS (http://facebook.github.io/react-native/docs/tabbarios.html#content) is implemented very similar and a good reference in how this could look later on. To clarify, is the behaviour we want for this? Not that I start and waste my time with this :p |
|
That sort of thing would be ideal for me - I've had a go at implementing it myself but I got a bit stuck. |
Summary: public The dev mode override feature was built with the assumption that bunlded JS would be minified, and broke with unminified JS. This fixes that by using a more robust regex-based search. Reviewed By: tadeuzagallo Differential Revision: D2581240 fb-gh-sync-id: 4d4b45eb8573ceb956b7259550d80a9807f83d59
…tons, further prepared for more types of accessories
- offloaded image generation for callouts into a separate function to reduce code size by a good chunk. - Fixed default images not getting used correctly - Added status code check for remote images
|
@dvcrn updated the pull request. |
|
no more silent updates, huh? 😄 Should I close this PR? |
|
Any updates on this? |
|
Closing since no activity on the PR. let's re-open if you wanna work on it again. |
|
Custom callouts views are supported now on iOS, so this PR is now moot. |
|
yup - not necessary anymore |
Addition / refactor to #1247
I realized while using the new callouts that support for images is still missing and that more callout types might get added in the future which is a bit awkward with the old config method. Refactored the code a bit and added image support to make sure there won't be bigger issues later on.
Example:
Difference from the last version
becomes to
typefor allowing to pick the accessory type (currentlybuttonandimage)on...CalloutPressinto new config underonPressconfigsub object for passing additional parameters to the accessory. Currently supported areimagewhen type is image, anddefaultImagewhenimageis not a local ressource