https://kotlinlang.org logo
#compose
Title
# compose
a

allan.conda

06/09/2022, 9:35 AM
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

Albert Chang

06/09/2022, 10:00 AM
https://github.com/mxalbert1996/Zoomable The sample is exactly that.
👍 3
a

allan.conda

06/09/2022, 10:49 AM
Wow! Does it work well inside a ViewPager?
m

Michael Paus

06/09/2022, 10:58 AM
Would be nice to add rotation too to complete the gestures. 🙏
a

Albert Chang

06/09/2022, 11:09 AM
@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

allan.conda

06/09/2022, 11:19 AM
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

Michael Paus

06/09/2022, 11:55 AM
@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

Colton Idle

06/09/2022, 2:00 PM
Zoomable in a pager... Interesting
a

allan.conda

06/09/2022, 7:54 PM
Pretty common. Like Instagram
c

Colton Idle

06/09/2022, 7:56 PM
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

allan.conda

06/10/2022, 5:14 AM
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

Albert Chang

06/10/2022, 5:57 AM
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

allan.conda

06/11/2022, 5:39 AM
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

Albert Chang

06/11/2022, 12:27 PM
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

allan.conda

06/12/2022, 2:34 PM
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!
6 Views