-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 lightbox for enlarging chat images #304
Conversation
source={{uri: this.props.currentMessage.image}} | ||
/> | ||
<Lightbox | ||
navigator={this.props.navigator} |
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.
@cooperka I don't think you can assume this.props.navigator
exists.
Even if it does, not everyone uses react-natives Navigator
which is what this package is assuming.
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.
If navigator
is null, the lightbox still renders just fine :) In fact, I don't even use it myself. It's recommended by lightbox, but not necessary by any means.
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.
I just added it to propTypes
where it defaults to null
. Hopefully this helps.
@cooperka Hey! Thanks for the PR :) I would love to hear what others have to say though |
Thanks @kfiroo! Honestly to me it seems like an oversight that this feature doesn't already exist, as everyone I've shown the chat interface to has tried to tap my mock image to see it larger and been disappointed when nothing happens. We could definitely let people implement this on a per-app basis instead, but that just seems a little redundant to me. This chat is supposed to be "gifted" 😉. I'm also interested to see what other people have to say. |
@cooperka @dgdavid Yeah, I hear you. I'm starting to turn too :) Few questions though,
|
@kfiroo it looks like there are a ton of new features coming as part of a major refactor, and I'm not quite sure but maybe it will even be able to use its own instance of Before the refactor (currently):
After the refactor:
TL;DR: I think we should go ahead and merge this PR, and if needed we/I can help contribute to Lightbox to bring it up to par with where we want it in the long-term. |
@cooperka take a look at this fork https://github.com/shoutem/react-native-lightbox |
@kfiroo Nice! Want me to use that one here instead? |
@cooperka Not sure actually, we should use the one that works better :) |
Interesting, let me know how it turns out! Lightbox does seem by far the most popular of the options, and intends to cover the gallery use-case with the refactor, but if something else works better I'm all for it. |
I wouldn't hold my breath waiting for that refactor to land.. repo hasn't changed in a year or so |
Definitely agree. I asked about the status in that thread (oblador/react-native-lightbox#8 (comment)), and at worst I'll just fork the repo in order to merge a few of the nice PRs there. Should work fine either way. |
@kfiroo there's an update here: oblador/react-native-lightbox#8. Honestly we don't need all the bells and whistles from the proposed refactor of lightbox, but there are several PRs that would be nice to have merged. Shall we fork it? |
@cooperka I didn't like how it works, but I guess it might be a good enough, out-of-the-box solution for many users, so I we can merge it or try with the In my app, I ended up writing something myself, I can try to extract it to its own repo and see if we like it better. |
I agree that lightbox is not ideal... if you can extract your logic into something simple and usable I'm all for it! How long do you expect that to take? |
@cooperka I'll try to do it this weekend |
+1 |
Currently the fix is unpublished.
@kfiroo how goes your extraction? I updated the props a bit on this PR, I think it's better and more generic after the changes. Also allows passing image props like |
@cooperka I couldn't find time to do it, I think we can merge your PR for now and get to it later if I ever get to it :) |
Yes, good to merge! I tested it just now after adding the new prop. |
@cooperka Does this work out of the box, or is there something I have to configure to get the lightbox to pop up? I simply tried updating to the latest version of react-native-gifted-chat and clicked on an image, but nothing happened. Sorry for the stupid question. 😛 UPDATE:
Thanks for the pr. So awesome! 👍 |
@booboothefool yeah it should work out of the box, no setup needed! You can try getting it to work in the example app, and if it's still not working just send us a link to your code and we can take a look. Might be silly, but also make sure you've run Also, if you're passing in a custom component e.g. |
@cooperka Well I got everything hooked up, but do you notice any performance issues with lightbox? The close is extremely slow on iOS. It's like the laggiest thing I've ever seen. 😆 oblador/react-native-lightbox#2 Doesn't seem to be any solid solutions though, unfortunately. |
Haha yeah it's really bad for large images. The issue is actually that it's trying to display an enormous image at full resolution instead of down-sampling it. I wrote custom logic in my client app to resize the image to 720p at 80% quality before displaying, and then it works very smoothly. |
@cooperka Can you explain how you did it? I'm using https://github.com/ivpusic/react-native-image-crop-picker for the upload:
which makes the image look like a butthole, like you can see every single big pixel and can't even tell what the picture is anymore, but I still can't get the animation smooth. 😝 UPDATE: Nevermind. I can't get this to work smoothly enough for my needs, so I just ended up using react-native-router-flux to just throw up another modal, and it's super smooth, even with huge full-resolution images. Just without the super slick lightbox animation unfortunately, but I'd rather it not lag. 👍 |
Does image can be zoomed now? |
Sadly there is not much engagement for react-native-lightbox. Last change was 7 month ago. |
Oh no>< |
Images sent in messages will be enlarged when you tap them.
Also adds 2 new props:
imageProps
andlightboxProps
. These will be passed through to the<Image>
and<Lightbox>
, respectively. For example, you can now specify an imageonLoad
callback.Tested and verified on iOS and Android.
Note: Uses a commit hash instead of version number in order to fix a warning on Android that's currently unpublished.
You can read more about react-native-lightbox here 🍹