We’re struggling to achieve Zoomable Images in a P...
# compose
a
We’re struggling to achieve Zoomable Images in a Pager since Pager steals all the touches and
pointerInput
seems doesn’t have the pointer id to detect the number of pointers on screen. Anyone tried anything similar? We can’t find an open-source code or snippet available so far.
a
https://github.com/mxalbert1996/Zoomable The sample is exactly that.
👍 3
a
Wow! Does it work well inside a ViewPager?
m
Would be nice to add rotation too to complete the gestures. 🙏
a
@allan.conda Are you talking about the accompanist
Pager
or the
ViewPager2
? If the former, yeah it works well as shown in the sample. If the latter, I’m not sure and I don’t think there’s anything I can do if it doesn’t work.
@Michael Paus Is there any scenario where you need that?
a
Woops, I didn't notice it's in a pager in the demo. Yes I meant Pager :) . This looks amazing, let me try it
👍 2
m
@Albert Chang For image views this might be interesting. E.g., imagine the image displays a map which you would like to see from a different angle. Of course this must be optional because you do not always want a rotation.
c
Zoomable in a pager... Interesting
a
Pretty common. Like Instagram
c
Gotcha. I don't use Instagram but I would've thought that the two gestures kinda trample each other. But if it works there then I suppose it's a valid use case. Thanks!
a
Thank you for sharing this! It doesn’t fit our requirements but it is very helpful and we’ll try to refer its code. Let me give my feedbacks here: • It doesn’t let you swipe pages in case there is zoom already applied. • It lets you drag image across the screen even though you didn’t zoomed it enough to cover whole surface of the screen • It uses layout instead of graphics layer which is a bit laggy
a
It doesn’t let you swipe pages in case there is zoom already applied.
Yeah this is by design.
It lets you drag image across the screen even though you didn’t zoomed it enough to cover whole surface of the screen
If I understand you correctly you are probably not applying
Modifier.aspectRatio()
as shown in the usage section of the README and the sample.
It uses layout instead of graphics layer
This is also by design. The original version is using graphics layer, however as stated in the README:
This version is mainly intended to be used to show images. If the image is larger than the screen, when zoomed, the original version will show the upscaled version of the downscaled image, while this version will directly scale the image to the zoomed size, which has higher quality.
👍 2
💯 2
a
about the pager, is it possible and are you open for PRs to make it configurable? 4/5 of the apps I tested works like I wanted it, only Facebook has the behavior similar to yours. We are rewriting our component to compose so we’d like to keep the behavior basically.
a
Sure! PRs are always welcome. I may also look into this myself when I have time.
I have implemented the feature. You can try it by using
1.5.0-SNAPSHOT
(instructions on how to use snapshot builds are in README).
1
❤️ 1
a
Wow!!! I'll have a look, and thanks!
👍 1
🎉 1
I’m having problems getting the snapshot repo working, I’ll settle with the stable version for now!