oleksandrbalan / pagecurl

This library allows to create an effect of turning pages, which can be used in book reader applications, custom on-boarding screens or elsewhere.
Apache License 2.0
303 stars 25 forks source link

Are you using HorizontalPager from Compose #15

Open cacato86 opened 1 year ago

cacato86 commented 1 year ago

Hi, first of all, congratulations on your amazing work. The animation looks fantastic.

I've tried to use your library, but I have a super complex use case (in summary, it's a SpannableText with images, where the images can be zoomed, and also options that can be clicked). The problem arises when attempting to interact with everything.

I have two questions:

First, when I use HorizontalPager from Compose, these problems disappear, but of course, I can't apply your fantastic animation. So, I'd like to know if you are using this component in your implementation.

Would there be any possibility of using just your animation in some way with the HorizontalPager offered by Google?

Thank you so much for your time, mate, and keep up the good work!

oleksandrbalan commented 1 year ago

Thank you for your kind words 🤗

  1. Nope,PageCurl is basically a box, where max 3 items are added (previous page, current page and next page). The animation is just a bunch of shadow drawing and clipping those child composables.

  2. Unfortunatelly I do not think this would be possible, at least now I do not know how 😅

However if you could reduce your use-case to some small reproduction example and send it here, I may take a look whether PageCurl gestures could be adjusted to not collide with interactive components inside.

cacato86 commented 1 year ago

Thanks for your quick response, Olek!

Unfortunately, I can't share a small sample with you, as it's quite difficult to extract from the main logic. However, the main idea is to render a TextView containing InlineTextContent. Inside this InlineTextContent, you have a placeholder that renders an AsyncImage from Coil with a GestureDetector for zooming in/out.

I've been researching how to create animations with the new HorizontalPager (which works perfectly with other elements), and I came across this post: https://www.sinasamaki.com/pager-animations/ where the author uses the .graphicsLayer to handle all the logic.

I'm wondering if you could share your approach for shadow drawing and clipping in some way, and I could try to help you adapt it to the new HorizontalPager from Google. This way, you'll end up with a truly solid library.

oleksandrbalan commented 1 year ago

Yeah, I see 👌

Thx for sharing an article, I will check it 👀

The main drawing logic is in: https://github.com/oleksandrbalan/pagecurl/blob/main/pagecurl/src/main/kotlin/eu/wewox/pagecurl/page/CurlDraw.kt

Now I am on a finish line of another side library, so you are welcome to contribute 😄 Then when I will have some free time I will also try how PageCurl drawing could be integrated with HorizontalPager 👍

cacato86 commented 1 year ago

Yeah, I see 👌

Thx for sharing an article, I will check it 👀

The main drawing logic is in: https://github.com/oleksandrbalan/pagecurl/blob/main/pagecurl/src/main/kotlin/eu/wewox/pagecurl/page/CurlDraw.kt

Now I am on a finish line of another side library, so you are welcome to contribute 😄 Then when I will have some free time I will also try how PageCurl drawing could be integrated with HorizontalPager 👍

Hey Olek, any news on that? 😄

oleksandrbalan commented 1 year ago

I have tried, but failed 😄

Actually simple clipping is be possible, but I had a problem with drawing a back-page over the "previous" page, and also drawing a shadow over the "next" page.

So for now it is on hold 🧊

cacato86 commented 1 year ago

Thanks a lot for try out!

Let me know if I can help in something, would be a dream to have it 🙏

Also, if you have a branch where you are trying the new implementation let me know so maybe I can have a look :)